ESP32 DHT22 IFTTT : Différence entre versions

(Page créée avec « {{Tuto Details |Description=<translate>ESP32</translate> |Area=Electronics |Type=Creation |Difficulty=Medium |Duration=1 |Duration-type=hour(s) |Cost=0 |Currency=USD ($) }... »)
 
Ligne 1 : Ligne 1 :
 
{{Tuto Details
 
{{Tuto Details
|Description=<translate>ESP32</translate>
+
|Description=<translate>Send DHT22 temperature and humidity values to a google sheet through ESP32 and Webhooks</translate>
 
|Area=Electronics
 
|Area=Electronics
 
|Type=Creation
 
|Type=Creation
Ligne 15 : Ligne 15 :
 
{{Tuto Step
 
{{Tuto Step
 
|Step_Title=<translate>Install Thonny or Other Python IDLE</translate>
 
|Step_Title=<translate>Install Thonny or Other Python IDLE</translate>
|Step_Content=<translate>*Go to [[www.thonny.com]]
+
|Step_Content=<translate>*Go to https://thonny.org/
 
*Download
 
*Download
 
*Install</translate>
 
*Install</translate>
|Step_Picture_00=Polar01d_facedetect_py.png
+
|Step_Picture_00=ESP32___DHT22___IFTTT_Thonny__Python_IDE_for_beginners.png
 
}}
 
}}
 
{{Tuto Step
 
{{Tuto Step
 
|Step_Title=<translate>Setup Circuit</translate>
 
|Step_Title=<translate>Setup Circuit</translate>
|Step_Content=<translate></translate>
+
|Step_Content=<translate>+ pin on DHT22 to VCC on ESP
|Step_Picture_00=Distributeur_de_croquette_chat_arduino_20210115_223203.jpg
+
 
 +
out pin on DHT22 to GPIO pin 15 on ESP(can change depending on code)
 +
 
 +
- pin on DHT22 to GND on ESP</translate>
 +
|Step_Picture_00=ESP32___DHT22___IFTTT_Untitled_Sketch_fzz_-_Fritzing_-__Breadboard_View_.png
 +
|Step_Picture_01=ESP32___DHT22___IFTTT_Untitled_Sketch_fzz_-_Fritzing_-__Schematic_View_.png
 +
}}
 +
{{Tuto Step
 +
|Step_Title=<translate>Source Code for thonny</translate>
 +
|Step_Content=<translate><syntaxhighlight lang="python3" start="1">
 +
import network
 +
import urequests as requests
 +
from machine import Pin
 +
from dht import DHT22
 +
from time import sleep
 +
wifi_ssid = "WIFI NAME"
 +
wifi_password = "WIFI PASS"
 +
 
 +
 
 +
webhook_url = "https://maker.ifttt.com/trigger/esp32/with/key/<insert api key here>"
 +
 
 +
 
 +
sta_if = network.WLAN(network.STA_IF)
 +
sta_if.active(True)
 +
 
 +
if sta_if.isconnected() == False:
 +
    sta_if.connect(wifi_ssid, wifi_password)
 +
 
 +
while sta_if.isconnected() == False:
 +
    #sta_if = network.WLAN(network.STA_IF)
 +
    #sta_if.active(True)
 +
    #sta_if.connect(wifi_ssid, wifi_password)
 +
    sleep(1)
 +
    print(".", end = "")
 +
 
 +
dht22 = DHT22(Pin(15))
 +
 
 +
while True:
 +
    dht22.measure()
 +
    temperature = dht22.temperature()
 +
    humidity = dht22.humidity()
 +
    temp = temperature * 9/5 + 32
 +
    url = webhook_url + "?value1=" +  str(temp) + " F" + "&value2=" + str(humidity) + "%"
 +
    try:
 +
        r = requests.get(url)
 +
        print(r.text)
 +
    except Exception as e:
 +
        print(e, "error")
 +
    sleep(30)
 +
 
 +
</syntaxhighlight><br /></translate>
 +
|Step_Picture_00=ESP32___DHT22___IFTTT_Thonny__-___Users_sidharthsandeep_DHT22_Code_public_py_____13___6.png
 
}}
 
}}
 
{{Notes
 
{{Notes
Ligne 29 : Ligne 80 :
 
}}
 
}}
 
{{PageLang
 
{{PageLang
 +
|Language=en
 
|SourceLanguage=none
 
|SourceLanguage=none
 
|IsTranslation=0
 
|IsTranslation=0
|Language=en
 
 
}}
 
}}
 
{{Tuto Status
 
{{Tuto Status
 
|Complete=Draft
 
|Complete=Draft
 
}}
 
}}

Version du 14 janvier 2023 à 16:36

Auteur avatarSid | Dernière modification 15/01/2023 par Disisid

Pas encore d'image

Send DHT22 temperature and humidity values to a google sheet through ESP32 and Webhooks
Difficulté
Moyen
Durée
1 heure(s)
Catégories
Électronique
Coût
0 USD ($)

Introduction

ESP32 connected to DHT22, to read temperature and humidity

Matériaux

Outils

Étape 1 - Install Thonny or Other Python IDLE




Étape 2 - Setup Circuit

+ pin on DHT22 to VCC on ESP

out pin on DHT22 to GPIO pin 15 on ESP(can change depending on code)

- pin on DHT22 to GND on ESP



Étape 3 - Source Code for thonny

import network
import urequests as requests
from machine import Pin
from dht import DHT22
from time import sleep
wifi_ssid = "WIFI NAME"
wifi_password = "WIFI PASS"


webhook_url = "https://maker.ifttt.com/trigger/esp32/with/key/<insert api key here>"


sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)

if sta_if.isconnected() == False:
    sta_if.connect(wifi_ssid, wifi_password)

while sta_if.isconnected() == False:
    #sta_if = network.WLAN(network.STA_IF)
    #sta_if.active(True)
    #sta_if.connect(wifi_ssid, wifi_password)
    sleep(1)
    print(".", end = "")

dht22 = DHT22(Pin(15))

while True:
    dht22.measure()
    temperature = dht22.temperature()
    humidity = dht22.humidity()
    temp = temperature * 9/5 + 32
    url = webhook_url + "?value1=" +  str(temp) + " F" + "&value2=" + str(humidity) + "%"
    try:
        r = requests.get(url)
        print(r.text)
    except Exception as e:
        print(e, "error")
    sleep(30)




Commentaires

Draft