
Original :
0 : https://robocraft.ru/blog/2929
1 : https://robocraft.ru/blog/2946
2 : https://robocraft.ru/blog/2956
Working with the Internet (algorithm)
In order to find out the time and weather, you need to make a request to the Network. I decided to read the data output by PHP scripts (thus unloading the slow Arduino from unnecessary calculations – PHP is executed on the server), since free hosting and a domain (even of the second level) are not a problem now, and I just have one working (notice , what is the address of the large pictures and diagrams in the previous article?). I found services from which it would be easy to take time and weather, wrote two PHP scripts (time.php and weather.php, respectively) and now I access them with Arduino.
And the algorithm of work is as follows: Arduino receives a signal from nRF24L01 + (in this case, unlike the main module, it is more convenient to wait for an interrupt from the transceiver than to poll it every N seconds), generates the necessary HTTP request, sends it to the Web server, waits for a response, reads it 1 byte at a time, separates the useful information (“body”) from the HTTP headers and sends it back to the main module. That’s how easy it is.
COMMENTS