Used for a Rashberry PI sensor. The goal is to setup a simple program that polls a sensor installed on a rasberry Pi
This assumes the following
- Rasbian is installed on the Raspberry Pi
- Adafruit AM2302 (wired DHT22) temperature-humidity sensor (ADA393) is installed on pin 18
- A mongoDB instance is setup
- Install Python 2.6/2.7
sudo apt-get update
sudo apt-get install build-essential python-dev
sudo apt-get install python-pip
- Install Adafruit Python DHT Sensor Library
pip install Adafruit_Python_DHT
- Install PyMongo
pip install pymongo
- Set up dbconfig.py
-
variable name Purpose Notes MONGO_DB_HOST URL of host MONGO_DB_PORT Mongo DB Port MONGO_DB_NAME Mongo DB Name MONGO_DB_USER_NAME Mongo UN MONGO_DB_PASSWORD Mongo Password MONGO_DB_STATS_COLLECTION Mongo Collection Name SENSOR_LOCATION Location Of the Sensor Ex: Basement
-
- Setup cron job to run sensor
- Edit current Cron jobs
sudo crontab -e
- Set Polling time
- Note the polling time should not be faster then every 2 seconds
- This example conjob does it every 5 mins
*/5 * * * * sudo python /home/pi/temperatureHumidSensor/sensorPoll.py
- Edit current Cron jobs