diff --git a/node-wifi-mqtt/Makefile b/node-wifi-mqtt/Makefile index d494c56..a44f01d 100644 --- a/node-wifi-mqtt/Makefile +++ b/node-wifi-mqtt/Makefile @@ -1,35 +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)/ESP8266WiFi \ - $(ESP_LIBS)/ESP8266HTTPClient \ - ../libraries/SerialDebugger/*.h \ - ../libraries/SerialDebugger/*.cpp \ - ../libraries/Adafruit_MQTT_Library/*.h \ - ../libraries/Adafruit_MQTT_Library/*.cpp \ - ../libraries/ArduinoJson/include \ - ../libraries/OneWire \ - ../libraries/DallasTemperature \ - ../libraries/RobTillaart-Arduino/libraries/DHTstable \ - ../libraries/RobTillaart-Arduino/libraries/RunningMedian \ - ../libraries/HX711 \ - ../libraries/ADS1231 +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 diff --git a/node-wifi-mqtt/README.rst b/node-wifi-mqtt/README.rst index 681dfb7..553c10d 100644 --- a/node-wifi-mqtt/README.rst +++ b/node-wifi-mqtt/README.rst @@ -21,6 +21,7 @@ Basic WiFi/MQTT sensor node ************ Introduction ************ + A beehive monitoring sensor node based on the `Adafruit Feather HUZZAH`_, featuring an ESP8266_ MCU. Telemetry data is transmitted using WiFi/MQTT. The most recent firmware version is available at `node-wifi-mqtt.ino`_. @@ -105,33 +106,20 @@ Configure WiFi and MQTT settings:: Build ===== -The build system is based on `makeESPArduino`_, a Makefile for ESP8286 Arduino projects. - -Setup SDK:: - mkdir ~/sdk; cd ~/sdk - git clone https://github.com/esp8266/Arduino esp8266-arduino - - # Download appropriate Espressif SDK - cd esp8266-arduino/tools - ./get.py +The build system is based on PlatformIO_. Build firmware:: - # Announce path to SDK - export ESP_ROOT=~/sdk/esp8266-arduino - - # Run Makefile make -Enable more verbose output:: - - export VERBOSE=true - Upload to MCU ============= :: + export MCU_PORT=/dev/ttyUSB0 make upload + +.. _PlatformIO: https://platformio.org/ diff --git a/node-wifi-mqtt/node-wifi-mqtt.ino b/node-wifi-mqtt/node-wifi-mqtt.ino index f0125e3..afa34e4 100644 --- a/node-wifi-mqtt/node-wifi-mqtt.ino +++ b/node-wifi-mqtt/node-wifi-mqtt.ino @@ -29,7 +29,8 @@ Add comment about connecting GPIO#16 to RST for waking up after deep sleep. Thanks, Giuseppe and Matthias! Add sensor ADS1231. Thanks, Clemens! Silence debug output by using SerialDebugger to reduce battery drain even more. - 2021-05-02 Use SerialDebug library by Joao Lopes. + 2021-05-02 Modernize code by using the SerialDebug library by Joao Lopes and + add build environment based on PlatformIO. GNU GPL v3 License diff --git a/node-wifi-mqtt/platformio.ini b/node-wifi-mqtt/platformio.ini new file mode 100644 index 0000000..34aef69 --- /dev/null +++ b/node-wifi-mqtt/platformio.ini @@ -0,0 +1,30 @@ +; 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:huzzah] +platform = espressif8266 +board = huzzah +framework = arduino + +monitor_speed = 115200 + +lib_deps = + joaolopesf/SerialDebug@^0.9.82 + OneWire@2.3.5 + HX711@0.7.4 + DallasTemperature@3.8.1 + robtillaart/DHTStable@^0.2.9 + ../libraries/ADS1231 + RunningMedian@0.1.15 + ArduinoJson@^5 + https://github.com/daq-tools/Adafruit_MQTT_Library#maxbuffersize-2048