Get DHT value without IP

Moderator: leecollings

Post Reply
doodoovane
Posts: 11
Joined: Friday 11 December 2015 3:15
Target OS: Raspberry Pi / ODroid
Domoticz version: v2.3530
Location: French Polynesia
Contact:

Get DHT value without IP

Post by doodoovane »

Hello,

First of all, be sure that I feel sorry for my bad english. I'll do my best :D
I'm trying to get my Rpi running Domoticz with a DHT22 wired on the GPIO4 without any connexion.
Let me explain: to get my values up to date in domoticz from the sensor, i've found a script that use json to send Temperature humidity values to Domoticz IP. The problem is that if the Rpi change his IP or lose the connexion the DHT isn't updated in Domoticz anymore and so are the events related.

#!/bin/sh
# Domoticz server
SERVER="192.168.0.29:8080"
# DHT IDX
# le numero de l4IDX dans la liste des dispositifs Domoticz
DHTIDX="1"
DHTIDX2="2"
DHTIDX3="3"
DHTIDX4="4"
#DHTPIN
# LE GPIO ou est connecte le DHT11
DHTPIN="4"
# si vous avez un DHT22 modifiez plus bas sur la ligne Adafruit_DHT 11 par Adafruit_DHT 22
# TMPFILE : chemin pour fichier temporaire a placer dans le RAMDRIVE pour eviter les
# ecritures sur la SD card
# sinon chemin ou sera ecrit le fichier contenant les temperature
# /tmp/temper.txt est un bon choix si pas de RAMDRIVE installe
# consultez www.easydomoticz.com pour tout savoir
TMPFILE="/var/tmp/temper.txt"
TEMP=""

until [ -n "$TEMP" ] ; do
sleep 5
sudo nice -20 Adafruit_DHT 22 $DHTPIN > $TMPFILE
TEMP=$(cat $TMPFILE|grep Temp |awk '{print $3}')
done

TEMP=$(cat $TMPFILE|grep Temp |awk '{print $3}')
HUM=$(cat $TMPFILE |grep Temp |awk '{print $7}')

# Send data
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TEMP;$HUM;2"
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX2&nvalue=0&svalue=$TEMP"
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX3&nvalue=0&svalue=$HUM"
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=command&param=udevice&idx=$DHTIDX4&nvalue=0&svalue=$HUM"
TEMP=""
HUM=""

Is there any way for me to get this work without the need of any connexion?

Thank you for your help
antwan
Posts: 116
Joined: Saturday 13 July 2013 13:28
Target OS: Linux
Domoticz version: Latest
Location: Hilversum, The Netherlands
Contact:

Re: Get DHT value without IP

Post by antwan »

Change the server ip address to: 127.0.0.1:8080
Rasp Pi 2B: 3x DS18S20 (1-wire), BME280 (i2c)
Cubietruck 1: Aeotec Z-Wave+, RFXtrx433XL+P1, RFXtrx868, TE923 display, SolarEdge API
Cubietruck 2: Aeotec Z-Wave, Voltcraft CO-20
doodoovane
Posts: 11
Joined: Friday 11 December 2015 3:15
Target OS: Raspberry Pi / ODroid
Domoticz version: v2.3530
Location: French Polynesia
Contact:

Re: Get DHT value without IP

Post by doodoovane »

Thank you it works perfectly!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest