So, you also need a Raspberry Pi for this tutorial: Local PHP Serverįor this example, we’ll create a local PHP server on a Raspberry Pi. You can create a local PHP server on a Raspberry Pi, for example, or alternatively, you can create a PHP server on the cloud (hosting + domain name) that can be accessed from anywhere. The ESP will communicate with the PHP server periodically to check if there are any updates (a new file with a new MicroPython code). Update the record for the ESP making the request.īefore proceeding, make sure you check the following prerequisites.We provide the files for this method at the end of the tutorial.Ī better way to do it might be to create an SQL database on your server, with a record for each ESP with fields for ID (could be MAC address), the version running, time file downloaded (instructions not included). So, multiple boards running the same code can update themselves as we no longer delete the files from code, so the delete_ESP_data.php file can be removed. You don’t need to delete any files because all versions have a unique name.The URL for updates is taken directly from the new program you upload (it should indicate what the next uploaded file will be called).The files you upload have a version number on the name.Here’s an alternative method that doesn’t require deleting previous files and allows you to update multiple boards. Note that the new python file must also contain the instructions to delete the previous file from the PHP server and to check for updates. When you upload a new code, the process repeats.This new file has an instruction at the beginning of the code to make a request to the delete_ESP_data.php URL to delete the python file from the PHP server because it is already running the most updated code.When it restarts, it will be running the newly uploaded python file.If there is a new file available, the ESP will download it to its filesystem and reboot.The ESP checks for updates periodically by making a request to the get_ESP_data.php URL to search for a new program.py.Meanwhile, you upload a new python file that you want to run on your ESP to the Rpi PHP server.The ESP32 or ESP8266 executes whatever tasks you define.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |