Wireless Remote Propane Tank Level Gauge

Place your projects here
Zim
Posts: 289
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 263 times
Been thanked: 129 times

Wireless Remote Propane Tank Level Gauge

Post by Zim »

I'm getting too old to trudge through the snow in -40 weather to check my propane level. Most large propane tanks use a bar magnet attached to a float linkage assembly. This bar magnet will rotate approx. 180 deg. from empty to full. The bar magnet position is monitored by a simple compass, externally. My idea was to monitor the bar magnet with an external digital compass and transmit the data. The digital compass is simply mounted approx. 1" above the original gauge and is NOT intrusive to the existing gauge or tank. I will transmit the data once a weak to increase battery life. The receiver is in the house and is calibrated to text me when the level is at 10%. Use this info at your own risk. If you are not aware of the risks liquid propane presents, this is not a project for you. Do not remove any existing screws or fittings from the gauge or tank.

DO NOT TAMPER WITH THE ORIGINAL GAUGE or TANK, OR LOSS OF LIFE MAY OCCUR!

The transmitter:
Tx.jpg
20231218_111351.jpg
typical.jpg
20231228_140855.jpg
gauge.jpg

Code: [Local Link Removed for Guests]

'gauge sensor v6
PIN.MODE 23, INPUT, PULLUP 'for boot up switch from io 23 to ground avoids sleep command
pause 100
if pin(23) = 0 goto en 'boot up and wait
msg$ = "0"
MAC1$ = "EE:FA:xx:6E:18:xx"  '  AP mac of the receiver
WIFI.CONNECT "Propane_Rx", "whatever"  'receiver name and password
pause 300
I2C.SETUP 21, 22           'QMC5883 compass
address = &H0D    ' Address of the device QMC5883
ioBuff.dim(0, 6)  ' To save the measurement result
i2c.writeRegByte address, &H0A, &B10000000  ' SOFT_RST
pause 100
i2c.writeRegByte address, &H0B, 1 ' start
pause 100
i2c.writeRegByte address, &H09, &B00010001 ' 512 samples, 8 gauss, 10Hz, continuous
pause 100

espnow.begin 
espnow.add_peer MAC1$
onEspNowError retry ' set the place where jump in case of TX error
pause 100

i2c.read_ioBuff(0), address, &H00, 6
  
  x = ioBuff.read(0, 0) OR (ioBuff.read(0, 1) << 8)
  if x > 32768 then x = x - 65536
  
  y = ioBuff.read(0, 2) OR (ioBuff.read(0, 3) << 8)
  if y > 32768 then y = y - 65536
  
  z = ioBuff.read(0, 4) OR (ioBuff.read(0, 5) << 8)
  if z > 32768 then z = z - 65536
   
  yaw = atan2(y, x) * 180 / PI
  if yaw < 0 then yaw = 360 + yaw 
pause 1000 
yw = cint(yaw)
print yw
msg$ = str$(yw)
EspNow.Write(msg$, MAC1$)  
pause 1000
sleep 86400       'set this for one week if needed

retry:
EspNow.Write(msg$, MAC1$)
print "resend"
return

en:
print "waiting for you"
wait
end
The Receiver:
Rx.jpg
20231231_231912.jpg
20231231_232152.jpg

Code: [Local Link Removed for Guests]

'propane_receiver v6 mac$(1) AP(EE:xx:BC:6E:xx:xx)
cls
wifi.connect "yourwifi", "password"
pause 1000
WIFI.APMODE "Propane_Rx", "password", 10

percent$ = "0"
percent = 0
msg$ = "360"
msg = 77
file$ = ""
line$ = ""
a$ = ""
pin.mode 14, input   
interrupt 14, view  ' turn on display with push button

I2C.SETUP 4, 5  ' set I2C port on pins (4 or D2 on SDA) and (5 or D1 on SCL)
OLED.INIT 1 ' init the OLED upside-down
OLED.CLS ' clear the screen
OLED.COLOR 1

OLED.FONT 3
OLED.PRINT 15,2, "Hello"
pause 2000
oled.cls

espnow.begin
pause 500
onEspNowMsg incoming ' set the place where jump in case of message reception
autorefresh 1000
print "start"
wait

incoming:
print "received"
Msg$ = EspNow.READ$
'Msg$ = "50"     'for testing
Msg = val(Msg$)   
print Msg
percent = CONVERT.MAP(Msg, 230, 50, 10, 70)  '(number, fromLow, fromHigh, toLow, toHigh) deg. to percentage [ you may need to calibrate this
if percent < 11 goto warning

percent$ = date$ +" "+ str$(cint(percent)) +"%"+" "+"Full"+" "
file$ = "/data.txt"              ' you must create this file
line$ = chr$(13)                 '
file.append file$, line$         '   required to add data to top of column
line$ = percent$ + chr$(13)      '
a$ = line$ + file.read$(file$)   '
file.save file$, a$              '   create new data file for display
file$ = ""
reboot
return

warning:
EMAIL.SETUP "smtp.gmail.com", 465, "whatisyour@gmail.com", "ynwnbpdeikvyfvvv",1 
print EMAIL ("tanklevel@gmail.com", "7892061010@msg.telus.com", "Propane Aert", "Propane below 10%")
OLED.CLS ' clear the screen
OLED.FONT 2
OLED.PRINT 15,2, "PROPANE LOW"
sleep 120
return

