[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
> You get a higher quality reply if you email me directly rather than via the list > ;-) Yes, but then others wouldn't know about the meetings in Plymouth :D (I love watching email conversations go widely away from their subject line...) Thanks for the info Gordon - I'll have a dive in to what you've written below. -----Original Message----- From: list [mailto:list-bounces@xxxxxxxxxxxx] On Behalf Of Gordon Henderson via list Sent: 16 February 2017 19:37 To: list@xxxxxxxxxxxxx Subject: Re: [LUG] WiringPi - 1 Wire? On Thu, 16 Feb 2017, Tremayne, Steve via list wrote: > Gordon, You get a higher quality reply if you email me directly rather than via the list ;-) > I was "fiddling" with a Ras Pi Zero and a 1-wire temp sensor yesterday... > > Does your Wiring Pi deal with 1-wire? I got no search results from > the site, so I'm presuming not? 1-wire is handled very well by the Linux kernel and its owfs (one-wire filing system), so there's no need for me to write anything for something that's already there. However, for the common ds18b20 1-wire temperature sensors, I've created a pin wrapper for them to better integrate them into the wiringPi world. You'll need to install the latest wiringPi from source though. http://wiringpi.com/download-and-install/ then run: sudo raspi-config go through the menus and enable 1-wire. Plug in the sensor - it's fixed to bcm_gpio pin 4 (physical pin 7) then ls /sys/bus/w1/devices If you see a 28-????? file, then the ds18b20 is present. You can cat this file/w1_slave - e.g.: $ cat /sys/bus/w1/devices/28-0000053af458/w1_slave f6 00 4b 46 7f ff 0a 10 d6 : crc=d6 YES f6 00 4b 46 7f ff 0a 10 d6 t=15375 your filename will be different from mine - each device has a unique 64-bit ID and mine is: 0000053af458. In the output above, YES means a good read and t=15375 is the temperature times 1000. Remember these are +/- 1ÂC devices, so round and truncate appropriately. With the latest wiringPi: $ gpio -x ds18b20:100:0000053af458 aread 100 154 means 15.4ÂC. In a C program: #include <ds18b20.h> int temp10 ; if (ds18b20Setup (pinBase, "0000053af458") < 0) .. something went wrong exit (1) ; temp10 = analogRead (pinBase) ; returns the temperature times 10 as an integer. Reading takes about 3/4 a second. > It's been a while since I've really done much "fiddling" with > electronics, so I'm finding more rust on my brain than I thought - so, > if 1-wire is handled by I2C / SPI, then apologies... I'll just go and > RTFM... It's handled directly. Use BCM_GPIO pin 4 and off you go. Gordon -- The Mailing List for the Devon & Cornwall LUG https://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/listfaq