Hello,
I'm finishing a project to protect my bee hives without counting the lipo battery, it cost me less than € 30
It's about connecting a SIM800L module, with a ThingsMobile SIM card (which has a virtually universal coverage), and a very low consumption when sending short text messages.
I do not want to send SMS, because they are expensive. My tactic is another: send short text messages, for example, send latitude and longitude to a certain web, with the POST protocol. Receive the data in a php of the server, and send from the php an email to my mail if there is an alarm.
A gprs module, a GPS module and a tilt sensor are connected to Arduino, so that if someone moves the hive, an alarm is created sending GPS data.
This is the php file that is on the server:
<?php
$DATE = gmdate("Y-m-d H:i:s");
$LAT = htmlspecialchars($_POST['lat'], ENT_QUOTES, "UTF-8");
$LON = htmlspecialchars($_POST['lon'], ENT_QUOTES, "UTF-8");
if (strlen($LAT) < 1)
goto end;
$message = "warning! The hive has been moved! lat = " . $LAT . "
lon = " . $LON . "
;";
$to = "myweb@gmail.com";
$subject = $DATE;
mail($to, $subject, $message);
end:
?>
This is the function that sends the data:
char kate[99];
void gprs_appendPOST_webhost(char data[], int length)
{
Serial.println("\n\nHTTP post method :\n");
/* Check Communication */
sim800.write(27);
sim800.println("AT");
delay(500);
sim800SerialData(); // OK
delay(50);
// SIM card inserted and unlocked?
sim800.println("AT+CPIN?");
delay(555);
sim800SerialData(); // +CPIN: READY
delay(50);
// Is the SIM card registered?
sim800.println("AT+CREG?");
delay(555);
sim800SerialData(); // +CREG: 0,1 OK
delay(50);
// Is GPRS attached?
sim800.println("AT+CGATT?");
delay(555);
sim800SerialData(); // +CGATT: 1 OK
delay(50);
// Check signal strength - should be 9 or higher
sim800.println("AT+CSQ");
delay(555);
sim800SerialData(); // +CSQ: 14,0 OK
delay(50);
// Reset the IP session if any
sim800.println("AT+CIPSHUT");
delay(555);
sim800SerialData();
delay(50);
/* Configure bearer profile 1 Connection type GPRS */
sim800.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
delay(500);
sim800SerialData(); // OK
delay(50);
/* APN of the provider */
//AT+SAPBR=3,1,"APN","wholesale"
sim800.println("AT+SAPBR=3,1,\"APN\",\"TM\"");
delay(555);
sim800SerialData(); // OK
delay(50);
// Enable GPRS - this will take a moment or two
sim800.println("AT+SAPBR=1,1");
delay(500);
sim800SerialData();
delay(50);
// Check to see if connection is correct and get your IP address
// (I hid mine here, but you'll get a real IP back)
sim800.println("AT+SAPBR=2,1");
delay(5000);
sim800SerialData(); // +SAPBR: 1,3,"0.0.0.0" OK
delay(50);
// ===========================
/* Terminate HTTP service */
sim800.println("AT+HTTPTERM");
delay(500);
sim800SerialData();
delay(50);
// ============================
// Initialize HTTP service or enablke HTTP mode
sim800.println("AT+HTTPINIT");
delay(5555);
sim800SerialData(); // OK
delay(50);
// Set parameters for HTTP session: Set HTTP profile identifier
sim800.println("AT+HTTPPARA=\"CID\",1");
delay(5000);
sim800SerialData(); // OK
delay(50);
sim800.println("AT+HTTPPARA=\"URL\",\"http://myweb.com/gprs/GPSpost.php\"");
delay(5555);
sim800SerialData(); // OK
sim800.println("AT+HTTPPARA=CONTENT,application/x-www-form-urlencoded");:
delay(5555);
sim800SerialData();
sprintf(kate, "AT+HTTPDATA=%d,10000", luze);
sim800.println(kate);
delay(5000);
sim800SerialData(); // DOWNLOAD
delay(50);
sim800.println(datuak);
delay(5000);
sim800SerialData(); // OK
delay(50);
// Post the data - wait a second for the response
sim800.println("AT+HTTPACTION=1");
delay(5000);
sim800SerialData(); // +HTTPACTION:1,200,142 OK
delay(50);
// URL where you can confirm that it's working
sim800.println("AT+HTTPREAD");
delay(5000);
sim800SerialData(); // +HTTPREAD:142
delay(50);
// Close the HTTP connection
sim800.println("AT+HTTPTERM");
delay(5000);
sim800SerialData(); // OK
delay(50);
// Disconnect the GPRS
sim800.println("AT+SAPBR=0,1");
delay(5000);
sim800SerialData(); // OK
delay(50);
}
char data[222];
char txtlat[33], txtlon[33];
float flat, flon;
int length;
void loop()
{
if(tilt == 1)
{
gps_NEO6M.listen();
read_gps(); // flat = -22.34; // flon = 111.34;
strcpy(txtlat, ftoa(flat));
strcpy(txtlon, ftoa(flon));
sprintf(data, "lat=%s&lon=%s", txtlat, txtlon);
length = strlen(data);
delay(2222);
sim800.listen();
gprs_appendPOST_webhost(data, strlen(data));
Serial.write(data);
Serial.write( " length:");
Serial.print(strlen(data));
}
delay(6000);
}