(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 | + | |Step_Content=<translate>*Go to https://thonny.org/ |
*Download | *Download | ||
*Install</translate> | *Install</translate> | ||
− | |Step_Picture_00= | + | |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= | + | |
+ | 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 | ||
− | |||
}} | }} | ||
{{Tuto Status | {{Tuto Status | ||
|Complete=Draft | |Complete=Draft | ||
}} | }} |
Auteur Sid | Dernière modification 15/01/2023 par Disisid
Pas encore d'image
Creation
+ 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
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)
en none 0 Draft
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #