ECHOcommunity Conversations


EDN 155 featured an article on microcontrollers as a low-cost approach to automating the monitoring environmental conditions such as temperature, humidity, rainfall, and soil moisture. It was beyond the scope of the article to give detailed instructions for the various projects alluded to in the article. Programming and wiring details for various microcontroller devices are being added to Github. Additionally, this Conversations thread is a place where you can ask questions. We are still learning ourselves but will do our best to provide advice.

I’ve been following a similar trajectory to Tim for the last two years with regards to the use of microcontrollers for data gathering and farm automation. I started with simple programmable timers and pre-packaged wifi relays, and eventually discovered a well-developed alternate firmware that takes much of the work out of programming the microcontrollers, and easily integrates into wifi networks.

The firmware is called Tasmota, and is an Arduino-based software for ESP8266/ESP8285 and ESP32 microcontrollers. ESP8266 is a 160mhz wifi capable microcontroller that has 10 digital and 1 analog inputs/outputs, that can control relays, lights, motors, MOSFETs, read voltage, communicate on serial buses like I2C and SPI, and more. It costs around $2 for a development board. The Tasmota community is very active and drivers exist for all kinds of sensors (temperature, humidity, time-of-flight, air quality, pressure, light, UV, CO2, pH). Those sensors are available for very low cost ($1-$5).

ESP32 is more powerful (240mhz), and costs around $4, but has more digital and analog inputs/outputs.

I have ESP8266 modules controlling bore-hole pumps (they can even read and pass-through serial data from motor controllers), with attached manual switches, so pumps can be turned on and off in-person or remotely.

I have modules controlling solar battery charging and reading individual lithium cells (although dedicated BMS balancing boards are easier)

I have modules reading temperature, humidity, and rainfall and that data is logged to an SD card.

I’m monitoring and logging energy usage of some freezers using a ESP8266 module plus a AC power meter board ($6)

ESP8266 and ESP32 both use significantly more energy than a simpler Arduino board, mostly due to wifi, so trying to run these using batteries is challenging. The firmware works best when it can connect to wifi (and send/receive data to/from various servers), but low-power options exist, so modules can run for weeks at a time on a 18650 lithium cell, and indefinitely in conjunction with a small solar panel. In general though, they are suited for environments where 24/7 power is available.

Centralized data collection from all the modules is helpful, and I am using a $15 Raspberry Pi Zero 2 W to run the services that the ESP8266 needs for that. The Zero 2 W can easily handle Node-Red (automation flow-chart software), Syslog (error and debugging logging), InfluxDB (time-series database for sensor logging), Grafana (graphing of time-series data), MQTT (low-overhead messaging protocol for communicating with wifi things), GPS (for accurate time-keeping in the absence of internet), NTP (distributing accurate time to everything else on the network).

Grafana and InfluxDB let me collect the sensor data from the ESP8266 modules and visualize it easily. Can also monitor switch state to see at a glance which things are on or off.