Skip to content

Commit

Permalink
node-esp8266-generic: Modernize build environment by adding PlatformIO
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed May 2, 2021
1 parent e71a8c1 commit ea6e222
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/source/firmware/node-esp8266-generic
5 changes: 5 additions & 0 deletions doc/source/resources.rst
Expand Up @@ -64,6 +64,8 @@
.. _node-wifi-mqtt-homie.ino: https://github.com/hiveeyes/arduino/blob/master/node-wifi-mqtt-homie/node-wifi-mqtt-homie.ino
.. _node-wifi-mqtt-homie-battery.ino: https://github.com/hiveeyes/arduino/blob/master/node-wifi-mqtt-homie-battery/node-wifi-mqtt-homie-battery.ino

.. ulmi
.. _node-esp8266-generic.ino: https://github.com/hiveeyes/arduino/blob/master/node-esp8266-generic/node-esp8266-generic.ino
.. Kotori
.. _Kotori: https://getkotori.org/docs/

Expand Down Expand Up @@ -167,6 +169,9 @@
.. _HttpRequester: https://addons.mozilla.org/en-us/firefox/addon/httprequester/


.. _PlatformIO: https://platformio.org/
.. _NodeMCU: https://en.wikipedia.org/wiki/NodeMCU


.. Clearfix in reStructuredText
.. https://stackoverflow.com/questions/23498174/clearfix-paragraph-in-restructured-text
Expand Down
15 changes: 15 additions & 0 deletions node-esp8266-generic/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
150 changes: 150 additions & 0 deletions node-esp8266-generic/README.rst
@@ -0,0 +1,150 @@
.. include:: ../../resources.rst

.. _node-esp8266-generic:

#######################
Bienenwaage 2.0 NodeMCU
#######################

.. contents::
:local:
:depth: 1

----

.. tip::

You might want to `read this document on our documentation space <https://hiveeyes.org/docs/arduino/firmware/node-esp8266-generic/README.html>`_,
all inline links will be working there.


*****
About
*****
A beehive monitor firmware for ESP8266.

:Author: Stefan Ulmer <ulmi [ät] gmx.de>

Details
=======

A beehive monitoring sensor node based on the NodeMCU_ hardware, featuring an ESP8266_ MCU.
Telemetry data is transmitted using MQTT over WiFi or GSM.
The most recent firmware version is available at `node-esp8266-generic.ino`_.


********
Features
********
- Equipped for NodeMCU_, but suitable to run on any ESP8266_ device
- Sensors: 2x Temperature via DS18B20_, 2x Weight via HX711_, Battery level via ADC
- GSM/GPRS via SIM800/TinyGSM
- WiFi via ESP8266
- Telemetry via MQTT


*************
Documentation
*************
- https://community.hiveeyes.org/t/inbetriebnahme-und-weiterentwicklung-der-firmware-fur-arduino-node-esp8266-generic-node-esp32-generic/3189


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

General
=======
In order to toggle different features and modes, please have a look
at the list of ``#define`` constants at the top of the sketch.

Weight scale
============
Adjust ``SCALE_DOUT_PIN_{A,B}``, ``SCALE_SCK_PIN_{A,B}``, ``Taragewicht_{A,B}`` and ``Skalierung_{A,B}``.
To find out about appropriate values for ``Taragewicht_X`` and ``Skalierung_X``,
please use a weight scale adjustment sketch like
https://github.com/hiveeyes/arduino/tree/master/scale-adjust/HX711.

::

// Scale settings
#define WEIGHT true
float Taragewicht_A = 226743;
float Skalierung_A = 41.647;
float Taragewicht_B = -238537
float Skalierung_B = -42.614;

Temperature sensors
===================
Adjust ``SENSOR_DS18B20``, ``DS18B20_PIN`` and the device addresses ``SensorX``.

More sensors
============
Adjust ``SENSOR_BATTERY_LEVEL``.

WiFi
====
To configure WiFi SSID and credentials, please use the captive portal
available on X.X.X.X when the device starts in AP mode.

