Today on the hookup we’re going to build a simple internet of things weight sensor that you can use to measure things like how much propane is in your barbeque tank, CO2 is left in your keg, or with a little modification you could even measure the amount of salt left in your water softener... the possibilities are endless, oh and we’re going to do it all without coding, and for under $15.
A couple of videos ago I tested out some grilling accessories, and I was really disappointed that neither of the propane level monitors that I tested worked, like, at all. In the end I decided to just say screw it and build my own. Lots of you guys commented that you’d like a walk through so you could build your own, not just for propane level monitoring, but for kegs, CO2 tanks, steam irons and basically anything else that changes it’s mass as it depletes, so here it is!
This video is sponsored by HolidayCoro.com, one of the largest light show vendors in America, and light show season is officially here. This may be your last week to get started if you hope to have a functional show by Christmas and HolidayCoro has you covered with prebuilt kits including props, controllers, LEDs and power supplies to give you that boost that you need to start your first show, or maybe just level up your existing decorations. Check out HolidayCoro using the link in the description to support my channel.
To make this project you’re going need an ESP8266 nodemcu, a set of 4 load cells, and an HX711 amplifier, those parts are available on amazon for under $15, or AliExpress for significantly cheaper than that. Links for both are down in the description. Optionally, I also used my set of dupont crimpers to make connections easier, but they aren’t necessary.
The basic concept behind this circuit is simple. A load cell is a piece of metal that can deform, and as it deforms, one side becomes slightly shorter and thicker and the other becomes slightly longer and thinner. The short thick side experiences a reduction in its resistance, while the long thin side has an increase. By measuring the difference in the resistance of both sides we can determine how much deformation is occurring, and therefore determine the load on the system. You could theoretically use a single load cell, but putting too much weight on that cell will cause it to permanently deform, which will cause your sensor to become less accurate over time. Instead we will use 4 loadcells setup in a configuration called wheatstone bridge to take some of the strain off each load cell so they will hopefully last a lot longer.
Lets build it:
You can get as fancy as you want with your mount, but I’m going to keep it simple and use some scrap plywood that I’ve cut into a ring that can fit my propane tank. I’ll then mount my load cells equidistant from each other in a square configuration. The important thing to know about mounting your load cells is that they need to be able to deform, so you’ll need to provide some kind of a hole for the middle section to deflect into. There are a few 3d printed options, links to those are down in the description, but if you want to skip the 3d printer, there’s no reason why you can’t just drill a few holes and chisel out an indentation underneath each cell.
You can mount your cells with superglue, or optionally screw them in with some short panhead screws. Just make sure the screw doesn’t protrude lower than the load cell foot, or even worse up through the scale into your propane tank. Next, you should label your load cells as 1, 2, 3, and 4 in a clockwise fashion.
To make your wheatstone bridge, you’re going to connect the white wires of cell 1 and cell 2, and the white wires of cell 3 and cell 4. Then connect the black wires of cell 1 and cell 4, and then the black wires of cell 2 and cell 3.
At this point I broke out my dupont crimpers and attached some female pin headers to my 4 remaining red wires, and then connected them to the HX711 amplifier. The amplifier is necessary because the difference in resistance in the load cell is actually really small so we need a purpose built device with a better analog voltage resolution than you’d find in a normal microcontroller. We also want to keep the HX711 as close to our load cells as possible so we don’t introduce noise or more resistance into the circuit with our connecting wires. On the HX711 you’ll connect the red wire of cell 1 to the A minus terminal, cell 2 to the E plus terminal, cell 3 to the A plus terminal, and cell 4 to the E minus terminal.
Next, we just need to connect our HX711 to our nodemcu microcontroller and set up a program to monitor it. For this, we’re going to use my personal favorite custom firmware: Tasmota. My current favorite method for installing tasmota is a program called tasmotizer that simplifies the process to the point where absolutely anyone can use it. Download tasmotizer for the link in the desicription and right click the file and hit run as administrator. In tasmotizer we’re going select release under image, and then choose “Tasmota-sensors.bin” from the dropdown, click the “self resetting device” checkbox and plug your nodemcu into your computer’s USB port. If you hit refresh a new com port should show up and you’re ready to flash your device, so hit that blue tasmotize button and let the program do the rest.
After it finishes you’re going to send your wifi credentials, and your MQTT information using the send config button, I like to specify the topic in this window, and for this project I’m going to make the topic “propane”.
After you’ve entered that information the device will automatically reboot and you can press the Get IP button to find your new device’s IP address.
Navigate to that IP address in your browser to get to the tasmota web UI where we need to setup our new sensor. Click on configure, and then configure module and select generic, which will cause the device to reboot. Then repeat those steps to get back to the configure module screen where we can tell tasmota where we plan on attaching our HX711 load cell amplifier. We’ll need to set a clock pin and a data pin, and I like to use D1 and D2 in my projects because they don’t cause boot issues, so select D1 your clock pin or HX711 SCK, and D2 for your data pin or HX711 DAT and then hit save.
Next, you’re going to connect your nodemcu to your HX711 by connecting ground to ground, 3v3 on the nodemcu and VCC on the HX711, and then connect the clock pin to D1, and the Data pin to D2.
You should now see some data pop up in the tasmota web interface for your new scale, but it’s probably not going to be right. Click on console and grab something that you know the weight of. For instance these water bottles contain 500 mL of water with a mass of 500g, so they should weigh roughly 510 grams each with the bottle included, and two should be about 1020 grams. I’ll calibrate my scale by typing in sensor34 2 1020 which is the calibrate command for the HX711 sensor, followed by the number of grams that it should be expecting. The console asks me to remove the weight, then replace it and then it will automatically calibrate itself. If you get an error on this step, the wiring on your load cells may have been reversed from the factory and you can check it by typing in status 8, which should show you the raw value of the sensor. Putting things on the scale should make that value go up, and taking them off should make it go down. If it’s the opposite of that you’ll need to reverse your white and black wires, so every white connection that you had instead connect the black ones, and vice versa.
Once you’re calibrated the last thing to do is increase the frequency that your sensor reports the weight via MQTT by typing teleperiod 20 to report every 20 seconds and you’ll also want to increase the resolution of the weight output by typing in weightres 3 to the tasmota console. Once you’ve done that and then you can go back to your tasmota web interface and start weighing stuff, pretty cool right?
In my experience for sustained loads tasmota sometimes does weird things like randomly zeroing the balance or changing the start value of the scale on it’s own, luckily the raw weight seems to always be correct. The good news is that it’s really simple to calculate the number of grams based on the raw weight value. All you need to do is empty your scale and type in status 8 in the tasmota console and write down the raw weight value to use later.
To add an MQTT sensor to home assistant open your configuration.yaml file and under the sensor heading specify a name and state topic according to the topic you put into tasmotizer earlier. So for me it’s “tele/propane/SENSOR”. Since this topic reports a JSON output we want to grab the specific attribute for raw weight, so we’ll put in a value template to grab the json attribute from our HX711 sensor and then we just need to subtract the raw value of the scale that we wrote down earlier to calculate the number of grams on the scale. You can also specify that the unit of measurement is in grams, and then you’re all set.
To set up your percentage sensor you can use some standard values for propane tanks. I’m not sure if these are different internationally, but in the US we use 17 pound roughly 7700 kgram tanks, that are filled with 20 pounds of propane which is roughly 9070 kilograms.
Do do this calculation we’ll use another MQTT sensor with a value template that will first grab the raw weight and convert it to grams just like before and then we will take that value and subtract 7700 grams which is the weight of the empty propane tank, and that will give us just the weight of the propane. Then we want to take that value and divide it by 9070 grams, which is the maximum amount of liquid propane that will fit in one of these tanks and finally we need to multiply by 100 to give us a percentage of propane left in the tank. For reference here’s the reading from my partially used propane tank, and then a brand new never been used tank from Home Depot.
Once you’ve got those entries in your configuration.yaml file you can restart home assistant and add them to your lovelace dashboard using the edit UI button. Next you can make it as plain or fancy as you want by using different card types. Once you’ve got those values in home assistant you can set up automations to do things like remind you to buy a new tank you if the % drops below a certain amount, or alert you if the % drops a certain amount while your away from the house or asleep indicating that there is a propane leak.
At this point the possibilities are endless and the use cases are all up to you. If you’ve got a specific use case in mind other than a propane monitor, leave a comment to give everyone else some inspiration. If you’ve got questions about how to make your sensor, or make it do what you want feel free to leave a comment or come join us on the hook up home automation facebook group.
Thank you to all of my awesome patrons over at patreon for your continued support of my channel, if you’re interested in supporting my content please check out the links in the description. If you enjoyed this video please hit that thumbs up button and consider subscribing, and as always, thanks for watching the hookup.