how_to:mysensors:firmware_upload_pc

Upload a firmware to the node with your PC and PlatformIO

PlatformIO is an IDE that allows you to create, compile and upload the firmware to several IOT devices like the Arduino and the ESP boards.

It offers similar functionalities to the Arduino IDE, but has some advantages, like the automatic library download and management, so this is why all the firmware of the d-diot project are distributed as PlatformIO projects.

If you are running a d-diot image above v.1.2, PlatformIO is already installed according to this wiki page and you can follow this guide to upload the firmware to your devices using the d-diot hub and command line interfaces (CLI).

If you have the d-diot hub v.3.0, you need a separate machine running PlatformIO to upload and compile the firmware of you devices, so in this wiki page we will cover this case.

According to the PlatoformIO home page the reommended way to run PlatformIO is inside VScode which is an editor that can run on different operating system, so the first step is to install VSCode into your machine.

Once VSCode is installed the next step is to install the PlatformIO extension according to this simple guide.

With VSCode and PlatformIO up and running the upload of a d-diot firmware is quite easy:

  1. Download the firmware as PlatformIO project from the d-diot github repo.
  2. Open the downloaded PlatformIO project in VSCode
  3. Click the right arrow (→) in the bottom left corner to compile and upload the firmware

To download a PlatformIO project from the d-diot repo you can use the “git clone” command in the terminal followed by the URL of the repo like in the example below (mainmcu repo):

user@host:~ $ git clone https://github.com/d-diot/mainmcu

or you can use the “git clone” command in the “Command Palette”, accessible from View → Command Palette or with the keyboard shortcut Ctrl+Maiusc+P, of VSCode.

Each PlatformIO project contains a configuration platformio.ini file, like the one in the example below (BT-Pcb-328P-firmware)

platformio.ini
;PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
 
[platformio]
default_envs = MySpro1MHzatmega328
;default_envs = MySpro8MHzatmega328
;default_envs = pro8MHzatmega328
 
[extra]
lib_deps =
    MySensors@>=2.3.1
monitor_speed = 9600
 
 
[env:pro8MHzatmega328]
platform = atmelavr
board = pro8MHzatmega328
framework = arduino
lib_deps =
    ${extra.lib_deps}
monitor_speed = ${extra.monitor_speed}
 
 
[env:MySpro8MHzatmega328]
platform = atmelavr
board = MySpro8MHzatmega328
framework = arduino
lib_deps =
   ${extra.lib_deps}
monitor_speed = ${extra.monitor_speed}
 
[env:MySpro1MHzatmega328]
platform = atmelavr
board = MySpro1MHzatmega328
framework = arduino
lib_deps =
   ${extra.lib_deps}
monitor_speed = ${extra.monitor_speed}

Before compiling and uploading the firmware, uncomment in the [platformio] section the default environment corresponding to your target board and leave the other entries commented out with a “;” symbol at the beginning of the line.

  • how_to/mysensors/firmware_upload_pc.txt
  • Last modified: 2021/02/21 04:26
  • by franzunix