Skip to content

Commit

Permalink
Add PlatformIO build environment to all Homie-based firmwares
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed May 3, 2021
1 parent cbaa892 commit 3944a10
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 77 deletions.
15 changes: 15 additions & 0 deletions node-wifi-mqtt-homie-battery/Makefile
@@ -0,0 +1,15 @@
$(eval venvpath := .venv)
$(eval python := $(venvpath)/bin/python)
$(eval pip := $(venvpath)/bin/pip)
$(eval pio := $(venvpath)/bin/pio)


build: setup-virtualenv
$(pio) run

upload: setup-virtualenv
$(pio) run --target upload --upload-port=${MCU_PORT}

setup-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=python3 $(venvpath)
$(pip) install platformio
26 changes: 26 additions & 0 deletions node-wifi-mqtt-homie-battery/platformio.ini
@@ -0,0 +1,26 @@
; 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]
src_dir = .

[env:esp07]
platform = espressif8266
board = esp07
framework = arduino

monitor_speed = 115200

lib_deps =
marvinroger/Homie@^2
paulstoffregen/OneWire@^2.3.5
bogde/HX711@^0.7.4
milesburton/DallasTemperature@^3.9.1
robtillaart/RunningMedian@^0.3.3
15 changes: 15 additions & 0 deletions node-wifi-mqtt-homie-calibration/Makefile
@@ -0,0 +1,15 @@
$(eval venvpath := .venv)
$(eval python := $(venvpath)/bin/python)
$(eval pip := $(venvpath)/bin/pip)
$(eval pio := $(venvpath)/bin/pio)


build: setup-virtualenv
$(pio) run

upload: setup-virtualenv
$(pio) run --target upload --upload-port=${MCU_PORT}

setup-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=python3 $(venvpath)
$(pip) install platformio
26 changes: 26 additions & 0 deletions node-wifi-mqtt-homie-calibration/platformio.ini
@@ -0,0 +1,26 @@
; 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]
src_dir = .

[env:esp07]
platform = espressif8266
board = esp07
framework = arduino

monitor_speed = 115200

lib_deps =
marvinroger/Homie@^2
paulstoffregen/OneWire@^2.3.5
bogde/HX711@^0.7.4
milesburton/DallasTemperature@^3.9.1
robtillaart/RunningMedian@^0.3.3
44 changes: 11 additions & 33 deletions node-wifi-mqtt-homie/Makefile
@@ -1,37 +1,15 @@
# makeEspArduino: A makefile for ESP8266/Arduino projects.
# https://github.com/plerup/makeEspArduino
$(eval venvpath := .venv)
$(eval python := $(venvpath)/bin/python)
$(eval pip := $(venvpath)/bin/pip)
$(eval pio := $(venvpath)/bin/pio)

# Announce path to your "ESP8266 Arduino Core" installation
# Can also be announced via environment variable: export ESP_ROOT=...
# ESP_ROOT=~/sdk/esp8266-arduino

# Manually enumerate libraries, this is currently the only deterministic way.
LIBS = \
$(ESP_LIBS)/esp8266 \
$(ESP_LIBS)/GDBStub \
$(ESP_LIBS)/SD \
$(ESP_LIBS)/SPI \
$(ESP_LIBS)/Wire \
$(ESP_LIBS)/Ticker \
$(ESP_LIBS)/ESP8266WiFi \
$(ESP_LIBS)/ESP8266mDNS \
$(ESP_LIBS)/ESP8266WebServer \
$(ESP_LIBS)/ESP8266HTTPClient \
$(ESP_LIBS)/DNSServer \
../libraries/homie-esp8266 \
../libraries/async-mqtt-client \
../libraries/ESPAsyncTCP \
../libraries/ArduinoJson/include \
../libraries/Bounce2 \
../libraries/OneWire \
../libraries/HX711 \
../libraries/DallasTemperature \
../libraries/RobTillaart-Arduino/libraries/RunningMedian \
build: setup-virtualenv
$(pio) run

# Run makeEspArduino
include ../tools/makeEspArduino/makeEspArduino.mk
upload: setup-virtualenv
$(pio) run --target upload --upload-port=${MCU_PORT}

### FWBUILDER_DIR
### Include helpers from Firmware-Builder directory.
FWBUILDER_DIR = ../tools/Firmware-Builder
include $(FWBUILDER_DIR)/Helper.mk
setup-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=python3 $(venvpath)
$(pip) install platformio
68 changes: 29 additions & 39 deletions node-wifi-mqtt-homie/README.rst
Expand Up @@ -21,8 +21,10 @@ ESP8266 beehive scale based on Homie
************
Introduction
************

