I have it running, but I wonder if there is somewhere a config file, a cron .. How does it run
ds18b20
Apr 10, 2022
Last reply: 4 years ago
18 Replies
You have to have something that will scan your 1-wire bus, detect and read your temperatue sensor(s) ... no doubt something already exists that can run on a Pi
Try this:
#!/bin/bash
# get a list (array) of all devices shopt -s nullglob devices=(/sys/bus/w1/devices/w1_bus_master1/28*) [ ${#devices[@]} -eq 0 ] && { printf 'No device files found. Investigate.' exit 1 } shopt -u nullglob printf '%s\n' "${devices[@]}"
while true; do # repeat forever unset temp # new array for d in ${!devices[@]}; do # for each device unset t # new temperature value # at odd times we get -015 for reading; ignore it while [[ ! "$t" || "$t" -lt 0 ]]; do # getting temp can take a couple of seconds t=$(<"${devices[d]}/temperature") # get reading done p="${devices[d]##*-}" # probe serial number # reading is in millidegrees t=$(bc <<<"scale=3; $t/1000") temp+=("P-$p ${t}") # now degrees done printf '%(%Y-%m-%d %H:%M:%S)T ' # date and time printf '%s %1.3f ' ${temp[@]} # probe data printf '\n' # newline sleep 10 done
I have it running!!!!!!!!!! My question is:::: how does it work, config file, cron job .. I haven't found HOW it work.
HOW what works?
I run the above as a background job, output recorded in a data file for further processing by gnuplot.
Well, how did you install it? There is no driver or service or daemon, it's just a gpio read-out (according to a certain protocol, that's what the Python library is for). If by running you mean it's logging the temperature somewhere, then you probably installed a Python program that now runs in the background. It might be started from /etc/rc.local or it might be installed as a service. We don't know. So how did you get it running?
See
formatting link
or
formatting link
Le 11/04/22 à 10:31, zeneca a écrit :
It run every 5 minutes, how to modify this, it run from a gpio.?? how to change this?? how to change the precision ?? ....
What runs every five minutes? And where did you get it from? Look at your cron file (crontab -e) for the 5 minute interval time.
Your probe connects to a gpio pin (default 4 as I remember) You change the default pin in /boot/config.txt on the dtoverlay=w1-gpio line. Look it up.
Probe data is in millidegrees - you can't change that.
Look it up! Get used to using the command line because using it is often faster than messing about with a web browser.
'man' tells you about programs and functions, e.g. 'man sleep' run from the command line tells you about the 'sleep' command
Don't know the name of the command you want? Use 'apropos' command: 'apropos delay' tells you about things that cause delays, including 'sleep'.
Despite the title, consider about buying a copy of 'Linux for Dummies'. The '...for dummies' books are quite well regarded and less technical that O'Reilly books, which are really for sysadmins and developers. Also, you should learn how to ask technical questions. Just saying 'Wah! it doesn't work' is a good way to be ignored. Your post should say:
- what you're trying to do and why
- what you tried
- what happened when you tried it. Include the command you ran and the 'whole' response to that command by copying and pasting text from the screen. ALWAYS show what you see on screen and NEVER paraphrase it.
- what you expected to happen.
The python w1thermsensor module is useful, it also includes a command line program to scan for all ds18b20 devices.
---druck
No entry found in all cron I found (etc/cron.d ....) every 5 minutes a read data from the ds18.. is iniiatted and data stored in /sys/bus/w1/devices/w1_bus_master1/28-0000034decc3/w1_slave where I can read temperature from. My appli display temperature on a web page, store it in a rrdtools database, display graphics And temperature is alos displayed on a NOKIA-5110 display (writen in C)
Doesn't give idea where to changes w1-gpio??
Many thanks for you answer
>
You don't need python. Just list: /sys/bus/w1/devices/w1_bus_master1/28-*
Current temperature (millidegrees) is in /sys/bus/w1/devices/w1_bus_master1/28-[serialnum]/temperature
Did you look in your own crontab?
/sys/bus/w1/devices/w1_bus_master1/28-0000034decc3/w1_slave and /sys/bus/w1/devices/w1_bus_master1/28-0000034decc3/temperature are updated constantly. There is one directory (28-nnnnnnnnnnnn) for each probe.
What you mean is every five minutes w1_slave is read. You could also read temperature directly from the file 'temperature'.
In your (undoubtedly python) program, is there a line such as time.sleep(600)? That's the delay between readings.
/ deleted /
I think you replied to the wrong poster.
No you don't _need_ python, but it saves faffing about extracting the CRC check (failures are common with long leads) and reformatting to degrees. If you are going to stick the value in database, this can be done in a couple of lines of python with the sqlite module.
---druck
Indeed. Apologies.
The resolution is actually 1/16 degree, but reported to 3 decimal places.
I think there is a similar higher resolution device (GX20MH01?), but I haven't tried it.
formatting link
This is some Python code that uses the kernel-space 1-Wire support to read a temperature sensor and control an addressable switch in response. 1-Wire devices connected to an appropriate interface are enumerated when the kernel boots and show up under /sys/bus/w1/devices.
(Also related to this project:
formatting link
which brings 1-Wire, I2C, and power out to an RJ-45 connector. IIRC, it also adds an RTC.)
You might find this useful:
formatting link
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required