With the help of this GSM relay, you can turn on any load rated for 220 V and with a power of not more than 2 kW, in any corner of the Earth where there is a cellular network.
This device is controlled by arduino nano via gsm module SIM800L. A functional diagram with a list of components is shown below. It can operate both from built-in batteries and from a 220 V network. When operating from a network, the load can consume up to 2 kW of electricity. Battery operated, maximum output power 300W.
Briefly about the scheme.
In this device, 4 blocks can be distinguished:
- inverter unit
- controller and battery pack
- uninterruptible power supply unit
- Control block.
The inverter unit is a 500t ordinary car inverter. It will work with less power, but the maximum output power will also decrease in proportion to the power of the inverter.
The controller and battery pack is an ordinary cheap BMS S3 driver designed to connect 3x lithium-ion batteries. Batteries are high current. They can deliver a current of 35 amps. If you have less power, then you can buy cheaper batteries with a lower maximum current.
The uninterruptible power supply unit is made on the transistor VT3, VD4, R4, R5, R3. The cathode of the zener diode VD4 is connected directly to the power supply and when power is applied, the transistor VT3 opens. After it is opened, a negative potential comes to all relay inputs and the relays switch to the power supply mode of the circuit from the power supply. An important feature of ready-made relay assemblies: some of them work when a positive potential comes to the input, and some work when it is negative. If you have the first option, then you need to rearrange R3 to open the emitter of the transistor VT3 and connect the relay input to the emitter of the same transistor.
Control unit - assembled on the SIM800 module and arduino nano.
This is what the assembled circuit looks like
This is what it looks like packed
In order for the device to start receiving SMS from your phone, you need to write your phone number into the your_phone variable. It is also possible to connect an LCD display to the Arduino, for example, wh1601 or wh0802, but you will need to uncomment all the lines with the inscription lcd.
Code
char your_phone = "+79148389933";
#include <SoftwareSerial.h> // ΠΠΎΠ΄ΠΊΠ»ΡΡΠ°Π΅ΠΌ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ SoftwareSerial Π΄Π»Ρ ΠΎΠ±ΡΠ΅Π½ΠΈΡ Ρ ΠΌΠΎΠ΄ΡΠ»Π΅ΠΌ ΠΏΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠΉ ΡΠΈΠ½Π΅ UART
SoftwareSerial softSerial(8,9); // Π‘ΠΎΠ·Π΄Π°ΡΠΌ ΠΎΠ±ΡΠ΅ΠΊΡ softSerial ΡΠΊΠ°Π·ΡΠ²Π°Ρ Π²ΡΠ²ΠΎΠ΄Ρ RX, TX (ΠΌΠΎΠΆΠ½ΠΎ ΡΠΊΠ°Π·ΡΠ²Π°ΡΡ Π»ΡΠ±ΡΠ΅ Π²ΡΠ²ΠΎΠ΄Ρ Arduino UNO)
// include the library code:
//#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
//const int rs = 12, en = 11, d4 = 5, d5 = 6, d6 = 7, d7 = 10;
//LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // Π Π΄Π°Π½Π½ΠΎΠΌ ΡΠ»ΡΡΠ°Π΅ Π²ΡΠ²ΠΎΠ΄ TX ΠΌΠΎΠ΄ΡΠ»Ρ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ ΠΊ Π²ΡΠ²ΠΎΠ΄Ρ 2 Arduino, Π° Π²ΡΠ²ΠΎΠ΄ RX ΠΌΠΎΠ΄ΡΠ»Ρ ΠΊ Π²ΡΠ²ΠΎΠ΄Ρ 3 Arduino.
// ΠΠ½ΠΈΡΠΈΠΈΡΡΠ΅ΠΌ ΡΠ°Π±ΠΎΡΡ ΡΠΈΠ½ UART Ρ ΡΠΊΠ°Π·Π°Π½ΠΈΠ΅ΠΌ ΡΠΊΠΎΡΠΎΡΡΠ΅ΠΉ ΠΎΠ±Π΅ΠΈΡ
ΡΠΈΠ½: //
String buf2,buf3;
int g=0;
String cmd1;
void setup(){ //
init_port();
// lcd.begin(16, 2);
// Print a message to the LCD.
//lcd.clear();
// lcd.setCursor(0, 0);
/// lcd.print("VKL");
// lcd.setCursor(0, 1);
/// lcd.print("ZHDITE");
/// init_port();// ΠΠ½ΠΈΡΠΈΠΈΡΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΡ Π΄Π°Π½Π½ΡΡ
ΠΏΠΎ Π°ΠΏΠΏΠ°ΡΠ°ΡΠ½ΠΎΠΉ ΡΠΈΠ½Π΅ UART Π½Π° ΡΠΊΠΎΡΠΎΡΡΠΈ 9600 (ΠΌΠ΅ΠΆΠ΄Ρ Arduino ΠΈ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠΌ)
softSerial.begin(9600); // ΠΠ½ΠΈΡΠΈΠΈΡΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΡ Π΄Π°Π½Π½ΡΡ
ΠΏΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠΉ ΡΠΈΠ½Π΅ UART Π½Π° ΡΠΊΠΎΡΠΎΡΡΠΈ 38400 (ΠΌΠ΅ΠΆΠ΄Ρ ΠΌΠΎΠ΄ΡΠ»Π΅ΠΌ ΠΈ Arduino)
Serial.begin(9600);
delay(30000);
// cmd1 ="AT+CMGF=1rn";
softSerial.print("AT+CMGF=1rn");
/// print_lcd(cmd1);
delay(1000);
dellAllSMS();
// cmd1 ="AT+CMGDA="DEL ALL"rn";
// print_lcd(cmd1);
//cmd1="AT+CPAS";
/// print_lcd(cmd1);
} //
char c;
int m=0;
int i=0;//
int n=0;
// ΠΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΡΠ΅ΡΡΠ°Π½ΡΠ»ΡΡΠΈΡ: // ΠΡΡ ΡΡΠΎ ΠΏΡΠΈΡΠ»ΠΎ Ρ ΠΌΠΎΠ΄ΡΠ»Ρ - ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΡ, Π° Π²ΡΡ ΡΡΠΎ ΠΏΡΠΈΡΠ»ΠΎ Ρ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ° - ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ ΠΌΠΎΠ΄ΡΠ»Ρ
void dellAllSMS(){
/* This deletes all sms in memory
*/
softSerial.print("AT+CMGDA="DEL ALL"rn"); // set sms to text mode
delay(3000);
}
void pin_on_setb()
{
digitalWrite(2,1);
digitalWrite(13,1);
}
void pin_off_setb()
{
digitalWrite(2,0);
digitalWrite(13,0);
}
void pin_on_inv()
{
digitalWrite(3,1);
// digitalWrite(13,1);
}
void pin_off_inv()
{
digitalWrite(3,0);
// digitalWrite(13,0);
}
void init_port()
{
pinMode(2,1);
pinMode(3,1);
pinMode(13,1);
}
String readData(){
// this function just reads the raw data
uint16_t timeout=0;
while (!softSerial.available() && timeout<10000)
{
delay(10);
timeout++;
}
if(softSerial.available())
{
String output = softSerial.readString();
//if(DEBUG)
/// Serial.println(output);
return output;
}
}
String buf, bufferIndex;
int tempIndex=0;
int messageIndex;
int prev=0;
int power=0;
void loop(){ //
/* if(softSerial.available()){ Serial.write(softSerial.read());} // ΠΠ΅ΡΠ΅Π΄Π°ΡΠΌ Π΄Π°Π½Π½ΡΠ΅ ΠΈΠ· ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠΉ ΡΠΈΠ½Ρ UART Π² Π°ΠΏΠΏΠ°ΡΠ°ΡΠ½ΡΡ (ΠΎΡ ΠΌΠΎΠ΄ΡΠ»Ρ ΡΠ΅ΡΠ΅Π· Arduino ΠΊ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΡ)
if( Serial.available()){softSerial.write( Serial.read());} // ΠΠ΅ΡΠ΅Π΄Π°ΡΠΌ Π΄Π°Π½Π½ΡΠ΅ ΠΈΠ· Π°ΠΏΠΏΠ°ΡΠ°ΡΠ½ΠΎΠΉ ΡΠΈΠ½Ρ UART Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΡΡ (ΠΎΡ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠ° ΡΠ΅ΡΠ΅Π· Arduino ΠΊ ΠΌΠΎΠ΄ΡΠ»Ρ )*/
// lcd.clear();
// lcd.setCursor(0, 0);
// lcd.print("Nagruzka");
// lcd.setCursor(0, 1);
// if (power==1)
// {
// lcd.print("VKL");
// }
// else {lcd.print("VIKL");}
softSerial.print(F("AT+CMGL="ALL",0"));
softSerial.print("r");
buf = readData();
// Serial.println(buf);
tempIndex = buf.lastIndexOf("+CMGL: ");
tempIndex = tempIndex + 6;
bufferIndex = buf.substring(tempIndex);
bufferIndex = bufferIndex.substring(1,(bufferIndex.indexOf(",")));
messageIndex = bufferIndex.toInt();
///Serial.println(messageIndex);
if(prev!=messageIndex)
{
tempIndex = buf.lastIndexOf(your_phone);
// lcd.clear();
// lcd.setCursor(0, 0);
// lcd.print("SMS READ");
if((digitalRead(4))&&(tempIndex!=-1))
{
pin_on_inv();
delay(2000);
pin_off_inv();
// i=1;
// power=1;
}
else
{
pin_on_setb();
delay(2000);
pin_off_setb();
// i=1;
// power=1;
}
// send_sms(number3);
prev++;
}
if(messageIndex>=2)
{
dellAllSMS();
// lcd.clear();
// lcd.setCursor(0, 0);
// lcd.print("SMS READ");
// lcd.setCursor(0, 1);
// lcd.print("SMS DEL");
// cmd1 ="AT+CMGDA="DEL ALL"rn";
// print_lcd(cmd1);
prev=0;
}
delay(10000);
}
STL file for box printing can be found
Video of work:
Source: habr.com