Introduction: GSM Text Operated Mains Switch
I just love technology!
My son bought me a GSM unit for Christmas last year, and I've just got round to using it !!
I have converted a £1.99 mechanical timer socket into a GSM text operated switch - and it was really quite easy!
The GSM board (eBay -SIM800L GPRS GSM Module Board Quadband QUAD BAND Antenna for MCU Arduino) uses AT commands and talks (and listens) to a serial port.
The project is based on this excellent article -
This is not just limited to switching on electrical equipment, it can be used for remotely unlocking gates or your car etc !!
In theory, more than one socket can be controlled - see last step.
As usual, my code probably isn't the most efficient, but it works.
**WARNING - RESPECT MAINS VOLTAGE or it will KILL YOU !! **
Step 1: Bits & Pieces
1 x 10K pull up resistor (relay 'on' digital o/p).
1 x relay 5v coil. I found some on eBay with 15 amp contacts - ideal for mains!
1 x arduino pro mini
SIM800L GPRS GSM Module Board Quadband QUAD BAND Antenna for MCU Arduino -eBay
AC-DC-5V-700mA-3-5W-Power-Supply-Buck-Converter-Step-Down-Module-for-Arduino - these are great little power supplies ! they deliver 5 volts at about 700 mA and are less than an inch square !! -eBay
Step 2: Utilising the Cheap Timer
These timers are ideal for mains projects as the Live side is already externally switched.
Remove the 2 screws & the motor unit. Be careful not to lose the plastic arm used to operate the micro switch (it will fall out) when you open the unit. Also the connector cover and spring part company when modifying the case !
I kept the micro switch as this can be used as a 'manual override', I also kept the LED!
Remove the front dial.
It was necessary to cut out the internal collar which I did with a pair of cutters and a bit of patience !
I also cut a slot for the GSM connector as the board itself lives in the top of the unit.
Step 3: Inside the Box
This image shows the location of the arduino, power supply & relay!
The GSM module lives on top. I used piece of plastic (old credit card) to cover the hole.
I used part of the clear packaging as a cover !
Step 4: The Code & Sim Card
The program uses the software serial library to communicate (via AT commands) with the GSM Board
Serial mySerial(9, 10); //9 GSM TX 10 GSM RX
I connected 5v, Gnd & reset, although the board seemed quite happy with reset floating!
I tested with the Arduino Uno before using the mini in the project.
There are a few delays in setup, without them connection is unpredictable - the Arduino Uno seemed to work ok without them, but the pro mini grizzled!
I also had to use an external 5v power supply with the pro mini, whereas, the Uno was quite happy being supplied from the pc usb port !
There is a choice of 2 commands to switch the device on and off.
4on# just turns the relay on.
4on$# turns the relay on and then sends back a text confirming it !
The same goes for 4off# & 4off$#
I purchased a cheap SIM card from Tesco & it worked straight away!
Just make a note of the number so you can text to it !
Step 5: Powering Up & Possible Future Development.
When the board powers up, the connection LED will flash.
When you have connected to a network, it will flash about once every 3 seconds !
Send text, 4on# or 4off# to turn the relay on and off.
Anyone with access to the SIM card phone number will be able to operate the switch!
A simple 'IF' statement to compare the allowed phone, would prevent this!
Future development would store the numbers (and check for them) of all mobile phones which were allowed access in the Arduino Eprom.
In the code, I have used digital o/p 4 and enabled 5 & 6!
In theory,(not yet tested), I could connect the TX / RX of the Arduino to pins 9 & 10 of another, both Arduino's should receive the same info !
So, what if another socket identical to this one, with the relay connected to digital pin 5 received the text via
KQ-130F Power Line Carrier Module Distance without External Components (search eBay) ??
In theory I could talk to a number of sockets with modified code !
Have fun and remember Mains Electricity WILL kill you !!
Step 6: Intermittent Reset Fix Sept 19th 2016
I noticed that sometimes, after a 4on# command, the device reset and failed to turn the relay on!
It would need the command sent again to operate correctly!
It would seem that occasionally, sending the command would suck just too much current and reset the Arduino.
I think I have resolved the issue by putting a 1000mf capacitor directly on the 5v & Gnd pins of the gsm board!
I'm guessing this is a tad large and possibly a 470mf should be fine!
Since the addition of the capacitor the device has worked fine !
We have a be nice policy.
Please be positive and constructive.