GSM
===
To configure GSM/GPRS connectivity, please adjust the ``GSM_ENABLED``,
``apn[]``, ``user[]``, ``pass[]`` and ``simPIN[]`` variables.

MQTT
====
To configure MQTT telemetry, adjust the ``MQTT_BROKER``, ``MQTT_PORT``,
``MQTT_USERNAME``, ``MQTT_PASSWORD`` and ``MQTT_TOPIC`` variables.

Weather Underground
===================
To enable Weather Underground for getting nearby temperature and humidity
information, adjust ``WUG_API_KEY`` and ``WUG_STATION_ID``.


******************
Build instructions
******************
::

make

After successfully building it, you will find firmware images at

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


********
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-esp8266-generic


Build
=====

The build system is based on PlatformIO_.

Build firmware::

make

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

export MCU_PORT=/dev/ttyUSB0
make upload
12 changes: 8 additions & 4 deletions node-esp8266-generic/node-esp8266-generic.ino
Expand Up @@ -49,15 +49,16 @@ Shield Lila
//Version 1.19 Echtdaten werden an als node-2 geführt deshabl spielwiese/node-2/data.json, anstatt node-4 an den bisher zu testzwecken übermittelt wurde.
//Version 1.20 Version um Tippfehler bereinigt und für Upload auf GitHub vorbereitet
//Version 1.20 public - User / Login Credentials entfernt
//Version 1.21 Modernisierung und PlatformIO Build-Umgebung


#define GSM_ENABLED false // Bei FALSE wird automatisch WIFI aktiviert
#define WEIGHT true
#define SENSOR_DS18B20 false // Aktuell ohne Funktion, da zu wenig PINS zwangsweise false da ich pin D5 für die Waage benötige
#define SENSOR_BATTERY_LEVEL false // falls Spannungsmessung über Spannungsteiler erfolgen soll, wenn kein SIM800 Modul verwendet wird.
#define SENSOR_BATTERY_LEVEL false // Falls Spannungsmessung über Spannungsteiler erfolgen soll, wenn kein SIM800 Modul verwendet wird.
#define DEEPSLEEP_ENABLED true // Code ist aktuell nur auf TRUE ausgelegt, falls False, muß noch im main() ein Delay eingebaut werden.
#define SLEEP_TIMER true // SleepDauer abhängig vom Ladezustand, Sleep_Timer noch nicht mit Wifi verifziert.
#define WUNDERGROUND false //funktionert aktuell nur mit GSM_ENABLED false
#define SLEEP_TIMER true // Sleep-Dauer abhängig vom Ladezustand, Sleep_Timer noch nicht mit Wifi verifziert.
#define WUNDERGROUND false // Funktionert aktuell nur mit GSM_ENABLED false


#if GSM_ENABLED
Expand Down Expand Up @@ -639,10 +640,13 @@ void setup_tempsensor() {

Serial.println("Temperaturmessung mit dem DS18B20 ");

// Start Dallas Tempeartur Library / Instanz
// Start Dallas Temperature Library / Instanz
sensors.begin(); // DS18B20 starten

// Präzision auf 12 Bit
#ifndef TEMP_12_BIT
#define TEMP_12_BIT 0x7F // 12 bit
#endif
sensors.setResolution(TEMP_12_BIT);

//Anzahl Sensoren ausgeben
Expand Down
30 changes: 30 additions & 0 deletions node-esp8266-generic/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:nodemcu]
platform = espressif8266
board = nodemcuv2
framework = arduino

monitor_speed = 115200

lib_deps =
OneWire@2.3.5
HX711@0.7.4
DallasTemperature@3.8.1
RunningMedian@0.1.15
ArduinoJson@^5
https://github.com/daq-tools/Adafruit_MQTT_Library#maxbuffersize-2048
tzapu/WiFiManager@^0.16.0
vshymanskyy/TinyGSM@^0.10.9
tardate/TextFinder

0 comments on commit ea6e222

Please sign in to comment.