Announcement

Collapse
No announcement yet.

How To Monitor Temperature of your Zee S2

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How To Monitor Temperature of your Zee S2

    This is for a Raspberry Pi2 version of the Zee (Zee S2) only.

    First, create the following shell script on your Pi2 as user homeseer in your /home/homeseer folder. Name the script getTemp.sh and make sure you assign execute attributes:

    Code:
    homeseer@RPi2 ~ $ cat getTemp.sh
    #!/bin/bash
    echo $(/opt/vc/bin/vcgencmd measure_temp)
    homeseer@RPi2 ~ $ chmod a+x getTemp.sh
    homeseer@RPi2 ~ $


    Next. create a HomeSeer Virtual device and mark it as Status Only. Click on the Advanced tab to get the device reference number.

    Next, create a new Event to run a Script. You can schedule it to run every hour or so. Have the Event run this script. Add your virtual device reference from the step above.

    Code:
    Imports System.IO
    
    ''Pi2Temperature.vb - Rob Mason - 7/30/2015 - Free to use/modify.
    ''This version is for the Pi2 only, and has been tested on Raspbian.
    
    Sub Main(parm as object)
       dim FTemp,CTemp as Double
       dim proc as System.Diagnostics.Process
       dim resp,t,s() as String   
       dim sw as StreamWriter
       dim dref as Integer = 866   'use your own virtual device reference
       
       Try
          	proc = new System.Diagnostics.Process()
    	proc.StartInfo.FileName="/home/homeseer/getTemp.sh"
    	proc.StartInfo.UseShellExecute=False
    	proc.StartInfo.RedirectStandardOutput = True
    	proc.Start()
    	t=proc.StandardOutput.ReadToEnd()
    	s = Split(t,"=")
    	resp=s(1)
    	s=split(resp,"'")
    	resp=s(0)
    
    	CTemp = CDbl(resp)
    	FTemp = getFarenheit(CTemp)
    	hs.WriteLog("Pi2Temperature","CTemp=[" & CTemp & "]  FTemp=[" & FTemp & "]")
    
    ''optionally write the values to a file here
    	sw = new StreamWriter("Data/Pi2Temperature.log",True)
    	sw.writeLine(Now() & " -- " & CTemp & " - " & FTemp)
    
    ''update HomeSeer device here - use CTemp or FTemp as needed
    	hs.SetDeviceValueByRef(dref, FTemp, True)
    	hs.SetDeviceString(dref, "Pi2 Current Temp: " & FTemp.ToString("0.#") & "&deg F", True)
    
       Catch ex as Exception
    	hs.WriteLog("Pi2Temperature Error t=[" & t & "]",ex.Message)
       Finally
    	if(not sw is Nothing) then sw.Close
    	resp=Nothing
       End Try
    End Sub
    
    Public Function getFarenheit(ByVal c as Double) as Double
    	dim d as Double
    	d = c*9/5+32
    	return d
    End Function
    If you find any issues, let me know and I'll update the script in this thread.

    Enjoy!
    Last edited by rmasonjr; July 30, 2015, 10:53 AM. Reason: code
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    #2
    Thank you Rob.

    Watching the temps in the attic now climbing fast.

    ~# sudo cat temp
    Jul 30 10:44:02 Sensor 0 C: 40.31 F: 104.56
    Jul 30 10:44:03 Sensor 1 C: 36.06 F: 96.91 H: 38%

    ~# sudo cat temp
    Jul 30 11:02:02 Sensor 0 C: 41.00 F: 105.80
    Jul 30 11:02:03 Sensor 1 C: 37.59 F: 99.67 H: 35%



    Seeing this in the HS3 logs when running the script.

    Jul-30 10:43:08 AM Event Event test 1-Wire triggered by the event page 'Run' button.
    Jul-30 10:43:08 AM Event Event Trigger "test 1-Wire"
    Jul-30 10:43:08 AM Event Running script in background: /HomeSeer/scripts/Pi2Temperature.vb
    Jul-30 10:43:16 AM Pi2Temperature Error Array index is out of range.
    Last edited by Pete; July 30, 2015, 10:52 AM.
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

    HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
    HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

    Comment


      #3
      Your output from the shell command must be different than mine. I wonder if it is Raspbian?

      I edited the script above to add the reading to the error output. Can you update your script with the one above and run it again for me?
      HS4Pro on a Raspberry Pi4
      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

      HSTouch Clients: 1 Android

      Comment


        #4
        The output is simple and just:

        Jul 30 11:02:02 Sensor 0 C: 41.00 F: 105.80
        Jul 30 11:02:03 Sensor 1 C: 37.59 F: 99.67 H: 35%

        It is based on this configuration file which can be tweaked accordingly for any type of output.

        TTY /dev/ttyUSB0
        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 2
        ROM 0 0x28 0xCF 0xD8 0xF4 0x02 0x00 0x00 0xF5
        ROM 1 0x26 0x3B 0x3A 0xF5 0x00 0x00 0x00 0xBD

        Updated script and manually ran it. Here is the log output.

        Jul-30 11:19:06 AM Event Event test 1-Wire triggered by the event page 'Run' button.
        Jul-30 11:19:06 AM Event Event Trigger "test 1-Wire"
        Jul-30 11:19:06 AM Event Running script in background: /HomeSeer/scripts/Pi2Temperature.vb
        Jul-30 11:19:15 AM Pi2Temperature Error t=[] Array index is out of range.



        I am using the original RPi2 image that you posted for the Zee-2 except the RPi2 has a PiFace RTC clock and a ZWaveMe GPIO card in it.

        Linux ICS-RPi2-Zee 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 arm v7l
        Last login: Thu Jul 30 07:11:14 2015 from 192.168.244.230
        Uptime: 4 hours 25 minutes
        CPU Speed: 900 Mhz - Load Average: 1min 3% 5min 3% 15min 3% - Cores: 4
        Free Memory: 825 Mb
        Free Disk Space rootfs: 9.6G
        SD Card: Written 327M Read 0G
        Network Traffic eth0: Sent 91.8 MiB Received 25.5 MiB
        root@ICS-RPi2-Zee:~# uname -a
        Linux ICS-RPi2-Zee 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 arm v7l GNU/Linux
        root@ICS-RPi2-Zee:~# mono -V
        Mono JIT compiler version 3.12.1 (tarball Fri Mar 6 23:28:08 UTC 2015)
        Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. dub dub dub mono-project dot com
        TLS: __thread
        SIGSEGV: normal
        Notifications: epoll
        Architecture: armel,vfp+hard
        Disabled: none
        Misc: softdebug
        LLVM: supported, not enabled.
        GC: sgen
        - Pete

        Auto mator
        Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

        HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
        HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

        X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

        Comment


          #5
          Oh - I think I see what you are doing. You just need to read that "temp" file and get those into a HS device. Let me come up with something for you.

          My script above is for reading the Pi2's on-board temperature sensor.
          HS4Pro on a Raspberry Pi4
          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

          HSTouch Clients: 1 Android

          Comment


            #6
            Yup; doing the same thing though except your script reads the raw hardware value under dev.

            Thank-you Rob.
            - Pete

            Auto mator
            Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

            HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
            HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

            X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

            Comment


              #7
              Emailing you offline the new script...
              HS4Pro on a Raspberry Pi4
              54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
              Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

              HSTouch Clients: 1 Android

              Comment


                #8
                Thank-you Rob.

                Working well.

                Using a very old AAG combo sensor here from the early 2000's (?) and one metal ended cable sensor.

                BTW today OWFS and Digitemp 1-Wire is part of Ubuntu and the RPi2 builds. Tried it many years ago it is was a bit of an effort to get it going.

                The bit bang stuff using 3 GPIO pins works as well and would be ideal for one temperature sensor inside of the RPi2 case.

                Reviewing my stuff yesterday only using 3 GPIO pins with the two boards on the expansion pin stuff. This set up would be just pins to a shrunk tubing combo of a 1-wire temperature sensor and resistor.

                The USB / 9097U / Serial port 1-Wire device below came packaged (purchased a few of these a few years back) with two cabled temperature sensors (with metal ends), stereo cable splitter and extension cable. I cut one cable and used two wires for the AAG Humidity sensor (so it is running in parasitic mode).
                Attached Files
                Last edited by Pete; July 30, 2015, 02:50 PM.
                - Pete

                Auto mator
                Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

                HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                Comment


                  #9
                  HI. I'd like to try using some 1-wire temperature sensors on my HS3 ZEE, connected to the GPIO pin on the Pi. Is this possible on the Zee?

                  Anyone got a suitable shell script to read the DS18B20 sensors and then a Zee script to put the values into virtual devices.

                  Comment


                    #10
                    Attached is a drawing to get a DS18B20 1-Wire sensor connected to the GPIO pins on the RPi2. You will need to add one resistor.

                    Shut down HS3 for a bit while you do all of this - IE: disable upstart or cron running for HS3.

                    I am doing this today using a microrouter with an added i2c combo RTC/1-wire device and a bit of bit banging for one 1-wire temperature sensor such that I get a time sync and one temperature read from the 1-wire sensor soldered on the board.

                    It would be nice to modify the PiFace RTC to include one 1-Wire temperature sensor like this combo RTC that I am using for the microrouter running OpenWRT.



                    I am using a PiFace RTC for all of my RPi2's today. I looked for the schematic relating to the i2c setup with the PiFace RTC. I would like to volunteer to give it a try as I have a few of the 1-wire sensors from playing with this stuff.



                    The DS1307 Real Time Clock developed by one of our designers: Waiman. The module comes fully assembled and pre-programmed with the current time (ok, so it's our current time - MST). The included Lithium coin cell battery (CR1225 41mAh) will run the module for a minimum of 9 years (17 years typical) without external 5V power. The DS1307 is accessed via the I2C protocol.

                    Except the DS1307 real time clock, the module also integrate the I2C EEPROM chip(24C32) and the DS18B20 sensor interface. The I2C EEPROM makes it possible to save the sensor data easily without spending too much microcontroller source. And the DS18B20 interface with the pull-up resistor embeded will be helpful to extend temperature monitoring feature for your project.


                    I have no clue what the PiFace RTC is using today but it would be nice to be able to integrate one 1-wire temperature sensor to the PiFace RTC clock.




                    1 - add the following to /boot/config.txt
                    dtoverlay=w1-gpio

                    2 - reboot

                    3 - do the following

                    sudo modprobe wire
                    sudo modprobe w1-gpio
                    sudo modprobe w1-therm

                    cd /sys/bus/w1/devices
                    ls
                    cd 28-xxxx (change this to match what serial number pops up)
                    cat w1_slave

                    4 - You will see something like this:

                    Code:
                    pi@raspberrypi:~$ cat /sys/bus/w1/devices/10-00080234149b/w1_slave
                    
                    37 00 4b 46 ff ff 07 10 1e : crc=1e YES
                    
                    37 00 4b 46 ff ff 07 10 1e t=27312
                    5 - The response will either have a YES or NO at the end of the first line. If it is yes, then the temperature will be at the end of the second line, in 1/000 degrees C. So, in the example above the temperature is actually read as 27.312 degrees C.

                    6 - if the above works then add the following to /etc/modules such that it starts on boot.

                    # /etc/modules
                    w1-gpio pullup=1
                    w1-therm

                    If you have more than one sensor connected, you'll see multiple 28-xxx files. Each one will have the unique serial number so you may want to plug one in at a time, look at what file is created and label the sensor.

                    7 - Here I just utilize an off the shelf program to read the values and create a text file. (or you can utilize a python program). Then I use a VB script written by Rob to read the text file. You could write a VB script to read the values directly if you want.

                    8 - here is a little perl script / program to read one sensor and write a text file. Looking for a way to do this with DigiTemp. Not finding a way to use DigiTemp as it reads a serial port. May have better luck with OWFS. It is only one temperature sensor.


                    Here is a quickie perl script that you can pipe to a text file producing same format of file that I am using for Digitemp.

                    Code:
                    #!/usr/bin/perl
                    
                    $count = 0;
                    
                    open(INDEX, "cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves | tac|");
                    @index = <INDEX>;
                    close(INDEX);
                    
                    foreach (@index) {
                      chop;
                      $crc = "NO ";
                      while ($crc ne "YES") {
                        open(SENSOR, "cat /sys/bus/w1/devices/$_/w1_slave|");
                        @data = <SENSOR>;
                        close(SENSOR);
                        $crc = substr(@data[0], 36, 3);
                        $attempt++;
                        die if ($attempt == 25);
                      }
                      my $temp = (substr(@data[1], 29, 5)/1000.00);
                      my $fahr = ($temp*9.0/5.0)+32.00;
                      $date = `date "+%b %d %H:%M:%S"`;
                      chop $date;
                      print "$date Sensor $count C: $temp F: $fahr\n";
                      $count++;
                    }
                    Pipe it to a filename of your choice. Note I am using a humidity sensor so remove that part from Rob's VB script mentioned above.

                    ./logtemp > temp
                    May 19 22:14:46 Sensor 0 C: 16.5 F: 61.7
                    May 19 22:14:48 Sensor 1 C: 11.687 F: 53.0366

                    Here is what the digitemp output logfile looks like:

                    root@ICS-RPi2-Zee:~# cat temp
                    Jan 20 08:17:02 Sensor 0 C: 3.31 F: 37.96
                    Jan 20 08:17:03 Sensor 1 C: 0.81 F: 33.46 H: 76%

                    Tested the above perl script on my microrouter using a 1-wire temperature sensor on the gpio. Works fine.

                    root@ICS-GLiNet:~# perl temperature.pl
                    Jan 20 23:48:06 Sensor 0 C: 34.062 F: 93.3116




                    With this file you can just utilize Rob's VB to read it and create variables.
                    Attached Files
                    Last edited by Pete; February 5, 2016, 10:00 AM.
                    - Pete

                    Auto mator
                    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

                    HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                    HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                    Comment


                      #11
                      Great script. Thanks Rob!
                      HS Pro 3.0 | Linux Ubuntu 16.04 x64 virtualized under Proxmox (KVM)
                      Hardware: Z-NET - W800 Serial - Digi PortServer TS/8 and TS/16 serial to Ethernet - Insteon PLM - RFXCOM - X10 Wireless
                      Plugins: HSTouch iOS and Android, RFXCOM, BlueIris, BLLock, BLDSC, BLRF, Insteon PLM (MNSandler), Device History, Ecobee, BLRing, Kodi, UltraWeatherWU3
                      Second home: Zee S2 with Z-Wave, CT101 Z-Wave Thermostat, Aeotec Z-Wave microswitches, HSM200 occupancy sensor, Ecolink Z-Wave door sensors, STI Driveway Monitor interfaced to Zee S2 GPIO pins.

                      Comment


                        #12
                        Yup; here been using Rob's script since first updating the Zee-2.

                        Thank you Rob.

                        Tinkering some more here now. Looking at the schematic for the PiFace RTC board and will try to add a 1-Wire temperature sensor on it such that it gets a read from the inside of the RPi2 case.
                        - Pete

                        Auto mator
                        Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

                        HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                        HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                        X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                        Comment


                          #13
                          Thanks for the help, but in the end it was beyond my understanding. I don't know how to write Python programs, and I just can't work out what sort of Homeseer VB script I need to:
                          1. Read the temperature from 4 probes
                          2. Put those values into a device

                          I can get the sensors working on the Pi, and the slave files are getting updated with temperature values okay. For example:
                          cd /sys/bus/w1/devices
                          ls
                          cd 28-xxxxxxxxxxxx
                          cat w1_slave

                          Successfully displays this:
                          72 01 4b 46 7f ff 0e 10 57 : crc=57 YES
                          72 01 4b 46 7f ff 0e 10 57 t=23125

                          But what script do I need in Homeseer to periodically read the slave files, and update a virtual device with the temperature?

                          Comment


                            #14
                            You got it right Tarbat.

                            You can only do the temperature reads via GPIO with that W1 directory thing. You cannot use DigiTemp.

                            Personally here using the Digitemp program with a 1-wire USB hub plugged in to my RPi2. I am doing the GPIO 1-Wire W1 stuff on my test microrouter that I installed an RTC clock with a 1-wire temperature sensor. It is the same mechanism of reading the GPIO ports as you do on the RPi2 with a GPIO connected 1-wire sensor.

                            BTW make sure that your RPi2 has Perl installed. I think by default it is installed such that you do not have to install it.

                            1 - check to see if you have perl installed by typing
                            perl -v
                            2 - my Zee-2 shows:
                            perl -v

                            This is perl 5, version 14, subversion 2 (v5.14.2) built for arm-linux-gnueabihf-thread-multi-64int
                            (with 89 registered patches, see perl -V for more detail)

                            Copyright 1987-2011, Larry Wall

                            Perl may be copied only under the terms of either the Artistic License or the
                            GNU General Public License, which may be found in the Perl 5 source kit.

                            Complete documentation for Perl, including FAQ lists, should be found on
                            this system using "man perl" or "perldoc perl". If you have access to the
                            Internet, point your browser at http://www.perl.org/, the Perl Home Page.

                            The Perl script mentioned below just reads the values in the W1 directory and outputs them as a text line per sensor in the Digitemp format.
                            You do not have to modify the Perl script. Just direct the output to a text file wherever you want. It will do multiple 1-wire sensors.

                            You need two scripts. You can run the perl script as a cron job which continously updates the text file that you read with Rob's VB script or you can modify Rob's script above to run the perl script every time it does a read.

                            Earlier (corrected it) I said it was a Python script where I should have written that it is a Perl script.

                            Script #1 - this is a modded perl script that creates an identical file to the Digitemp application.

                            1 - SSH to your RPi2
                            2 - nano nameofperlscript
                            3 - save it to home directory
                            4 - test run the perl script by typing perl nameofperl script
                            5 - then do a perl w1.pl > w1
                            6 - w1 is the name of the file you put in to Rob's script above.
                            7 - configure a cron job to run it every minute or so IE: perl /path/to/nameofperlscript


                            Code:
                            #!/usr/bin/perl
                            
                            $count = 0;
                            
                            open(INDEX, "cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves | tac|");
                            @index = <INDEX>;
                            close(INDEX);
                            
                            foreach (@index) {
                              chop;
                              $crc = "NO ";
                              while ($crc ne "YES") {
                                open(SENSOR, "cat /sys/bus/w1/devices/$_/w1_slave|");
                                @data = <SENSOR>;
                                close(SENSOR);
                                $crc = substr(@data[0], 36, 3);
                                $attempt++;
                                die if ($attempt == 25);
                              }
                              my $temp = (substr(@data[1], 29, 5)/1000.00);
                              my $fahr = ($temp*9.0/5.0)+32.00;
                              $date = `date "+%b %d %H:%M:%S"`;
                              chop $date;
                              print "$date Sensor $count C: $temp F: $fahr\n";
                              $count++;
                            }
                            I will do a step by step for my GPIO connected temperature sensor so you can see what it is that needs to be done.

                            Here is the cron job running on my microrouter:

                            # execute every 5 minutes
                            */5 * * * * perl /root/temperature.pl > temp.txt

                            Here is the temp.txt file:

                            ~# cat temp.txt
                            Feb 05 09:20:01 Sensor 0 C: 34.375 F: 93.875

                            Make the change to Rob's VB here:

                            sr = new StreamReader("/root/temp.txt") ''point this to your temp file

                            OK just noticed that Rob's script above runs a bash script (which was what I am I doing with the DigiTemp application using a 1-wire hub).

                            You have to utilize the original script that I am using which just reads a text file and creates Homeseer 3 variables for the W1 GPIO 1-wire temperature sensor. Note that you can modify Rob's script above to run a perl script instead of a bash script and do the same. Noticed too that Rob's script writes to the HS3 log and a log file which is the temperature file. I am pretty sure that you can run a perl script inside of Rob's VB script such that mechanism would be the same and you do not need to run a cron job on the Perl script this way.
                            IE:

                            1 - put the perl script under the HS3 scripts directory - you do not need to edit it.
                            2 - put a line in Rob's script that runs the perl script

                            NOTE that this perl script just outputs a text file in the identical format that I have DigiTemp configured for. Only difference is that DigiTemp using one wire devices serially connected via a USB port and the W1Temp program is using a 1-wire device plugged in to the GPIO ports on the RPi2. Note too that DigiTemp does not work with a GPIO 1-wire temperature / humidity sensor on the RPi2; only the W1 program works this way.

                            Code:
                            Imports System.IO
                            ' 1WireTemp.vb - Rob Mason - 7/30/2015 - Free to use/modify. 
                            ' reads in the content of a temp file created by the 1-wire sensor
                            
                            Sub Main(parm as object) 
                               dim FTemp,CTemp,Humid as Double 
                               dim lin,t,h,x,n,s() as String 
                               dim sr as StreamReader 
                               dim sensor0_Temp_Ref as Integer = 260       [B] 'use your own device references [/B]
                               dim sensor1_Temp_Ref as Integer = 261 
                               dim sensor1_Humid_Ref as Integer = 262
                               
                               Try 
                                  [B]sr = new StreamReader("/root/temp")       ''point this to your temp file[/B]
                                    while(1) 
                                            lin=sr.ReadLine() 
                                            if(lin is nothing) then exit while
                                            if(lin.length()<=0) then exit while
                                            s = Split(lin,"Sensor ") 
                                            t = s(1) 
                                            n = left(t,t.indexOf(" ")).Trim ''contains sensor number
                                            s = Split(t,"C: ") 
                                            CTemp = CDBL(left(s(1),s(1).indexOf(" ")).Trim) 
                                            FTemp = getFarenheit(CTemp) 
                                            s = Split(t,"H: ") 
                                            if(s.length>1) then 
                                                    Humid=CDBL(left(s(1),s(1).indexOf("%")).Trim) 
                                            else 
                                                    Humid=0 
                                            end if
                                          ''hs.writeLog("debug","t=[" & t & "]  n=[" & n & "] CTemp=[" & CTemp & "] FTemp=[" & FTemp & "] Humid=[" & Humid & "]")
                                            Select case n 
                                                    case 0 
                                                    ''update HomeSeer here with the device references above 
                                                    hs.setDeviceValueByRef(sensor0_Temp_Ref,FTemp,True)     ''change to CTemp if you want Celsius 
                                                    hs.setDeviceLastChange(sensor0_Temp_Ref,Now()) 
                                                    hs.setDeviceString(sensor0_Temp_Ref,FTemp & " degrees",False) 
                                                    case 1 
                                                    hs.setDeviceValueByRef(sensor1_Temp_Ref,FTemp,True)     ''change to CTemp if you want Celsius 
                                                    hs.setDeviceLastChange(sensor1_Temp_Ref,Now()) 
                                                    hs.setDeviceString(sensor1_Temp_Ref,FTemp & " degrees",False)
                                                    if(humid>0) then 
                                                            hs.setDeviceValueByRef(sensor1_Humid_Ref,humid,True)    ''change to CTemp if you want Celsius
                                                            hs.setDeviceLastChange(sensor1_Humid_Ref,Now()) 
                                                            hs.setDeviceString(sensor1_Humid_Ref,humid & "%",False) 
                                                    end if
                                            End Select 
                                    End While
                            
                            
                               Catch ex as Exception 
                                  hs.WriteLog("1WireTemp Error","lin=[" & lin & "]    " & ex.Message) 
                               Finally 
                                  if(not sr is Nothing) then sr.close() 
                               End Try 
                            End Sub
                            Public Function getFarenheit(ByVal c as Double) as Double 
                               dim d as Double 
                               d = c*9/5+32 
                               return d 
                            End Function
                            Last edited by Pete; February 5, 2016, 10:54 AM.
                            - Pete

                            Auto mator
                            Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb

                            HS4 Pro - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                            HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                            X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                            Comment


                              #15
                              I came up with this simple script to read the 1-wire temperature sensors. Script is for just one sensor at the moment.

                              Code:
                               
                               Sub Main(parms As Object)
                                  dim valid as Double
                                  dim tpos as Double
                                  dim w1file as string
                                  dim resp as string
                                  dim filename as string = "/sys/devices/w1_bus_master1/28-04159128c3ff/w1_slave"
                                  w1file = My.Computer.FileSystem.ReadAllText(filename)
                                  valid = w1file.IndexOf("YES")
                                  If valid > 0 Then
                                      tpos = w1file.IndexOf("t=")
                                      If tpos > 0 Then
                                          resp = Mid(w1file, tpos + 3, 5) / 1000
                                      End If
                                  End If
                                  hs.SetDeviceValueByRef(67, resp, True)
                                  hs.WriteLog(resp,w1file)
                              End Sub
                              No need for chron jobs, perl scripts, etc. Just a simple VB script in Homeseer.

                              Comment

                              Working...
                              X