Smart toilet paper counter

Hi there

may I introduce you to the revolutionary smart toilet paper counter :wink: 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

3 Likes

Great idea :grinning:. I hope that is not your real password for your wifi. You might want to remove that.

1 Like

many thanks for making me aware of it, its changed :wink:

People’s ideas never stop amazing me, when you think you have seen it ‘all’ :slight_smile:
I think I am going to use this for another thing…we are always running out of bottles of bubbly water…

As a next challenge, maybe you can build a pulse-meter that measures every rotation of the roll, together with the location sensor you can then measure who ‘consumes’ what :slight_smile:

1 Like

Too much information.

Well Done!
Curious to know if you experience drift on your hx711 over time. I have a few of these and could never keep them stable for very long.

1 Like

thats a good question, as for now it works fine :stuck_out_tongue: 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.

for example two rolls weigh 242g but the upper value of the range is 255.

 }
      if ((id(rollcounter_value).state >= 199) and (id(rollcounter_value).state <=255)) {
        return {"2 Rollen"};
1 Like