#include <DFRobot_sim808.h>
//Mobile phone number, need to change
#define PHONE_NUMBER "My number here"
//The content of messages sent
#define MESSAGE "Message here"
DFRobot_SIM808 sim808(&Serial);
#include<LiquidCrystal.h> //Header file for LCD Module
#include "WiFiEsp.h"
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
char ssid[] = ""; // Network Name
char pass[] = ""; // Network Password
int status = WL_IDLE_STATUS; // Wifi radio's status
int reqCount = 0; // number of requests received
WiFiEspServer server(80);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //lcd connected pins
const int sensor = A0; //Assigning analog A0 to LM35
float tempc; //Storing temp in °C
float tempf; //Storing temp in °F
float vout; //variable to store values from sensor
void setup()
{
// initialize serial for debugging
Serial.begin(115200);
// initialize serial for ESP module
Serial1.begin(9600);
// initialize ESP module
WiFi.init(&Serial1);
lcd.begin(16, 2);
lcd.print("DOG TRACKER\nDEVICE");
pinMode(A0, INPUT);
{
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}
Serial.println("Sim808 init success");
Serial.println("Start to send message ...");
//******** define phone number and text **********
sim808.sendSMS(PHONE_NUMBER,MESSAGE);
}
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
Serial.println("You're connected to the network");
// start the web server on port 80
server.begin();
printWifiStatus();
}
void loop()
// Looping of LM35
{ vout = analogRead(sensor);
vout = (vout * 500) / 1023;
tempc = vout; // Storing value in °C
tempf = (vout * 1.8) + 32; //conversion of °C to °F
Serial.println(tempc);
lcd.setCursor(0, 0);
lcd.print("Temperature = ");
lcd.setCursor(0, 1);
Serial.println(tempc);
lcd.print(" "); // overwrite old data with spaces
lcd.setCursor(0, 1);
lcd.print(tempc);
}
void printWifiStatus()
{
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print where to go in the browser
Serial.println();
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
Serial.println();
}