Do I have to use 3 sec delay after every AT commands in sim800l.
Every site I browse has delay between every commands, some has low some has very high.
The project I am working on is monitor temperature of temperature sensitive material using DHT every second and upload to server and I think using delay is bad. I wouldn't mind not monitoring temperature for few seconds until at commands run but using 60 sec delay total is I think bad.
Can't this have any workaround like creating a recursive loop of 10 sec which check temperature instead of delay. Will it interfere with sim800l?
No the proper way to handle AT commands is to parse the answers you get and handle those correctly. If you get OK for example then you can proceed.
Poor code written by lazy programmers will just wait for what they think is long enough for the module to execute the command and be ready for the next one… often this is too long but other times it’s not long enough and the next command fails silently and you have a bug….
You just come across bad examples.
In fact, between commands there should be no delays, but waiting and parsing responses from the modem. That is, it is necessary not only to wait 3 seconds, but to check. whether the modem answered OK or not. If the modem has already answered, then you can give a new command
This is mostly correct, but commands take time to respond, and ‘waiting’ could easily affect any other real time activities in your code.
I’m using a self-written version of the FONA library that runs asynchronously with multiple ‘states’ and callbacks - that allow the main program to run continuously.
It’s pretty poorly hacked together out of necessity, but I’m still able to handle polled inputs, serial comms and timed output events at better than 20mS resolution at any time whether the modem is busy or not.
If there’s a hardcore experienced developer that would like to take it further, DM me, and we might be able to move forward.
Read gets you only one byte when there is something to read, so not only it’s not a pointer to a cString you can use in strcmp() but it’s not accumulating the characters you get.