A beehive monitoring sensor node based on a ESP8266 module and a custom made PCB.
Telemetry data is transmitted using WiFi/MQTT.

The standard firmware is based on the `ESP8266 framework for Homie`_,
its most recent version is available at `node-wifi-mqtt-homie.ino`_.
However, the PCB (`ESP8266-BeeScale.fzz`_) can be used with any firmware.
Expand Down Expand Up @@ -77,25 +79,10 @@ The PCB can be downloaded in Fritzing format from `ESP8266-BeeScale.fzz`_.
PCB - Bottom view.


********
Firmware
********
.. highlight:: bash


Clone git repository
====================
::

# Get hold of the source code repository including all dependencies
git clone --recursive https://github.com/hiveeyes/arduino

# Select this firmware
cd node-wifi-mqtt-homie

*************
Configuration
*************

Configure
=========
.. highlight:: c++

Have a look at the source code `node-wifi-mqtt-homie.ino`_ and adapt
Expand All @@ -108,45 +95,49 @@ Configure load cell calibration settings::
const float cell_divider = 22.27; // Load cell divider


Build
=====
The build system is based on `makeESPArduino`_, a Makefile for ESP8286 Arduino projects.

******************
Build instructions
******************

.. highlight:: bash

Setup SDK::
Clone git repository
====================
::

mkdir ~/sdk; cd ~/sdk
git clone https://github.com/esp8266/Arduino esp8266-arduino
# Get hold of the source code repository including all dependencies
git clone https://github.com/hiveeyes/arduino

# Download appropriate Espressif SDK
cd esp8266-arduino/tools
./get.py
# Select this firmware
cd node-wifi-mqtt-homie

Build firmware::

# Announce path to SDK
export ESP_ROOT=~/sdk/esp8266-arduino
Build
=====

# Run Makefile
make
The build system is based on PlatformIO_.

Enable more verbose output::
Build firmware::

export VERBOSE=true
make

After successfully building it, you will find firmware images at

- .pio/build/esp07/firmware.bin
- .pio/build/esp07/firmware.elf

Upload to MCU
=============
::

export MCU_PORT=/dev/ttyUSB0
make upload



*************
Configuration
*************
*********************
Runtime configuration
*********************
.. highlight:: bash

The Homie firmware offers different ways of runtime configuration.
Expand Down Expand Up @@ -228,4 +219,3 @@ Todo


.. _Homie custom settings: https://homie-esp8266.readme.io/docs/custom-settings

10 changes: 5 additions & 5 deletions node-wifi-mqtt-homie/node-wifi-mqtt-homie.ino
Expand Up @@ -24,11 +24,11 @@
Credits: Marvin Roger for the awesome Homie Framework: https://github.com/marvinroger/homie-esp8266
Used libraries:
HX711: https://github.com/bogde/HX711
RunningMedian: https://github.com/RobTillaart/Arduino/tree/master/libraries/RunningMedian
Homie-esp8266 v2.0.0: https://github.com/marvinroger/homie-esp8266
Bounce2: https://github.com/thomasfredericks/Bounce2
ESPAsyncTCP: https://github.com/me-no-dev/ESPAsyncTCP
HX711: https://github.com/bogde/HX711
RunningMedian: https://github.com/RobTillaart/Arduino/tree/master/libraries/RunningMedian
Homie-esp8266 v2.0.0: https://github.com/marvinroger/homie-esp8266
Bounce2: https://github.com/thomasfredericks/Bounce2
ESPAsyncTCP: https://github.com/me-no-dev/ESPAsyncTCP
async-mqtt-client: https://github.com/marvinroger/async-mqtt-client
**********************************************************************************************************/
Expand Down
26 changes: 26 additions & 0 deletions node-wifi-mqtt-homie/platformio.ini
@@ -0,0 +1,26 @@
; 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]
src_dir = .

[env:esp07]
platform = espressif8266
board = esp07
framework = arduino

monitor_speed = 115200

lib_deps =
marvinroger/Homie@^2
paulstoffregen/OneWire@^2.3.5
bogde/HX711@^0.7.4
milesburton/DallasTemperature@^3.9.1
robtillaart/RunningMedian@^0.3.3

0 comments on commit 3944a10

Please sign in to comment.