ESP8266 beehive scale based on Homie


Tip

You might want to read this document on our documentation space, all inline links will be working there.

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.

Open Hive ESP8266 BeeScale

Platform and supported peripherals

  • AI-THINKER ESP8266-07 module with an ESP8266 MCU
  • HX711 ADC weigh scale breakout board
  • DS18B20 digital thermometer

Note

There’s also an alternative firmware Battery-powered ESP8266 beehive scale based on Homie.

PCB

The PCB can be downloaded in Fritzing format from ESP8266-BeeScale.fzz.

ESP8266 BeeScale PCB - schematics - top view

PCB - Schematics Top view


ESP8266 BeeScale PCB - top view

PCB - Top view.


ESP8266 BeeScale PCB - bottom view

PCB - Bottom view.

Firmware

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

Configure

Have a look at the source code node-wifi-mqtt-homie.ino and adapt setting variables according to your environment.

Configure load cell calibration settings:

// Use sketch BeeScale-Calibration to get these values
const float offset = 85107.00;    // Offset load cell
const float cell_divider = 22.27; // Load cell divider

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

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

make upload

Configuration

The Homie firmware offers different ways of runtime configuration.

HTTP API

When starting the ESP8266 device with Homie firmware, it will come up in configuration mode and spawn a secure WiFi access point named Homie-xxxxxxxxxxxx, like Homie-c631f278df44. Connect to it.

Configure the device by uploading the JSON configuration file to the HTTP JSON API at http://192.168.1.1:

# 1. Clone real configuration from blueprint
cp example.config.json config.json

# 2. Edit configuration file
sublime config.json

# 3. Configure device
curl -X PUT http://192.168.1.1/config --header "Content-Type: application/json" -d @config.json

SPIFFS

The configuration file config.json can also be uploaded to the device’s SPIFFS filesystem as /homie/config.json.

makeESPArduino also has the upload_fs target, so:

# 1. Clone real configuration from blueprint
cp example.config.json data/homie/config.json

# 2. Edit configuration file
sublime data/homie/config.json

# 3. Configure device
make upload_fs

User interface

When installing the UI bundleui_bundle.gz”, the configuration UI will be served directly from the device:

# 1. Download ui_bundle.gz
wget --directory-prefix=data/homie http://setup.homie-esp8266.marvinroger.fr/ui_bundle.gz

# 2. Configure device
make upload_fs

Todo

  • Improve documentation at all
  • Document how to determine calibration values (i.e. “Use sketch BeeScale-Calibration to get these values”). Would it be possible to build it into the main firmware and run it conditionally somehow?
  • Document how to determine scale’s temperature compensation values.