Hi there
may I introduce you to the revolutionary smart toilet paper counter
it is made from an IKEA box called KUGGIS, a loadcell and ESP8266. I made baseplate of 3mm acryl and glued the ESP8266, HX711 to the bottom of the box. the loadcell can accept up to 5kg and is attached with screws. the ESP8266 is powered by a USB power-adapter.
parts-lists
IKEA KUGGIS box
ESP8266 / Wemos D1 mini
HX711 load cell amplifier
loadcell 5kg bar type
code thanks to @Holdestmade who helped out with the code (Smart toiletpaper holder - with illumination - #6 by Holdestmade)
esphome:
name: "rollcounter"
esp8266:
framework:
version: 2.7.4
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "your-key"
ota:
password: "your-password"
wifi:
ssid: 'your-wifi'
password: 'your-password'
sensor:
- platform: hx711
name: "Rollcounter Value"
dout_pin: D1
clk_pin: D2
gain: 128
id: rollcounter_value
update_interval: 2s
filters:
- calibrate_linear:
- 203000 -> 0
- 280478 -> 193
unit_of_measurement: g
text_sensor:
- platform: template
name: Pieces of Rolls
lambda: |-
if ((id(rollcounter_value).state >= 85) and (id(rollcounter_value).state <=125)) {
return {"1 Rolle"};
}
if ((id(rollcounter_value).state >= 199) and (id(rollcounter_value).state <=255)) {
return {"2 Rollen"};
}
if ((id(rollcounter_value).state >= 301) and (id(rollcounter_value).state <=390)) {
return {"3 Rollen"};
}
if ((id(rollcounter_value).state >= 401) and (id(rollcounter_value).state <=490)) {
return {"4 Rollen"};
}
if ((id(rollcounter_value).state >= 501) and (id(rollcounter_value).state <=615)) {
return {"5 Rollen"};
}
if ((id(rollcounter_value).state >= 650) and (id(rollcounter_value).state <=730)) {
return {"6 Rollen"};
}
if ((id(rollcounter_value).state >= 750) and (id(rollcounter_value).state <=855)) {
return {"7 Rollen"};
}
if ((id(rollcounter_value).state >= 870) and (id(rollcounter_value).state <=980)) {
return {"8 Rollen"};
}
if ((id(rollcounter_value).state >= 1020) and (id(rollcounter_value).state <=1099)) {
return {"9 Rollen"};
}
if ((id(rollcounter_value).state >= 1130) and (id(rollcounter_value).state <=1250)) {
return {"10 Rollen"};
}
if ((id(rollcounter_value).state >= 1280) and (id(rollcounter_value).state <=1360)) {
return {"11 Rollen"};
}
if ((id(rollcounter_value).state >= 1401) and (id(rollcounter_value).state <=1490)) {
return {"12 Rollen"};
} else {
return {"Leer"};
}
update_interval: 5s
all the best
Andrew




. I hope that is not your real password for your wifi. You might want to remove that.
what is the range of the drift, like several gramms or in an acceptable range that can be adjusted via the ESP-config file? a roll of toiletpaper is 121g, I created a larger range of the values which represent how many rolls are in the box.