It's incredibly cool to update that 'fantastic' sensor without shedding a single drop of sweat ( you know, it's always located in the most inaccessible place ), and updating the whole mesh 'on the air' is... priceless.
Let's see how.
Parts required- A working mesh ( as setup in Part 1 )
- ESP32 development board ( I used a generic DEVKITV1 )
- SD ( or microSD ) card module ( like this )
- SD ( or microSD ) card
- PlatformIO development software ( install from here )
- PainlessMesh library
Connect the SD board following this schematic ( a good alternative could be a board with integrated SD connector ):
- After programming the board with the OTA software you should prepare the SD card:
- empty SD card ( formatted fat32 )
- add the updated node software with the following name: firmware_ESP32_XXX.bin where XXX is the 'role' of the node you are updating ( the 'role' of the nodes of part 1 are: red, white, switchlamp )
- insert the SD card and restart the board
- the OTA server will start 'publicizing' the new software ( see line 124 ), and will start sending chunks of software to requesting nodes ( for one hour )
- the 'old' software on the node must be 'ota enabled' ( it wont update otherwise )
- the 'new' software must be 'ota enabled' ( to be updatable again )
- to be 'ota enabled' a software must call initOTAReceive(role), for example, the 'role' of the nodes of part 1 are: red, white, switchlamp ( yes is that easy )
- different nodes of the mesh, with different functions ( and software ), should be assigned different 'role' ( for example 'tsensor' for a temperature sensor, 'bridge' for a bridge and so on )
Something went wrong and ota does not work. Double check ( as engineering practice ) the following :
- the schematic
- I also added 10K pullup resistors ( to +3.3V ) on CS, SCK and MOSI ( should not be necessary as these are true push-pull outputs, but YMMV )
- the SD card is formatted fat32 and the software name is formatted correctly ( firmware_ESP32_XXX.bin, replace XXX with the 'role' of the nodes to update )
- check the log that spits out the board, if this error "sdcard_mount(): f_mount failed 0x(3)" is present ( and the board resets every few seconds ) you should have a 'hardware' problem or SD card problem
- check ( with an oscilloscope ) if the waveforms are similar to the following ( image to be added )
- check if the SPI signals are on different pins: CS=13 SCK=14 MOSI=15 MISO=12
Useful tools for testing and debugging:
PainlessMesh Listener App for Android ( author Bernd Giesecke, sources and documentation )
Comments