MQTT Bed Sensor/Scales for bed occupancy (although entirely adaptable for anything), for integrating with Home Assistant, OpenHAB, Domoticz and anything else supporting MQTT.
Has remote tare function which you can issue over MQTT if your sensor suffers from drift which many load cells seem to. This saves having to re-start the device everytime you want to tare. You can also remotely adjust the calibration factor and reboot the device via MQTT. The firmware offers a web interface for configuration as well.
Full guide available here
- HX711 Amplifier
- Load Cells
- ESP8266 based board with 5v output (Wemos D1 Mini etc)
- HX711 library - available through Arduino IDE library manager
- PubSubClient library - available through Arduino IDE library manager
- ESP boards
- LittleFS library - available through Arduino IDE library manager. Make sure to select the ESP8266 library, not the ESP32.
- WiFiWebServer library - available through Arduino IDE library manager
- ArduinoJSON library - available through Arduino IDE library manager
- ESP8266 LittleFS Data Upload - Follow the installation instructions on this page, then restart your Arduino IDE.
This was built specifically with bed occupancy in mind so that automations can be triggered when in bed such as switching lights off, locking doors, setting alarms etc etc using Home Assistant. I found that load cells seem to "drift" a little over time, with this in mind a remote tare function was built in so that I can issue a tare command over MQTT which will reset it to zero without having to physically reset the device everytime.
- Load sketch to the device
- Load the required files to the device by clicking the "ESP8266 LittleFS Data Upload" option in the "Tools" menu
- Without a valid WiFi configuration, the device will go into access point mode automatically. Connect to WiFi "MQTT_Scale" with password "scalemqtt"
- In a web browser, go to the address http://192.168.4.1
- Fill in the WiFi information and MQTT server connection information, enter the base MQTT topic to use for the device, enter a device ID (will be used as device_id in Home Assistant) and a name (will appear in Home Assistant), then save.
- The device will reconnect to the WiFi. If it can't connect, it will return to access point mode. Repeat steps 3-5 to fix WiFi configuration.
- Once connected to the WiFi, if the device can connect to the MQTT server, it will automatically publish auto-discovery topics, which will be picked up by Home Assistant. Otherwise, find the device's IP address in your router and connect to that IP address in your web browser to adjust the MQTT configurations.
- In the Home Assistant configuration, under "Devices & Services", find your MQTT integration, and click "devices". You should see a new device with the name you entered in the device configuration page.
- Clicking on the device will show all sensors and MQTT configuration options.
- Ensure no additional weight is on the scale.
- In Home Assistant, go to the device page
- Press the "Tare scale" button. After a few seconds, the "Weight" value should go to 0kg
- Place a known weight on scales.
- Adjust the "Calibration factor" field until the "Weight" value displays the weight of the object placed on the scale.
- Remove the weight. The weight shown should return back to zero.
Join the community on discord:
If you would like to support this project and many more like it, please consider supporting me so I can keep delivering more projects just like this one:
The original idea for this has been adapted from Zack over at Self Hosted Home's original build, so big thanks to him!