Skip to content
MQTT based bed sensor with remote tare function.
C++ C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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.

Full guide available here




  • HX711 library - available through Arduino IDE library manager
  • PubSubClient library - available through Arduino IDE library manager
  • ESP boards

Use case

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.


  1. Load calibration sketch and ensure no additional weight is on the bed/scale
  2. Using serial monitor, observe starting measurements
  3. Place known weight on bed/scale e.g 5kg and observe new measurements printed on monitor
  4. Adjust calibration factor variable and repeat steps till values are correct. Take note of calibration factor

Bed sensor

  1. Load sketch, ensure no additional weight is on the scales
  2. Fill in all variables in config.h file
  3. Observe output on serial monitor, place known weight on scales and ensure read-out is correct.
  4. Once happy, unplug and plug into main power supply and enjoy!


The original idea for this has been adapted from Zack over at Self Hosted Home's original build, so big thanks to him!

You can’t perform that action at this time.