1

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

amx5
  • 11
  • 2
  • Hi, welcome to SO. I would recommend only asking one question at a time, as you are likely to get better results - feel free to post multiple, independent questions. – kenny_k Aug 14 '17 at 14:16
  • Thank you, I apologise for being overzealous haha – amx5 Aug 14 '17 at 14:28
  • No problem. If you haven't already done so, please [take the tour](https://stackoverflow.com/tour) and read [how to ask](https://stackoverflow.com/help/how-to-ask) and [how to create a minimal, verifiable example](https://stackoverflow.com/help/mcve) for better results using this site. Good luck! – kenny_k Aug 14 '17 at 14:29
  • _"store the temperature/humidity data "_ , go with `XML` read [creating-a-simple-xml-file](https://stackoverflow.com/questions/3605680/creating-a-simple-xml-file-using-python) – stovfl Aug 14 '17 at 20:39

0 Answers0