Notify-doorbell-sms-final

Arduino SMS via Ethernet Pushing Bell

Arduino

This project used Arduino ethernet shield to send SMS over internet.

bell-push-sms

 

Sample code to send sms on a push button

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 };
IPAddress ip(192,168,1,20); //<<< ENTER YOUR IP ADDRESS HERE!!!
EthernetClient client;

const int requestInterval = 6000;
const int bellpin = 2;
const int buzzerpin = 6;
char serverName[] = “www.iatlbd.com”;

boolean requested;
long lastAttemptTime = 0;

String currentLine = “”;
boolean reading = false;
boolean bellring=false;
boolean bellpress=true;

void setup() {

pinMode(bellpin, INPUT);
pinMode(buzzerpin, OUTPUT);
// reserve space for the strings:
currentLine.reserve(256);

// initialize serial:
Serial.begin(9600);
// attempt a DHCP connection:
Serial.println(“Ethernet begin”);
if (!Ethernet.begin(mac)) {
// if DHCP fails, start with a hard-coded address:
Ethernet.begin(mac, ip);
}
Serial.println(“Ethernet initialized”);
digitalWrite(buzzerpin,LOW);

lastAttemptTime = millis();

}

void loop()
{

if (client.connected()) {
if (client.available()) {

char inChar = client.read();
currentLine += inChar;

if (inChar == ‘\n’) {
Serial.println(currentLine);
currentLine = “”;
}

if ( currentLine.startsWith(“SMS”)) {

reading = true;
Serial.println(currentLine);

}

if (reading) {

Serial.println(“Stop the client”);

client.stop();
reading=false;
currentLine=””;

}
}
}
else if (millis() – lastAttemptTime > requestInterval && bellring==true) {

connectToServer();
bellring=false;

}else{

bellpress=digitalRead(bellpin);
if(bellpress==false){
Serial.println(“bellpress false”);
digitalWrite(buzzerpin,HIGH);
delay(4000);
digitalWrite(buzzerpin,LOW);

bellring=true;

}
}
}

void connectToServer() {

Serial.println(“connecting to server…”);
if (client.connect(serverName, 80)) {
Serial.println(“making HTTP request…”);

client.println(“GET /api?sms=door+bell+ring HTTP/1.1”);

client.println(“HOST: www.iatld.com”);
client.println();
}

lastAttemptTime = millis();
}

One thought on “Arduino SMS via Ethernet Pushing Bell

Leave a Reply