Trigger SMS Code

Hi guys Im new at using arduino heck Im new at scripting, I am looking on building a project, but want to see how you guys would script it.

I am going to use the Arduino Uno R3 with the sim 800L GSM module and small mechanical end switch to do the following.

The switches will be placed under a board or flat surface and if the switch is triggered it needs to send an SMS to one number with the Date and exact time incl seconds, where can I start learning how to do this or is there a project like this that I can learn from?

I generally write programs, I let the doc write the scripts. Start by posting a schematic, not frizzy thing. Include your choice of micro etc; you can always change it later. You mentioned switchers how are they wired into the system and how long are the wires. Trying to tell you where to start at is not very easy as we have no idea of your experience and skills. I would guess this is one of your first tries. I would suggest you watch some of the tutorials on line, on the arduino and basic electronics. The arduino cookbook will give you most of what you need for your project.

Awesome thanx man okay so, the wires are not long maybe 10cm each I started watching a few videos and learning as I go this is what I have done so far working on a on and off button:

#include <SoftwareSerial.h>

SoftwareSerial sim800l(2, 3);

#define button1 7

bool button_State;

void setup()
{

pinMode(button1, INPUT_PULLUP);
sim800l.begin(9600);
Serial.begin(9600);
delay(1000);
}

void loop()
{

button_State = digitalRead(button1);

if (button_State == LOW) {
Serial.println("Button pressed");
delay(200);

SendSMS();                      

}

if (sim800l.available()){
Serial.write(sim800l.read());
}
}

void SendSMS()
{
Serial.println("Sending SMS...");
sim800l.print("AT+CMGF=1\r");
delay(100);
sim800l.print("AT+CMGS="+xxxxxxxxxx"\r");
delay(500);
sim800l.print("SIM800l Intruder Detected!");
delay(500);
sim800l.print((char)26);
delay(500);
sim800l.println();
Serial.println("Text Sent.");
delay(500);

}

This is the switch I'm using to trigger sms: https://www.diyelectronics.co.za/store/limit-switches-probes/2014-small-mechanical-end-switch.html?search_query=mechanical+switch&results=43

I'm learning with the arduino uno and a SIM800L

What I'm planning to do is use those switches if stepped on to alert intrusion detected via sms

1 Like

To be safe since the switches do not state dry contacts I would be sure you run at least 1 mA through them. You can calculate that using Ohm's Law and the voltage used to drive the switch.