I am working with a Sim800L and Arduino Mega, plus some XBEE modules currently to gather intel from multiple pieces of hardware (via XBEE) back to the Mega, and then from there I am assembling the data and now transmitting to a MySQL database via a php page.
I have gotten the radio up and running so it doesn't reset. (so it is powered reliably - went through the big Caps and finally Li-Ion battery)
I have had piles of problems with the AT commands, but most of that is figured out now. Except, I have a couple questions.
I am essentially sending the following commands:
AT+SAPBR=3,1,"CONTYPE","GPRS" <--- is there a better command that will allow me to switch to the Sim7000G card AND have it work in a GPRS area until the LTE-M is turned on, then automatically work with LTE-M without me re-programming?
AT+HTTPPARA="URL","xxxxxx.ca/index.php?vars=1,19-6-2,20:5,11,0,2584,2033,1447,4,3107,2,2,3,3" <--- the vars are the data, seperated by comma, which i parse in php before inserting to MySQL
AT+HTTPACTION=2 <--- I understand this is a HEAD request only, so the body of the webpage isn't retrieved saving me data?
AT+HTTPREAD <--- Is this actually necessary if I'm not retrieving data from the web address?
AT+CFUN=0 <--- Is this the best way to "reset" the radio until the next time I want to send data?
The delays (most of them) were added/increased in duration over 2 days of messing around. I have had so much trouble with the radio seemingly not responding. The radio usually echoes the characters/commands back to me and I have them being pushed back to the Arduino Serial Monitor, but before i got the lengthy delays in there, there was many issues with the radio returning ERROR on some commands, or not responding at all.
I left the code running on my bench for a few hours today (before i got up to 6,8, and 15 seconds delays) with it looping through every 5 minutes, and when I checked the database, I had about a 50% success rate. but with the lengthy delays, it sucks up a lot of my processor's time just sitting idle. Now with the delays mentioned above it appears to be close to 100% success rate (I'm only about 40 minutes into testing so 8 out of 8 so far)
My goal is to pull data every 5 minutes from 4 different pieces of equipment, and send to the net. Currently each piece of equipment is polled, then this AT command loop is run, then the next piece of equipment is polled and then AT commands again....
It is a big job to re-write my code to gather the data and push all 4 machine's data to the web at once (going to run out of array memory possibly) so It's not an easy do. Is there any suggestions on how to speed up the existing system I have? The code is not actively watching for the radio's reply, but I'm not sure how to write an efficient function to do that given the half dozen different replies for the commands.
Also, is sending CFUN=0 after each session the best way to reduce battery consumption from the radio AND make sure there's no erroneous data usage going on?
Thanks in advance for any help/suggestions. Feeling reasonably frustrated right now so a little pointer could help me move forward.
I've attached my actual sketch if anyone is crazy enough to dig through my newb code.
Modbus to Cellular.ino (39.9 KB)