wbarsuhn
Posts: 1
Joined: Sat Nov 11, 2017 1:43 pm

Losing Temperature probe

Sat Nov 11, 2017 1:53 pm

I have a Python program that I wrote to check the temperature of my aquarium and based on the results it will turn the heater on or off. The problem that I am having is that the program will, for no apparent reason, give the following error code and then stop:

Traceback (most recent call last):
File "Thermo.py", line 23, in <module>
tfile = open("/sys/bus/w1/devices/28-0315a4e4e6ff/w1_slave")#yellow
FileNotFoundError: [Errno 2] No such file or directory: '/sys/bus/w1/devices/28-0315a4e4e6ff/w1_slave'

The most significant problem with this is that if it shuts down while the heater is on, then the temperature can increase significantly. To prevent this I should probably put in code to turn off the heater if I get an error, but I don't know how to do that yet.

Can anybody help in explaining why this error would randomly show up? The program has been running for months without any error and now it has done this twice in the last 24 hours.

ghp
Posts: 1517
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Losing Temperature probe

Sat Nov 11, 2017 4:44 pm

Hello,
put the code into a try-except statement:

Code: Select all

try:
    tfile = open("/sys/bus/w1/devices/28-0315a4e4e6ff/w1_slave")#yellow
    ... process data as usual
except FileNotFoundError as e:
    print("ERROR", str(e) )
    ... stop heater, send emails, sound a buzzer or whatever needed
      
See also https://docs.python.org/3/tutorial/errors.html

Hope this helps,
Gerhard

pcmanbob
Posts: 9612
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Losing Temperature probe

Sat Nov 11, 2017 4:50 pm

1-wire devices are normally reliable, could water have got in the the temp probe end causing a problem.

I would look at what else you have connected to the gpio to see if any of them could be causing problems with the gpio which results in 1-wire device failure.

The reason I ask is another user was having problems with 1-wire device failure, it turned out he had 5v device connected to the gpio that had damaged the gpio and caused the 1-wire interface to fail.

one way to monitor for failure would be to record time heater comes on and check to see if it has been on for longer than a set time that you could decide on, and if so force the heater off and may be light an LED as an alarm or do something appropriate to alert you.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Python”