I'm new to programming esp boards but I'dont know if problem is with my wiring or the code.
I've connected sensor to the GND and D02 and when the doors are closed it should open link and go to deep sleep. Instead it stays open all the time.
Here is the code:
Code: Select all
import os import urequests import machine import time from time import sleep from machine import Pin def connect(): import network ssid = "" password = "" station = network.WLAN(network.STA_IF) if station.isconnected() == True: print("Already connected") return station.active(True) station.connect(ssid, password) while station.isconnected() == False: pass print("Connection successful") print(station.ifconfig()) connect() time.sleep(1) p2 = Pin(2, Pin.IN) while p2.value()==1: response=urequests.post("http://somer_link") time.sleep(10) else: response=urequests.post("http://other_link") time.sleep(5) machine.deepsleep()