Hi All - VERY new to Arduino and struggling somewhat as I am from a BASIC background (Picaxe etc!)
Looking for guidance on how to do this a better way - I have it working but its extremely messy and convoluted at the moment.
Background on the project is to collect certain weather data (Temp, RH & windspeed) and send a warning via email when certain conditions are met.
I have the data collection working and displayed on LCD . Temp & Humidity from a RHT03 sensor using the DHT library and a Davis Anemometer for the windspeed.
I have the 3G module (SIM5216J) working (ie power control, checking network registration etc) and sending SMS initially but the code is very messy as the commands are not nice to send via serial and cause errors in the compiling.
The command I needed to send was as follows:
AT+CMGS="0418xxxxxx"
This caused compiler errors due to the quotes inside the quotes:
gsmserial.println ("AT+CMGS="0418xxxxxx"");
So I had to do it this way (bigger code snippet with more of the commands)
sendATcommand("AT+CMGF=1","OK",500);
Serial.println(F("3G : SMS Mode"));
gsmSerial.print("AT+CMGS=");
gsmSerial.write(34);
gsmSerial.print("0418xxxxxx"); //mobile number edited for privacy
gsmSerial.write(34);
gsmSerial.write(13);
delay(500);
gsmSerial.print("SIMCOM MODULE TEST");
gsmSerial.write(26);
delay(500);
Serial.println(F("3G : SMS Sent"));
This works but is not very tidy - mainly due to my lack of understanding on Ardunio & C!
Now my issue grows larger as I need to send a much more complicated set of commands to send an email!
The "@" and the quotes inside the message strings cause compiler issues and having to do it the way I did the SMS will get crazy messy!
See below for commands that have to be sent:
AT+CGSOCKCONT=1,"IP","3GAPN","0.0.0.0",0,0
AT+SMTPSRV="smtp.server.com",25
AT+SMTPAUTH=0
AT+SMTPFROM="username@server.com"
ATSMTPRCPT=0,0,"toaddr@server.com"
AT+SMTPSUB="email subject"
AT+SMTPBODY="message body"
AT+SMTPSEND
Can anyone suggest a better way to handle sending these serial strings? Maybe point me at a good tutorial or appnote that makes this clear and is not too generic - I've read the arduino pages on serial.print etc and still no clearer to me!
Cheers and sorry for such a long post
Stocky