Home IoT Hub Series · 18

[Part 18] Is the dog bowl empty? HX711 food-remaining measurement node

Use an HX711 load cell to estimate remaining pet food in a bowl.

This node measures remaining pet food using an HX711 load cell. It is a good example of converting a physical weight into a hub slot.

Mechanical mounting matters more than code here. The bowl platform must press the load cell consistently without rubbing the frame.

[Part 18] Is the dog bowl empty? HX711 food-remaining measurement node hero image
System architecture and data pipeline note
This article is part of the Home IoT Hub system connected to the central NodeMCU server built in Part 2: Building the Brain. The HX711 load-cell node reports remaining food weight and connects low-food state to hub alerts. The collected data is sent over the local IoT_Hub_Net network and updates slot 20 for pet bowl weight on the central server (/set?no20=value), becoming part of the decision pipeline for the 20-channel smart-home controller.

Parts and cost

PartQtyUnit price
Wemos D1 Mini1 pc$1.50
HX711 + load cell(5kg) set1 set$2.20
Jumper wires 4 pc
Total$3.60

Pin wiring

[Part 18] Is the dog bowl empty? HX711 food-remaining measurement node wiring diagram
Sensor / moduleBoard pin
VCC3.3V
GNDGND
DTD1 (GPIO5)
SCKD2 (GPIO4)

Full code

[Part 18] Is the dog bowl empty? HX711 food-remaining measurement node - Code 2
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <HX711.h>

const char* ssid     = "IoT_Hub_Net";
const char* password = "iothub1234";
const char* hubURL   = "http://192.168.1.1";

#define DOUT  5    // D1
#define CLK   4    // D2
#define SLOT_NO      20
#define THRESHOLD    50   // 50 g or less means warning
#define INTERVAL     10000

HX711 scale;

void setup() {
  Serial.begin(115200);
  scale.begin(DOUT, CLK);
  scale.set_scale(2280.f); // calibration factor, adjust after measurement
  scale.tare();             // tare current weight to zero

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to IoT_Hub_Net");
  while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
  Serial.println("\nConnected!");
  Serial.println("Pet Bowl ready. Tare done.");
}

void loop() {
  float weight = scale.get_units(5); // 5note
  if (weight < 0) weight = 0;

  Serial.print("Pet Bowl: "); Serial.print(weight, 0);
  Serial.print(" g");
  if (weight < THRESHOLD) Serial.print("  REFILL!");
  Serial.println();

  WiFiClient client; HTTPClient http;
  String url = String(hubURL) + "/set?no"
             + String(SLOT_NO) + "=" + String((int)weight);
  http.begin(client, url);
  int code = http.GET(); http.end();
  Serial.print("HTTP "); Serial.print(code);
  Serial.print(" -> "); Serial.println(url);
  Serial.println();

  delay(INTERVAL);
}

Upload and check

Connect the Wemos D1 Mini to the PC with a USB data cable, select the ESP8266 board and port in the Arduino IDE, upload the sketch, then open Tools → Serial Monitor and set the baud rate to 115200.

Serial Monitor

After uploading, open Tools → Serial Monitor in the Arduino IDE and set the baud rate to 115200. The following is an example Serial Monitor flow for checking normal operation. This is not a real screenshot. It shows load-cell calibration, stable-window filtering, and slot 20 updates.

[BOOT] Home IoT Node #18 - Pet bowl load cell
[CAL] HX711 tare=complete, scale=2280.0
[SENSOR] raw_weight=164.2g stable_window=10
[FILTER] eating_motion=NO, outlier=PASS
[HTTP] GET /set?no20=164.2
[HUB] 200 OK - slot no20 updated
[LOOP] send only when stable for 5 minutes
  • If Connected or connected appears, the Wi-Fi step passed.
  • If HTTP 200 or 200 OK appears, the value reached the brain server.
  • If the value does not update, check both the slot number in the URL and the sensor wiring.

Build notes

  • Calibrate with a known weight, then put the bowl on the platform and check whether the value changes smoothly.
  • Power on the hub brain first so the node can join IoT_Hub_Net.
  • Use the same slot number written in the source code.
  • Open the serial monitor at 115200 baud and confirm HTTP 200.
  • If the value does not appear on the hub, recheck wiring, GPIO number, and Wi-Fi connection.

Using and Installing a Pet Bowl Weight Sensor

Placing an HX711 and load cell under your dog's bowl turns it into more than a 'refill me' alert; it becomes a small guardian of your pet's health. Here we focus not on wiring or code, but on how to use it and where to install it.

Troubleshooting checkpoints

The node code can look short, but real home installation is affected by placement, power, Wi-Fi quality, and sensor noise. Check these points before letting the node become a decision input for the brain server.

SymptomLikely causeField fix
Values jump while the dog is eatingLicking and pushing the bowl creates impact and vibrationTreat changes above 50 g/s as eating activity and send only the average after 5 minutes of stability.
An empty bowl is not 0 gLoad-cell zero drifts with temperature and mounting stressRun no-load tare at boot, add periodic tare if safe, and clamp negative values to zero.
Weight changes depending on bowl positionThe platform does not transfer force evenly to the load cellUse a rigid top plate and adjust spacers so the load is applied in the intended measurement direction.
Values spike during Wi-Fi transmissionHX711 microvolt signals are affected by power and board noiseKeep signal wires short, measure after power stabilizes, and separate sampling from HTTP transmission timing.

Practical Uses

  • Food-level alerts: When the weight drops below 50g, the hub signals 'refill needed', so you never miss an empty bowl while out.
  • Intake and appetite monitoring: Logging the difference between the day's starting and ending weight gives a graph of actual consumption. A sudden drop can be an early sign of illness or stress, helping you decide when a vet visit is warranted.
  • Multi-pet feeding management: A sensor per bowl reveals who eats how much, making it easier to manage obesity or picky eating.
  • Auto-feeder integration: When weight falls below a threshold, the hub can tell the feeder to dispense once, creating a closed-loop automatic feeding cycle.

Recommended Placement

  • Flat, firm floor: Carpets and mats spread the load and make readings jump. Tile or a rigid board is best.
  • Center the load: Keep the bowl's weight over the load cell's center to reduce error.
  • Avoid vibration sources (washers, entryways) and walkways where the bowl gets kicked.
  • Water-bowl use: The same setup can sense water level for a 'refill water' alert.

Field Tips and Cautions

  • Tare: Zero the scale with the empty bowl in place; the bowl's weight cancels out and you read only the food.
  • Calibration: Set the scale factor with known weights like 100g or 200g for accurate grams.
  • Temperature drift: Near windows or floor heating, readings slowly wander; choose a temperature-stable spot.
  • 4-wire load cell colors: Usually red (E+), black (E-), green/white (A+/-). If colors differ, check the datasheet.
  • Impact handling: When a dog nudges or noses the bowl, values spike momentarily. Averaging several readings cuts false alarms.

FAQ

Q. Do I reconfigure when I change bowls? Different bowls weigh differently, so just re-tare. Keep the same calibration factor.

Q. Readings keep drifting slightly. That's temperature drift or floor wobble. A stable location and averaging fix it.

Q. Is a damp area okay? Load cell contacts and the HX711 dislike water, so use a waterproof case and keep distance from the water bowl.