Hi all,
I tried to get FOTA working two times before, and I was about to give up a third time as I had always the same problems:
- After programming the MYSBootloader I loose the ability to do upload sketches via FTDI (with both pro-mini, nano's and barebones 328P)
- With MySController I could not upload any new FW, even a simple reboot command make the arduino to lock hard and it had to be powered down.
I tried the oficial github firmwares , the ones from GuilleBot I played with fuses, boards.txt, platformio.ini setting, different GWs, etc, etc, etc....
Last night I found this issue in github that gave me the detail that was missing. Just do not upload a sketch to the board, only program the MYSBootloader and wait until it asks the FW to the controller!
Another source of confusion, at least for me, was that I did not knew what to expect of the whole process. What where the different steps and the expected duration of the upload. I will try to describe my setup and how I could finally get it working.
MySetup
- Controller: HomeAssistant
- GW:MQTT GW using ESP8266
- Portainer from the HomeAssistan AddOns
- MQTT from the HomeAssistan AddOns (mosquitto)
- FW Controller - MYCONTROLLER.ORG using MQTT GW.
Follow this post instructions
I installed it with docker in the same machine as HA using Portainer and cdrocker's image
- Platformio.org for building sketches and programming bootloaders
Out of scope of this post, but way better than using Arduino. Totally worth the pain of learning it's basics.
- A MQTT Gui to see what is happening between the node and the controller
I'm using MQTT EXplorer
- An Arduino UNO as an ISP
- Sensors: A big mess of half working handmade boards, EasyPCB and SlimNode Sensors.
Steps
-
Get the correct MYSBootloader for your setup
Check GuilleBot repository if you are using another nfr24 channel or want to play with different radio power
-
Modify boards.txt or your platformio.ini to add the bootloader
In my case, for the nano:
[platformio]
default_envs = MYSBootloaderNano
[env]
platform = atmelavr
framework = arduino
upload_protocol = stk500v1
upload_port = /dev/ttyACM0
upload_speed = 19200
upload_flags =
-v
-e
-P$UPLOAD_PORT
-b$UPLOAD_SPEED
lib_deps =
MySensors
MySensors NodeManager
[env:MYSBootloaderNano]
board = nanoatmega328new
board_bootloader.file = bootloader/MYSBootloader_16MHz.hex
The important bits, the upload_flags specially the -e to erase the memory and the board_bootloader.file
- Program only the bootloader (and the fuses if necessary), for platformio:
$ platformio -f -c vim run --target bootloader
- Build the FW of your node, and copy the .hex somewhere on your PC. Again for platformio:
$ platformio -f -c vim run --target run
Look in .pio/build/<board>/
-
Add the FW to MyController.org following the product manual
-
Build your HW if needed, plug the radio, etc
-
Be sure to keep the MQTT Explorer and MyController.org to see some feedback of the whole process
-
Powerup the sensor
-
You will see a new node with ID 1 in MyController.org, if you look in "Status -> Resources logs" or in the MQTT Explorer you should see the node asking for a new FW.
-
In MyController.org assign the FW to the new node with ID 1 and upload it.
Check the manual if in doubt.
-
You will see in MQTT Explorer that the controller and the node get very chatty. The node will ask for each piece of the HEX in small batches.
-
You have some time now, get up and make yourself a cup of coffee and prepare a small celebration.
-
Check the MQTT Explorer, the FW is still uploading... go and get some confetti.
-
Check Mycontroller.org or HomeAssitant, the FW is uploaded and a new node just popup!
Enjoy!