Once this constitution is done, go ahead and wire it up, as shown here:
Once that is set, it is time for us to write the following code on to our Raspberry Pi:
import Adafruit_DHTimport datetimeimport RPi.GPIO as GPIOimport timeimport numpy as npimport pandas as pdimport Adafruit_DHTfrom sklearn.neighbors import KNeighborsClassifierGPIO.setmode(GPIO.BCM)GPIO.setwarnings(False)fan = 22light = 23sw1 = 13sw2 = 14GPIO.setup(led1,GPIO.OUT)GPIO.setup(led2,GPIO.OUT)GPIO.setup(sw1,GPIO.IN)GPIO.setup(sw2,GPIO.IN)sensor = 11pin = 2f = open("dataset.csv","a+")count = 0while count < 50: data = "" H = datetime.datetime.now().strftime('%H') ...