view:
if pin(14) = 1 then return   
OLED.CLS ' clear the screen
OLED.FONT 3
OLED.PRINT 15,2, file.read$("/data.txt",9,8) 'print percentage from file
OLED.FONT 2
OLED.PRINT 25,35, file.read$("/data.txt",0,8) 'print date from file
pause 6000
OLED.CLS ' clear the screen
Return
end
You need a push button from pin 14 to Vcc. This displays the reading. (The oled has limited life hours)
You also need to create a /data.txt file with this entry "26/12/23 63% Full". This file records the transmitted data for reference and can be accessed
through the editor.

Thanks to all who helped with the code!
You do not have the required permissions to view the files attached to this post.
Last edited by Zim on Tue Jan 16, 2024 5:53 am, edited 1 time in total.
User avatar
PeterN
Posts: 392
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 184 times
Been thanked: 220 times
Contact:

Re: Wireless Remote Propane Tank Level Gauge

Post by PeterN »

A very impressive and inspiring project!
User avatar
cicciocb
Site Admin
Posts: 2056
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1354 times
Contact:

Re: Wireless Remote Propane Tank Level Gauge

Post by cicciocb »

Nice project, Zim.

Now I understand why you were working with the digital compasses ... :D
User avatar
PeterN
Posts: 392
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 184 times
Been thanked: 220 times
Contact:

Re: Wireless Remote Propane Tank Level Gauge

Post by PeterN »

A source for many new thoughts; thank you!
One detail confuses me a bit:
There seems to be an external antenna connected via the on-board socket, but the bridging zero-ohm resistor is in the original position.
You mentioned remote positioning of the sensor, which would also have made me think of a "better" antenna.
Edit: And I am note sure, but the on board ceramic antenna seems to be removed(?)

IMG_8214.jpeg
You do not have the required permissions to view the files attached to this post.
BeanieBots
Posts: 345
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 183 times
Been thanked: 112 times

Re: Wireless Remote Propane Tank Level Gauge

Post by BeanieBots »

Nice project Zim, thanks for sharing.
FWIW, when using ESPnow, there is no need to actually establish WiFi connection, just be sure to set the channel to the same as the receiver.
That can save several seconds of on time. Might also be worth powering the other bits via an IO pin to reduce off current.
Maybe also consider adding battery level monitor. A 3M3/1M0 divider into 1uF on the ADC input pulls <1uA.
Doing all of the above would probably give you hourly updates for the same battery capacity.
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 267 times

Re: Wireless Remote Propane Tank Level Gauge

Post by Fernando Perez »

You may be too old to walk through the snow, but you demonstrate a mind that many young people would already like to program code. And to share it.

Rummaging through my drawers, I find 3 modules with HMC5883L. One, labeled GY-271 looks identical to the one in your photo.
I don't have a propane tank, ;) but I can try to reproduce your schematics in case I can help you as a beta-tester.
Zim
Posts: 289
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 263 times
Been thanked: 129 times

Re: Wireless Remote Propane Tank Level Gauge

Post by Zim »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jan 02, 2024 9:17 am Nice project, Zim.

Now I understand why you were working with the digital compasses ... :D
Hi cicciocb
I did try the AS5600, but it wasn't sensitive enough at the required distance. It was the code you posted for the GY-271 that worked out! Thanks!

Zim
User avatar
cicciocb
Site Admin
Posts: 2056
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 439 times
Been thanked: 1354 times
Contact:

Re: Wireless Remote Propane Tank Level Gauge

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jan 02, 2024 6:12 pm
[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jan 02, 2024 9:17 am Nice project, Zim.

Now I understand why you were working with the digital compasses ... :D
Hi cicciocb
I did try the AS5600, but it wasn't sensitive enough at the required distance. It was the code you posted for the GY-271 that worked out! Thanks!

Zim
You are welcome :D
Zim
Posts: 289
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 263 times
Been thanked: 129 times

Re: Wireless Remote Propane Tank Level Gauge

Post by Zim »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jan 02, 2024 9:59 am There seems to be an external antenna connected via the on-board socket, but the bridging zero-ohm resistor is in the original position.
You mentioned remote positioning of the sensor, which would also have made me think of a "better" antenna.
Edit: And I am note sure, but the on board ceramic antenna seems to be removed(?)
Hi PeterN
I found this old D1 Mini Pro in my junk box. I wanted an external antenna so it fit the bill. The ceramic ant. had been removed, which back in the day was an option vs removing the resistor. I tried several antennas, and low and behold, the RC aircraft antenna worked as good as any! (according to Vistumbler)

Thanks
Zim
Zim
Posts: 289
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 263 times
Been thanked: 129 times

Re: Wireless Remote Propane Tank Level Gauge

Post by Zim »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue Jan 02, 2024 10:41 am Nice project Zim, thanks for sharing.
FWIW, when using ESPnow, there is no need to actually establish WiFi connection, just be sure to set the channel to the same as the receiver.
That can save several seconds of on time. Might also be worth powering the other bits via an IO pin to reduce off current.
Maybe also consider adding battery level monitor. A 3M3/1M0 divider into 1uF on the ADC input pulls <1uA.
Doing all of the above would probably give you hourly updates for the same battery capacity.
Thanks BeanieBots
I am still waiting for a bare bones ESP32 module and a bare PC board so I can run without the onboard serial adapter, regulator and LED. Then I'll try using the sleep command to reboot, and power up the compass, once a week. I am also waiting for some "C005" timers to try, which will drive a FET and power up the assembly. I will use the system with the lowest power demand.
The battery operated transmitter doesn't connect to the local wifi, only to the receiver AP. The receiver connects to local wifi to keep Date and Time, and to allow remote access. The receiver has house power so drain isn't an issue. I am striving to get 6 months operation from a lantern battery. :roll:

Zim
Post Reply