fezder
Well-Known Member
Hey people, this time I have problem with this scenario:
I'm making an location tracker for my brother's motorbike, surely you know how wanted stuff those can be.
Idea is simple; when module is called on, it sends location data (google map would be awesome, but that should be done easily after getting raw data) via text message to number that is pre-set on code (so it doesn't send message to whoever calls it, only number that has been set on.
Trouble currecntly is that location data is also asked from SIM800 with AT commands, so that must be asked BEFORE entering SMS-state (all data that is written after switching to sms is sent in that message)
I thinked that solution would be that location data is first asked->save data (as string) to array->send that location data via SMS.
currently working code that I can use to send normal , simple data like millis, temperature, you get the idea:
I think that issuea is that I understand string bit wrong...
I'm making an location tracker for my brother's motorbike, surely you know how wanted stuff those can be.
Idea is simple; when module is called on, it sends location data (google map would be awesome, but that should be done easily after getting raw data) via text message to number that is pre-set on code (so it doesn't send message to whoever calls it, only number that has been set on.
Trouble currecntly is that location data is also asked from SIM800 with AT commands, so that must be asked BEFORE entering SMS-state (all data that is written after switching to sms is sent in that message)
I thinked that solution would be that location data is first asked->save data (as string) to array->send that location data via SMS.
currently working code that I can use to send normal , simple data like millis, temperature, you get the idea:
I think that issuea is that I understand string bit wrong...
C:
#include <SoftwareSerial.h>
SoftwareSerial SIM800(10, 11); // RX, TX
String a;
String b;
void setup()
{
Serial.begin(9600); //harware serial, debugging purposes
SIM800.begin(9600); //SIM800 module, for sending AT-commands
SIM800.print("ATE0\r\n"); //echo off
}
void loop()
{
a = SIM800.readString(); //data from SIM800
if (a == "\r\nRING\r\n")
{
SIM800.print("AT+CMGF=1\r\n"); // Set the shield to SMS mode
SIM800.print("AT+CMGS=\"**********\"\r\n");
delay(200);
SIM800.print(millis()); //here is what data is to be sent
//SIM800.print((String)
SIM800.print("\r\n");
delay(500);
SIM800.print((char)26);//the ASCII code of the ctrl+z is 26 (required according to the datasheet)
delay(100);
SIM800.print("\r\n");
}
}