ESP32 DHT22 IFTTT : Différence entre versions

Ligne 112 : Ligne 112 :
 
|Step_Content=<translate>Once you have finished all the previous steps, hit continue on the applet page</translate>
 
|Step_Content=<translate>Once you have finished all the previous steps, hit continue on the applet page</translate>
 
|Step_Picture_00=ESP32___DHT22___IFTTT_Create_-_IFTTT_continue.png
 
|Step_Picture_00=ESP32___DHT22___IFTTT_Create_-_IFTTT_continue.png
 +
|Step_Picture_00_annotation={"version":"2.4.6","objects":[{"type":"image","version":"2.4.6","originX":"left","originY":"top","left":0,"top":0,"width":800,"height":616,"fill":"rgb(0,0,0)","stroke":null,"strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":0.75,"scaleY":0.75,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"crossOrigin":"","cropX":0,"cropY":0,"src":"https://wikifab.org/images/thumb/6/64/ESP32_DHT22_IFTTT_Create_-_IFTTT_continue.png/800px-ESP32_DHT22_IFTTT_Create_-_IFTTT_continue.png","filters":[]},{"type":"wfline","version":"2.4.6","originX":"center","originY":"center","left":370,"top":239.5,"width":138,"height":1,"fill":"rgba(255,0,0,0)","stroke":"#000000","strokeWidth":4,"strokeDashArray":null,"strokeLineCap":"round","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"x1":-69,"x2":69,"y1":0.5,"y2":-0.5},{"type":"wfarrow2circle","version":"2.4.6","originX":"center","originY":"center","left":301,"top":240,"width":16,"height":16,"fill":"#aaa","stroke":"#666","strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":0.5,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"radius":8,"startAngle":0,"endAngle":6.283185307179586},{"type":"wfarrow2circle","version":"2.4.6","originX":"center","originY":"center","left":439,"top":239,"width":16,"height":16,"fill":"#aaa","stroke":"#666","strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":0.5,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"radius":8,"startAngle":0,"endAngle":6.283185307179586},{"type":"wfline","version":"2.4.6","originX":"center","originY":"center","left":370.5,"top":243,"width":137,"height":2,"fill":"rgba(255,0,0,0)","stroke":"#000000","strokeWidth":4,"strokeDashArray":null,"strokeLineCap":"round","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"x1":-68.5,"x2":68.5,"y1":1,"y2":-1},{"type":"wfarrow2circle","version":"2.4.6","originX":"center","originY":"center","left":302,"top":244,"width":16,"height":16,"fill":"#aaa","stroke":"#666","strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":0.5,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"radius":8,"startAngle":0,"endAngle":6.283185307179586},{"type":"wfarrow2circle","version":"2.4.6","originX":"center","originY":"center","left":439,"top":242,"width":16,"height":16,"fill":"#aaa","stroke":"#666","strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":0.5,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"radius":8,"startAngle":0,"endAngle":6.283185307179586},{"type":"wfline","version":"2.4.6","originX":"center","originY":"center","left":385,"top":245,"width":100,"height":0,"fill":"rgba(255,0,0,0)","stroke":"#000000","strokeWidth":4,"strokeDashArray":null,"strokeLineCap":"round","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"x1":-50,"x2":50,"y1":0,"y2":0},{"type":"wfarrow2circle","version":"2.4.6","originX":"center","originY":"center","left":335,"top":245,"width":16,"height":16,"fill":"#aaa","stroke":"#666","strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":0.5,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"radius":8,"startAngle":0,"endAngle":6.283185307179586},{"type":"wfarrow2circle","version":"2.4.6","originX":"center","originY":"center","left":435,"top":245,"width":16,"height":16,"fill":"#aaa","stroke":"#666","strokeWidth":0,"strokeDashArray":null,"strokeLineCap":"butt","strokeDashOffset":0,"strokeLineJoin":"miter","strokeMiterLimit":4,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":0.5,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"radius":8,"startAngle":0,"endAngle":6.283185307179586}],"height":462,"width":600}
 
}}
 
}}
 
{{Tuto Step
 
{{Tuto Step

Version du 14 janvier 2023 à 17:44

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

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 - Setup IFTTT

Go to https://ifttt.com/join

Create an account






Étape 4 - Create a new applet

First, click create in the upper right hand corner






Étape 5 - set up applet

Then, hit Add next to IF THIS




Étape 6 - Select webhooks

Once you are on choose a service, type in Webhooks in the search bar and click Webhooks




Étape 7 - Select request type

On webhooks, select receive a web request




Étape 8 - Set up Webhooks Account

- If you already have a webhooks account, skip this step


Otherwise, click the connect button and follow the steps on their website to create a webhooks account




Étape 9 - Name event for trigger

Name the event for the trigger esp32 (it is case sensitive so be careful)




Étape 10 - Set up reaction

Once the trigger is set up, click Add next to Then That




Étape 11 - Select google sheets

In the search bar, search sheets and click google sheets




Étape 12 - Set up sheets

Select Add row to spreadsheet




Étape 13 - Connect to sheets

Click the Connect button




Étape 14 - Sign in using gmail

Use your gmail to sign in to sheets




Étape 15 - Configure spreadsheet

Select all the values you want returned to the spreadsheet, along with the path the sheet has to follow in your drive



Étape 16 - Finish applet

Once you have finished all the previous steps, hit continue on the applet page




Étape 17 - Name applet

Rename the applet to an appropriate name




Étape 18 - Get API key

Select the Webhooks icon on the finished page




Étape 19 - Go to documentation

Click documentation on the webhooks page




Étape 20 - Get API key

Once you get onto this page, copy the api key and URL to paste into the code




Étape 21 - Source Code for thonny (insert api key and URL from previous step)

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)




Étape 22 - View output in spreadsheet

Go to whichever path you set the spreadsheet to in your drive




Commentaires

Draft