Python Nerds Gather...
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

Python Nerds Gather Round

6 Posts
3 Users
0 Reactions
54 Views
Posts: 13916
Free Member
Topic starter
 

I have a Raspberry Pi monitoring my old oil boiler for when it's actually running/burning from this I can calculate oil use.

Old System
Python script that 'listened' to the volume of the surroundings using a USB microphone.  Above a certain level the burner was running, below the level it was not.

Problem was that there were some errors due to outside noise and the Pi being in a steel box was not good for wifi signal.

New System
I've a relay triggered by the 28v power supply to the oil pump solenoid (only on when the burner is running) - the other side of the relay closes a connection on one of the Pi GPIO pins - works great.  The script checks the state of the pin every 5 seconds.

The little issue I'd like to fix is this:
A few seconds before the pump solenoid opens, the boiler controller send a quick burst (less than 1 second) of 28v to the solenoid and then it drops back to 0v before it fires properly a few seconds later.   This quick burst is enough to trigger the script which shows as the boiler being on for 5 seconds then going off again, before starting properly.
It's not a major issue as my app filters out burns of less than 1 minute - but it's just not 'tidy' and does create 4 webhook messages to IFTTT rather than just two for each burn.

I thought I could get the script to wait a couple of seconds and then re-check the pin status before deciding that the burner was on.... but it's not working and still records the first power blip.

This is the code that does the checking - have I got this wrong?

boiler_status = 0

while True:
input_state = GPIO.input(13)
if input_state == False and boiler_status == 0:
print("Waiting")
time.sleep(1)      # wait to see if the pin condition stays the same
if input_state == False and boiler_status == 0:       # if it is then the boiler is running
print('Boiler On')
boiler_status = 1
time.sleep(5)
r = requests.post('https://maker.ifttt.com/trigger/Boiler_On/with/key/blahblah',params={"value1":datetime.now()})

elif input_state == True and boiler_status == 1:
boiler_status = 0
print("Boiler Off")
time.sleep(5)
r = requests.post('https://maker.ifttt.com/trigger/Boiler_Off/with/key/blahblah',params={"value1":datetime.now()})

This is what I get in my spreadsheet for a single burn:
February 18, 2023 at 03:12PM Boiler_On 2/18/2023 15:12:35   <------ Power blip
February 18, 2023 at 03:12PM Boiler_Off 2/18/2023 15:12:40
February 18, 2023 at 03:12PM Boiler_On 2/18/2023 15:12:47   <------ Actual burn start
February 18, 2023 at 03:21PM Boiler_Off 2/18/2023 15:21:24


 
Posted : 18/02/2023 3:26 pm
Posts: 23277
Free Member
 

Don’t you need to recheck the pin status after your first wait.


 
Posted : 18/02/2023 3:41 pm
Posts: 1494
Full Member
 

Why don’t you measure the temp on the inlet pipe? That should be a good indication of heat being generated


 
Posted : 18/02/2023 3:48 pm
Posts: 13916
Free Member
Topic starter
 

Don’t you need to recheck the pin status after your first wait.

I thought it does!

Why don’t you measure the temp on the inlet pipe?

Temperature takes too long to build and dissipate...... Measuring when the oil starts and stops flowing is much more accurate.


 
Posted : 18/02/2023 3:58 pm
Posts: 23277
Free Member
 

input_state = GPIO.input(13)

this gets the state of the switch. You only get it at the start of the while loop.

You need to get it again after the 5s wait to see if it’s still on. Otherwise you are just checking the state it was when at the start.


 
Posted : 18/02/2023 4:05 pm
Posts: 13916
Free Member
Topic starter
 

Ahhh, of course.....perfect!

Something to play with in the morning.

Edit:  Altered to re-check the pin state.... off to the pub and wait to see if it's fixed 🙂


 
Posted : 18/02/2023 4:25 pm
Posts: 13916
Free Member
Topic starter
 

Fixed!

Thanks @jam-bo


 
Posted : 18/02/2023 4:52 pm

6 DAYS LEFT
We are currently at 95% of our target!