(TECH) Gate Command

Hello,

I would like to use rephone to be able to remote control by SMS my gate

I plan to use 2 magnetic switches to detect door position (open/close) and be able to send position by SMS and command the opening/closing by SMS also, using a relay as actuator on my existing installation.

I have medium Arduino knowledge (already play with it and done a ledstair project)

I already done preliminary tests : RePhone assembled, Firmware Updated with Arduino IDE, using javascript to respond to gsm text is Ok, Modem console is OK, Testing GPIO will be this weekend (need breadboard access ;- )

Using 2 switches & 1 relay I would use the following schematic :

Using Javascript, the init.js code would be like :

[code]// Init PINs
// A5, D9, 10, Switch Open
gpio.mode(10, INPUT)
// A6, D8, 11, Switch Close
gpio.mode(11, INPUT)
//B5, D7, 44, Relay Command
gpio.mode(44, OUTPUT)

var myphone = ‘+33600000000’;
var activate = ‘ACTIVATE’;
var state = ‘STATE’;

gsm.on_new_message(function (phone_number, message) {

//Basic Security !!
if (phone_number != myphone) { print('ignored message from : ’ + phone_number); return;}

switch(message) {
case activate: print(‘Activation…’); gpio.write(44, 1); for(var i=0;i<50000;i++){}; gpio.write(44, 0); break;
case state: var msg=’’;
var gate_opened = gpio.read(10);
var gate_closed=gpio.read(11);
if (gate_opened){msg=’’;} else if (gate_closed) {gsm.text(myphone, ‘Gate Closed !!’);} else {gsm.text(myphone, ‘Gate State Unknown !!’);}
gsm.text(myphone, msg);
print(msg);
break;
default: print(‘unknown command’);
}

});

print(‘RePhone Gate Command Ready !’);
gsm.text(myphone, ‘RePhone Gate Command Ready !’);
[/code]

Main questions are :
Does a pulldown (or pullup) resistor is needed ?
Does using javascript is a good idea ?
What do you think about my idea ?

Better have pulldown resistors, and have fun finding a relay that can be driven with 2.8 V. Even 5V relays are rare, you should consider using a relay driver, because the poor rephone will commit suicide after a few switches (relays are isolated because of a reason).

An optocoupler (4N35) before the relay could help you.

Like this:
Relay control.JPG

Hello,

Thank you for your very helpful suggestions :slight_smile:

For the best: dx.com/p/5v-relay-isolation- … rh8B_nhCUk
It’s all integrated. Also, if you want to use more channels, modules with 2/4 relays cost almost the same.