I'm looking for some guidance, any help would be greatly appreciated.
I recently picked up a raspberry pi 3 B to learn about home automation.
I'm new to coding and messing about with hardware.
I've managed to put together, using code I've found online, a python script with the help of the adafruit library, that displays temperature and humidity from an am2302 sensor and then runs a standard 5v fan for 5 seconds.
QN How do I call the fan to run dependent on temperature or humidity? my goal is to have several fans dependent on this single sensor.
QN How can I ask a script to run a different script located elsewhere if a temperature of humidity level is met?
Here is my code so far:
!/usr/bin/python
import time
import Adafruit_DHT
import RPi.GPIO as GPIO
import Adafruit_DHT
sensor = Adafruit_DHT.AM2302
pin = 5
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity))
else:
print('Failed to get reading. Try again!')
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.OUT)
GPIO.output(18, 1)
time.sleep(5)
GPIO.output(18, 0)
GPIO.cleanup()
Another goal is to also store the temperature/humidity data so that it can be viewed online, assuming I've set up a web server and wordpress,
QN What will I need to do, to get the sensor data online and into a chart?
I apologise in advance if these questions are vague in any way, I'm still learning good form when it comes to phrasing these types of inqueries. What would be good to learn about python at the moment? Any guidance on any part of the text would be appreciated.
Kind regards