Bonjour à vous,
je repris a partir du début avec ma micro carte SD
et j'arrive pas a avoir les résultas sur la page DOMOTICZ
voici des info pour mieux trouver mon problème et comprendre pourquoi aussi:
Sur ma page Domoticz j'ai 50% avec 0 Celsius pour mon AM 2302
je les branché sur la pin 18 du Raspberry Pi soit le GPIO 24
J'execute un fonction pour savoir si mon AM2302 est bien branché et voici la réponse que je reçois sur une page WEB
http://10.192.17.104:8080/json.htm?type=devices&ridx=2
{
"ActTime" : 1566507843,
"app_version" : "4.10717",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "24.2 C",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 2,
"HardwareName" : "18B20",
"HardwareType" : "1-Wire (System)",
"HardwareTypeVal" : 12,
"HaveTimeout" : false,
"ID" : "AAAF",
"LastUpdate" : "2019-08-22 17:00:39",
"Name" : "Temp TS2000",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "LaCrosse TX3",
"Temp" : 24.199999999999999,
"Timers" : "false",
"Type" : "Temp",
"TypeImg" : "temperature",
"Unit" : 175,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "1",
"trend" : 1
},
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "0.0 C, 50 %",
"Description" : "",
"DewPoint" : "-9.20",
"Favorite" : 1,
"HardwareID" : 3,
"HardwareName" : "DHT",
"HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal" : 15,
"HaveTimeout" : false,
"Humidity" : 50,
"HumidityStatus" : "Comfortable",
"ID" : "14052",
"LastUpdate" : "2019-08-22 16:27:41",
"Name" : "DHT",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "THGN122/123/132, THGR122/228/238/268",
"Temp" : 0.0,
"Timers" : "false",
"Type" : "Temp + Humidity",
"TypeImg" : "temperature",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "2",
"trend" : 0
}
],
"status" : "OK",
"title" : "Devices"
}
et Voici mon script qui est dans
/home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py
et voici mon script
#!/usr/bin/python
# -*- coding: latin-1 -*-
# basé sur le script Adafruit et adapté pour Domoticz
# Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import os
import sys
import Adafruit_DHT
from requests.auth import HTTPBasicAuth
import requests
############# Parametres #################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# les parametres de Domoticz
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
domoticz_ip='10.192.17.104'
domoticz_port='8080'
user='pi'
password='********'
domoticz_idx=2
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# les parametres du DHT
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# sensor est 11,22,ou 2302
# pin est le numero d la pin que vous avez cablée
sensor=2302
pin=18
############# Fin des parametres #################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# le fomat pour la temp hum est celui ci
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT
def maj_widget(val_url):
requete='http://'+domoticz_ip+':'+domoticz_port+val_url
#print requete
r=requests.get(requete,auth=HTTPBasicAuth(user,password))
if r.status_code != 200:
print "Erreur API Domoticz"
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}* Humidity={1:0.1f}%'.format(temperature, humidity))
# l URL Domoticz pour le widget virtuel
url='/json.htm?type=command¶m=udevice&idx='+str(domoticz_idx)
url+='&nvalue=0&svalue='
url+=str('{0:0.1f};{1:0.1f};2').format(temperature, humidity)
#print url
maj_widget(url)
else:
print('Probleme avec la lecture du DHT. Try again!')
sys.exit(1)
et dans CRONTAB
j'ai bien mit l"execution au 5 Minutes pour ne pas a avoir a attendre présentement
plus tard je vais le mettre a 10 minutes par la suite
# mettre à la fin du fichier exécution du script au 5 minutes:
*/5 * * * * /home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py
Merci a vous tous si vous pouvez me dire ou est mon légendaire problème je crois bien
Luc