How do I use owfs to read an iButton temperature logger?
I've installed owfs
and am trying to read the data off a iButton temperature logger.
owfs
lets me mount the iButton as a fuse filesystem and I can see all the data. I'm having trouble figuring out what is the best way to access the data though. I can get individual readings by cat
ting the files, e.g. cat onewire/{deviceid}/log/temperature.1
, but the onewire/{deviceid}/log/temperature.ALL
file is "broken" (possible too large, as histogram/temperature.ALL
work fine).
A python script to read all files seems to work but takes a very long time. Is there a better way to do it? Does anyone have any examples?
I'm using Ubuntu 8.04 and couldn't get the java "one wire viewer" app to run.
Update: Using owpython
(installed with owfs), I can get the current temperature but can't figure out how to get access to the recorded logs:
>>> import ow
>>> ow.init("u") # initialize USB
>>> ow.Sensor("/").sensorList()
[Sensor("/81.7FD921000000"), Sensor("/21.C4B912000000")]
>>> x = ow.Sensor("/21.C4B912000000")
>>> print x.type, x.temperature
DS1921 22
x.log
gives an AttributeError
.
Asked by: Carina470 | Posted: 28-01-2022
Answer 1
I've also had problems with owfs. I found it to be an overengineered solution to what is a simple problem. Now I'm using the DigiTemp code without a problem. I found it to be flexible and reliable. For instance, I store the room's temperature in a log file every minute by running
/usr/local/bin/digitemp_DS9097U -c /usr/local/etc/digitemp.conf \
-q -t0 -n0 -d60 -l/var/log/temperature
To reach that point I downloaded the source file, untarred it and then did the following.
# Compile the hardware-specific command
make ds9097u
# Initialize the configuration file
./digitemp_DS9097U -s/dev/ttyS0 -i
# Run command to obtain temperature, and verify your setup
./digitemp_DS9097U -a
# Copy the configuration file to an accessible place
cp .digitemprc /usr/local/etc/digitemp.conf
I also hand-edited my configuration file to adjust it to my setup. This is how it ended-up.
TTY /dev/ttyS0
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F"
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C"
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%"
SENSORS 1
ROM 0 0x10 0xD3 0x5B 0x07 0x00 0x00 0x00 0x05
In my case I also created a /etc/init.d/digitemp file and enabled it to run at startup.
#! /bin/sh
#
# System startup script for the temperature monitoring daemon
#
### BEGIN INIT INFO
# Provides: digitemp
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start the temperature monitoring daemon
### END INIT INFO
DIGITEMP=/usr/local/bin/digitemp_DS9097U
test -x $DIGITEMP || exit 5
DIGITEMP_CONFIG=/root/digitemp.conf
test -f $DIGITEMP_CONFIG || exit 6
DIGITEMP_LOGFILE=/var/log/temperature
# Source SuSE config
. /etc/rc.status
rc_reset
case "$1" in
start)
echo -n "Starting temperature monitoring daemon"
startproc $DIGITEMP -c $DIGITEMP_CONFIG -q -t0 -n0 -d60 -l$DIGITEMP_LOGFILE
rc_status -v
;;
stop)
echo -n "Shutting down temperature monitoring daemon"
killproc -TERM $DIGITEMP
rc_status -v
;;
try-restart)
$0 status >/dev/null && $0 restart
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
$0 try-restart
rc_status
;;
reload)
$0 try-restart
rc_status
;;
status)
echo -n "Checking for temperature monitoring service"
checkproc $DIGITEMP
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit
Answered by: Marcus275 | Posted: 01-03-2022
Answer 2
I don't think there is a clever way. owpython doesn't support that telling from the API documentation. I guess /proc
is your safest bet. Maybe have a look at the source of the owpython module and check if you can find out how it works.
Answer 3
Well I have just started to look at ibuttons and want to use python.
This looks more promising:
http://www.ohloh.net/p/pyonewire
Answered by: Adelaide728 | Posted: 01-03-2022Similar questions
How can I get the CPU temperature in Python?
This question already has answers here:
windows - Accessing CPU temperature in python
I need an example code for accessing CPU temperature in python.
I'm running windows 7, BTW.
python - temperature probes, voltage probes, etc. .dll
I am working on a program in python to monitor temperature of cpu and various other things including motherboard voltages.
I have tried using wmi, and acpi to read the probes, and have had no luck. this has been discussed here: http://www.python-forum.org/pythonforum/viewtopic.php?f=1&t=26726
I am now t...
linux - Get hard disk temperature using Python
I would like to get the temperature of a hard disk using Python (under Linux). I'm currently calling hddtemp with subprocess.popen, but I call it often enough that it is a performance bottleneck in my script. I think it should be possible to do something similar to question 4193514?
Python Tkinter Temperature Converter
so i am making a temp converter and i just cant get it to the calc for Fahrenheit to Celsius. It works to go from Celsius to Fahrenheit but it wont convert the other way. I am not sure what problem is causing this i have tried the intvars and stringvars but none seem to fix this problem and i have also tried the diff if statements but its just cant convert from fah to cel. Could someone please help me and tell me whats wro...
temperature - Python how to find correct result in string
I'm using Occidentalis v0.2 and calling modprobe with a python script to read out temperatures from one DS18B20!
I'm new to python as well so bear with me, this is a small part of my code:
with open(path, "r") as f:
contentArray = []
for line in f:
contentArray.append (line)
f.close
s = contentArray[0]
if s.find('YES'):
return contentArray[0]
else:
return 88
Example: c...
user interface - Creating a temperature program using Python and Tkinter
I am writing a small Python/Tkinter program for yearly temperatures.
I can get nearly everything working as a textual program, but I'm wanting to implement it into a GUI.
The program opens a csv file, reads it into lists, works out the average, and min & max temps. Then, on closing, the application will save a summary to a new text file.
I am wanting the default start up screen to...
PYTHON: Import .txt file (data for temperature and years) and find the average for k years
parameter passing - Python Temperature Converter
I'm working on a python temperature converter. It will convert Fahrenheit to Celsius and vice versa. I haven't added the if statements yet, or the Celsius to Fahrenheit function yet. But I'm having trouble with this Fahrenheit to Celsius function,
def F_C(x):
x = raw_input("Please Enter A Value")
x = int(x)
x - 32
x * 0.55
answer = F_C(x)
print x
for some reason, it only t...
python mapreduce example for max/min temperature in hadoop
I have setup the hadoop on my ubuntu, and ran example codes to test. One of the common examples is https://github.com/tomwhite/hadoop-book/tree/master/ch02/src/main/python
I have tested this code w/ given sample file(...
Still can't find your answer? Check out these communities...
PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python