Page 1 of 1

Raspberry pi + nethome + onewire temp howto!

Posted: Fri Feb 06, 2015 10:08 am
by Nasty76
Ok i write there some example script how i get nethome onewire temp sensors , i use perl script below this text to sent onewire temp to nethome udp packet i have configure that upm temp sensor same code where my script sent this , of course this example think you can read onewire temps in pi command line , there is good tuturials on net how get this to work.

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
#THERE IS SECTION WHERE YOU CONFIGURE YOUR ONEWIRE TEMP SENSOR CODE!
my  $device = "10-0008028fd655";


    my $ret = 9999; # default to return 9999 (fail)

    my $sensordata = `cat /sys/bus/w1/devices/$device/w1_slave 2>&1`;
#    print "Read: $sensordata";


   if(index($sensordata, 'YES') != -1) {
      #fix for negative temps from http://habrahabr.ru/post/163575/
      $sensordata =~ /t=(\D*\d+)/i;
      #$sensor_temp =~ /t=(\d+)/i;
      $sensordata = (($1/1000));
      $ret = $sensordata*1000;
#SENT SENSOR DATA TO NETHOME change peerport to match you udp comminaction port what you create nethome and peeraddr to match your pi ip address if you run them same machine u can use 127.0.0.1 
my $sock = IO::Socket::INET->new(
    Proto    => 'udp',
    PeerPort => 8005,
    PeerAddr => '127.0.0.1',
) or die "Could not create socket: $!\n";
#THERE YOU NEED ADJUST UPM.DeviceCOde,X,HouseCode,X section to match your upm sensor in nethome
print $sock "event,UPM_Message,Direction,In,UPM.DeviceCode,2,UPM.HouseCode,1,UPM.Primary,$ret,UPM.Secondary,122,UPM.SequenceNumber,0\n"  or die "Sen$


   } else {

   }
i autoload modules via /etc/modules example nano /etc/modules and add this lines there

Code: Select all

# 1-Wire devices
w1-gpio
# 1-Wire thermometer devices
w1-therm
after that remember save file and after reboot if all go ok you get autoload onewire modules and that perl script work.
then when i get all single temps to nethome i make one sh file where i call my scripts like

Code: Select all

#!/bin/bash
/opt/nethome/onewiretemp/makkaritempu.pl
sleep 2
/opt/nethome/onewiretemp/olkkaritempu.pl
sleep 2
/opt/nethome/onewiretemp/ulkotempu.pl
sleep 2
/opt/nethome/onewiretemp/pi.pl
Ofc someone think well not want use own script to one device and mod script like perl search $tempsensor in linux and read them and sent them nethome that work but if you add sensors there there is no quarantee that logic keep same , my first script was that and some times temps go wrong nethome items , so modded manual that onewire device name and now i know i get allways my bedroom temp to bedroom nethome item :D

Re: Raspberry pi + nethome + onewire temp howto!

Posted: Fri Feb 13, 2015 11:25 pm
by Nasty76
New image in raspberry something again changed not working modprobe w1-*
need make next nano /boot/config.txt
end of file add next line:
dtoverlay=w1-gpio,gpiopin=4changes

again I can read my onewire line.

Re: Raspberry pi + nethome + onewire temp howto!

Posted: Tue Feb 24, 2015 7:29 pm
by Nasty76
Picture puzzle find raspberry pi below image
Image

Oh my old 100mb/s switch hhmmmm....





Image
Hehe there is hiding Raspberry pi , onewire master chip , and internal power input system.

Last port my switch working powering pi , and network , i use this http://www.verkkokauppa.com/fi/product/ ... yottolaite[/url] to push usb charger power my network cable wich go raspberry , I cut one charger cord and find old power adaptor where connect is same than poe input plug. now solder usb charger cord to plug wich go poe input plug , after that I cut one network cable find spots in old switch mainboard solder wires correct place and data network is ready, find pins where come power , to power injector , solder correct usb cable wires there and data power line is ready.


Temp sensor is this kinda system
Image
Look carefull red jumper wire , that is nice feature. All know onewire bus need to be one line if want nice and good working , I have situation where onewire pi is middle of house and I need 3, diferent line to get tempsensors nice , so I wire that system like this:
old switch port 1 find pins orange , orange/white , green,green/white.
Orange = 3.3V , Orange/WHITE = ground this is wired all port separate then , lan 1 port green is onewire data , that go direct in sensor with line Green , and jump back my switch Green/white , then Green/white line jump port 2 pin GREEN. so now I have onewire line which are connected correct.
Only minus what I think is you lost one old switch , you need cut working usb cable and old poweradaptor plug, and onewire line come 2x length because data channel return in sensor side back to homepoint.
Warning you need cut of resistors and other stuff in old switch circuit board if there is any and multimeter , twice nothing is connected where not to be , meaning 3.3v ground not are connected etc.
and remember cut circuit board channels if they come somewhere not meant to be , my self I need cut last port wiring in mainboard because that was some how connected port 8

Re: Raspberry pi + nethome + onewire temp howto!

Posted: Tue Feb 24, 2015 8:58 pm
by stefangsbb
Really nice arrangement! I have been thinking about doing something similar with an old DVD-Player.

Re: Raspberry pi + nethome + onewire temp howto!

Posted: Tue Feb 24, 2015 9:20 pm
by Nasty76
Thank you Sir , Thank You. I wanna make that onewire system in switch box , now I can use standard rj-45 wires to wiring my temp sensors. Next project is burned airam sono radar lamp , i yesterday testing is that motion sensor are ok , after power side burning and i get digital signal there out. but this more new topic :P. how operate lamp via physic buttons via remote raspi gpio :D