A small Node Exporter to serve Sensor data from a D1 Mini Board or a ESP8266-01 Board to a Prometheus instance.
Clone this Repository:
git clone https://github.com/vaddi/d1mini_node.git
Or just copy the plain Text from this Files into you Adruino IDE Editor (Remember to choose the right Board!) and flash your Device:
Pinout for the D1 Mini
There is also a svg Version available.
- Silent Mode, disable LED blink
- Use Sensors by simple enable/disable them into the webgui/code (you still have to plug them ;)
- Initial Setup via Wifi Access Point with Captive Portal
- DHCP Client or Static IP Modes
- SecPush, Disable all auth for given seconds after booting the device
- Prometheus ready /metrics Endpoint
- Enable Disable Authentification from Webgui (basic auth & token based auth)
Open the d1mini_node.ino
File into an Arduino IDE.
- Set Board:
tools
->Board
->LOLIN(WEMOS) D1 R2 & mini
- Set Port:
/dev/cu.wchusbserialXXXX
* - Compile and Upload the Sketc
- Place Device to desired destination.
- Plugin all Sensors (Pinout in head of *.ino File)
- Start the Device, it will run now in Setupmode (On Start the LED blinks 3 times). Just grab a Computer/Phone and connect to the Wifi named
esp_setup
. - After connected, a Captive Page should open in a Browser in wich you can setup the Device by set SSID, Wifi Password, Hostname (DNS Name).
- After Submit the Device will do a Reboot and should then connected as Client into the desired Wifi Network.
- Now open the Device Page in a browser and setup other Stuff like connected Sensors and Security settings.
* Device Path For example, depend on your System and can has another path
- MQ135 Air Quality sensor
- DS18B20 Temperatur Sensors
- BME280 Air Temperature, Humidity and Pressure Sensor
- MightyOhm Geigercounter
- MCP 300X ADC Device for 8 Analog Sensorvalues
- There is only one ADC Pin (A0) available which will be used for Voltage detection by default. When using an MQ135 this Pin is used by the Sensor so accurate Voltage messuring will be disabled!
- This code is not perfect, but fits for my needs. Feel free to improve them.
Using a DHT Sensorboard (DHT-Board) or just add a Plain DHT Sensor to an ESP8266-01. I've soldering a DHT22 instead of a DHT11 onto my Boards to get more accuracy.
Open the esp8266-01_node.ino
File into an Arduino IDE.
- Configure DHT11 or DHT22 Sensor in File!
- Set Board:
tools
->Board
->Generic ESP8266 Module
- Set Port:
/dev/cu.wchusbserial1420
* - Compile and Upload the Sketch
- Place Device to desired destination.
- Plugin all Sensors (Pinout for DHT11 & DHT22 in *.ino File)
- Start the Device, it will run now in Setupmode (On Start the LED blinks 3 times). Just grab a Computer/Phone and connect to the Wifi named
esp_setup
. - After connected, a Captive Page should open in a Browser in wich you can setup the Device by set SSID, Wifi Password, Hostname (DNS Name).
- After Submit the Device will do a Reboot and should then connected as Client into the desired Wifi Network.
* Device Path For example, depend on your System and can has another path
Open a Webbrowser and try to connect to your Node:
http://esp01.speedport.ip/
Navigate through the Page, checkout the Metrics or Save some Settings.
When no connection to the Node come up:
- Try to connect to the IP instead of DNS Name to reach the Device.
- See in your Router DNS Table to get sure the Node will get an IP Adress.
- Try to disable Silent Mode to ensure the Node will connect to the Wifi and doesnt run in Setup Mode (LED blinks 3 times). The Device will blink if a client connecting to the wifi and when processing a request.
- Check Pins, make sure there are no shortcuits or other pin missplacements.
- On D1mini Boards you can enable
debug
and plugin via USB. Then read the Debug output by Arduino IDE Serial or via Terminal byscreen /dev/ttyUSB1 9600
.
If failed to connect to the Wifi, the LED will blink continuosly. Change the Compile settings to also clear the EEPROM (tools
-> Erease Flash
-> All Flash Contents
) and try again. The Device will start in AC Mode, so you can run the setup again.
If the BME280 Sensor dont show any Data:
- Checkout th Example from the Menu
File
->Examples
->Adafruit BME280 Library
->bme280_unified
Sketch. - If continuesly printed
Could not find a valid BME280 sensor, check wiring
, you have to check the used Adress inside the Library!
Open the file libraries/Adafruit_BME280_Library/Adafruit_BME280.h
and change the used Adress around Line 33 from:
#define BME280_ADDRESS (0x77)
to
#define BME280_ADDRESS (0x76)
The alternative BME280_ADDRESS_ALTERNATE
doesn´t seem to work so properly on the Library.
Just add your device as a Target to your prometheus.yml
File. I've using here a Network which searchdomain speedport.ip
, just change to your Network or use IPs instead of DNS Names. Here is an Example job:
...
- job_name: 'esps'
# metrics_path: '/metrics'
# scrape_interval: 5m
# scrape_timeout: 1m
# basic_auth:
# username: 'XXXXX'
# password: 'XXXXX'
# params:
# apikey: ['XXXXXXXXXX']
static_configs:
- targets: ['esp01.speedport.ip:80'],
- targets: ['esp02.speedport.ip:80'],
- targets: ['esp03.speedport.ip:80']
...
I've created some Dashboards, maybe there helpfull when begin to build some own Dashboards.
- ESP Full Dashboard: dashboard
- Dashboard Example: dashboard-example
The Webinterface:
Screenshot from the Setuppage. here you can configure you Device.
ESP Full Dashboard:
A Dashboard witch has all Metrics available. So you have to just enable a Sensor on your ESP Device to see the Sensordata. The Sensors present will get their Value by they're scrape time.
A Dashboard Example:
A Dashboard wich combines some Metrics to get a complete Overview over you flat or other Places. Just place some Sensors and feel free to combine or calc average from them.
Devices and Cases:
Some Basic Devices, only Temperature, Humidity and with the bme280 Sensor also Pressure. Beside the printed Cases (see links below).
Bathroom Device:
A Node which get Metrics from my Bathroom. Here also with a printed case and a MQ135 behind.
There are some More, just take a look into the assets/images Folder.
Some Ideas which i want to implement in the future.
- Parsing more values from mcp to flatten the output Data
- transport layer security (tls) support to use https
- Two Pins left for more Sensors or other Stuff
- mq135
- bme280
- ds18b20
- Analog Sensors which can connected to the MCP3008 ADC
- moisture
- ph-node
- brightness-meter
- Find a lot more Sensors on google and amazon. Mostly any kind of analoge Sensor should run.
- DHT-Board. You can de-soldering the sensor to a dht22.
- Geigercounter