[arm-allstar] pcsensor
David McGough
kb4fxc at inttek.net
Sat Jan 22 23:12:11 EST 2022
Dusty,
Looking at the messages, the utility "bc" is missing.
I'm guessing the RPi0W is running some Debian derivative OS? If so, try:
apt-get install bc
73, David KB4FXC
On Sun, 23 Jan 2022, Dusty Smith wrote:
> Hi again. I have successfully used your scripts on 2 different RPi3 units. But I was trying tonight to use it on a RPi zero wireless model and am getting errors. Can you offer any help on this.
>
> Here is the modified script I'm using that works flawlessly on rpi3 models.
>
> ---------------
> #!/bin/bash
> #
> # Simple temperature query script for PCSENSOR dual-sensor
> # device, version: Temper2_V3.7. KB4FXC 2021-11-28
> #
> # Available on Amazon: https://www.amazon.com/dp/B073PQJBMQ
> #
>
> [ ! -d /sys/class/hidraw ] && echo "No HID directory found!" && exit 1
>
> res=0
> for i in $(find /sys/class/hidraw/ -type l | sort -r) ; do
> grep -F -m 1 1A86:E025 <<< $(ls -srlt $i) &>/dev/null
> [ $? -eq 0 ] && res=1 && break
> done
>
> [ $res -eq 0 ] && echo "No HID devices found! Try resetting usb device" && exit 1
>
> hiddev="/dev/$(basename $i)"
>
> [ "$hiddev" = "" ] && echo "No HID directory found!" && exit 2
> [ ! -c "$hiddev" ] && echo "No HID device file found!" && exit 3
>
> DATE=$(date "+%Y-%m-%d-%H:%m:%S")
>
> exec 5<> $hiddev
> [ $? -ne 0 ] && echo "Can not connect to HID device!" && exit 4
>
> # Query the device version
> echo -e '\x00\x01\x86\xff\x01\x00\x00\x00\x00\c' >&5
>
> # get ASCII response
> OUT="$(timeout 5 dd count=2 bs=8 <&5 2>/dev/null | xargs)"
> #echo "version=$OUT"
>
> [ "$OUT" = "" ] && echo "ERROR: Can not read Version, try resetting usb device: hiddev=$hiddev" && exit 5
>
> REPLY="$OUT"
>
> # Query the temperature
> echo -e '\x00\x01\x80\x33\x01\x00\x00\x00\x00\c' >&5
>
> # get binary response
> OUT="$(timeout 5 dd count=2 bs=8 <&5 2>/dev/null | xxd -p )"
> #echo "out=$OUT"
>
> [ "$OUT" = "" ] && echo "ERROR: Can not read Temperature, try resetting usb device: hiddev=$hiddev" && exit 6
>
> # characters 5-8 is the temp1 in hex x1000
> HEX4=${OUT:4:4}
> DVAL=$((16#$HEX4))
> CTEMP=$(bc <<< "scale=2; $DVAL/100")
> FTEMP=$(bc <<< "scale=2; 9 * $DVAL / 500 + 32")
> #echo "Temp1=$CTEMP,$FTEMP"
> REPLY="$REPLY|$CTEMP|$FTEMP"
>
> # Starting at position 16, characters 5-8 is the temp2 in hex x1000
> HEX4=${OUT:20:4}
> DVAL=$((16#$HEX4))
> CTEMP=$(bc <<< "scale=2; $DVAL/100")
> FTEMP2=$(bc <<< "scale=2; 9 * $DVAL / 500 + 32")
> #echo "Temp2=$CTEMP,$FTEMP"
> REPLY="$REPLY|$CTEMP|$FTEMP"
>
>
> date2=$(date +%D---%T)
>
> echo "| ~ DATE ~ |USB F||Probe F|"
> echo "|$date2|$FTEMP-||$FTEMP2 |"
> exit 0
>
> -------------------------
>
>
> The error I get is as follows.
>
> root at raspberrypi:/HouseTemp# checktemp
> /usr/local/sbin/checktemp: line 52: bc: command not found
> /usr/local/sbin/checktemp: line 53: bc: command not found
> /usr/local/sbin/checktemp: line 60: bc: command not found
> /usr/local/sbin/checktemp: line 61: bc: command not found
> | ~ DATE ~ |USB F||Probe F|
> |01/22/22---21:43:12|-|| |
>
>
>
> Dusty Smith
> âW4MSIâ
>
> -----Original Message-----
> From: David McGough <kb4fxc at inttek.net>
> Sent: Saturday, November 20, 2021 8:03 PM
> To: Dusty Smith <w4msi at outlook.com>
> Cc: Dusty Smith via ARM-allstar <arm-allstar at hamvoip.org>
> Subject: Re: [arm-allstar] pcsensor
>
>
> Okay, I'll try to obtain one to test.
>
>
>
> On Sun, 21 Nov 2021, Dusty Smith wrote:
>
> > Ok just making sure you did get the reply. I purchased it from Amazon. Hereââ¬â¢s a link.
> >
> > PCsensor Double Sensor Computer USB Thermometer Data Logger Free PC
> > Software for Logging Temperature with Email Alarm -40~+120 Celsius
> > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.a
> > mazon.com%2Fdp%2FB073PQJBMQ%2Fref%3Dcm_sw_r_cp_api_glt_fabc_PNC0A2035C
> > R21T1QR8NK%3F_encoding%3DUTF8%26psc%3D1&data=04%7C01%7C%7Cf548aa3d
> > aa864d94424108d9ac92fbf0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C
> > 637730569565918148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjo
> > iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=W4cyxQUfUZYsJ
> > gxGMDIkplmh4HZHxX%2BWhN6ORyGxPjA%3D&reserved=0
> >
> > Let me know what you find and if thereââ¬â¢s any way I can assist or whatever. Appreciate your responses and any help you can offer.
> >
> >
> > Dusty Smith
> > ââ¬âW4MSIââ¬â
> >
> > (sent from my smartphone)
> >
> > On Nov 20, 2021, at 7:50 PM, David McGough <kb4fxc at inttek.net> wrote:
> >
> > 
> > Hi Dusty,
> >
> > Yes, I got the lsusb output. I'm not familiar with the model temp sensor
> > you've got, listed as:
> >
> > Bus 001 Device 005: ID 1a86:e025 QinHeng Electronics
> >
> >
> > I google'd this device ID and others indicated that a very simple
> > software update (probably just changing the device PID/VID in the
> > program) was all that was needed to get it to work. However, since I don't have one of
> > these sensors, I can't personally test. Where did you get this sensor??
> > If I can get one, I'll try to update the software.
> >
> >
> > 73, David KB4FXC
> >
> >
> >
> >
> > On Sun, 21 Nov 2021, Dusty Smith wrote:
> >
> > Did you get my reply with the lsusb output?
> >
> >
> > Dusty Smith
> > â?"W4MSIâ?"
> >
> > (sent from my smartphone)
> >
> > On Nov 19, 2021, at 7:36 PM, David McGough <kb4fxc at inttek.net> wrote:
> >
> > ïûÿ
> > Hi Dusty,
> >
> > Please post the output from lsusb. Typically, that family of sensors
> > is very easy to use. I expect a minor software change will get the
> > model you've got to work.
> >
> >
> > 73, David KB4FXC
> >
> >
> > On Sat, 20 Nov 2021, "Dusty Smith via ARM-allstar" wrote:
> >
> > Hello, I'm trying to setup a usb temperature sensor on my pi/hamvoip
> > node/repeater to monitor the temp of the station and such. I just
> > purchased a TEMPer2 usb sensor. Plugged it into the Pi and ran
> > pcsensor and it gives the error of "Couldn't find the USB device,
> > Exiting" tried updating hamvoip and rebooting multiple times to no
> > avail. If I run lsusb I can see the device listed. So the Pi is seeing
> > it. But pcsensor doesn't seem to know it's there. Can you offer any guidance? Thank you!
> >
> > So after doing some more digging it appears that maybe the sensor I
> > purchased just simply isn't compatible (TEMPer2). If that's the case,
> > do you know which sensors are compatible. I'd like to get this working
> > but not sure what needs to be purchased. Here's a site with different models.
> >
> > https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pc
> > sensor.com%2Fusb-temperature-humidity.html&data=04%7C01%7C%7Cf548a
> > a3daa864d94424108d9ac92fbf0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0
> > %7C637730569565918148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQ
> > IjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=Hi4wvQW9D4
> > 3cAioXH%2Fpqd34idipj5AyVEumrOP210mo%3D&reserved=0
> >
> > Any help would be greatly appreciated. Thanks!
> >
> >
> > Dusty Smith
> > -W4MSI-
> >
> > _______________________________________________
> >
> > ARM-allstar mailing list
> > ARM-allstar at hamvoip.org
> > https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.
> > hamvoip.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Farm-allstar&data=04%7
> > C01%7C%7Cf548aa3daa864d94424108d9ac92fbf0%7C84df9e7fe9f640afb435aaaaaa
> > aaaaaa%7C1%7C0%7C637730569565918148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC
> > 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sd
> > ata=j3XyL1qranQYCMjn8%2BOOjk7vM%2FpRcmD9JDIQ2ifExO4%3D&reserved=0
> >
> > Visit the BBB and RPi2/3/4 web page -
> > https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhamvoi
> > p.org%2F&data=04%7C01%7C%7Cf548aa3daa864d94424108d9ac92fbf0%7C84df
> > 9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637730569565918148%7CUnknown%7C
> > TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVC
> > I6Mn0%3D%7C3000&sdata=r5ehJu5SWrED0ME9eYk9jd8LoIPw%2BNr3fHpL%2F6Pu
> > LqQ%3D&reserved=0
> >
> >
> >
> >
> >
>
>
More information about the ARM-allstar
mailing list