Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Blueprints

You're reading from   Raspberry Pi Blueprints Design and build your own hardware projects that interact with the real world using the Raspberry Pi

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784392901
Length 284 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Raspberry Pi Pirate Radio FREE CHAPTER 2. Portable Speaker System 3. Mini Retro Arcade Cabinet 4. GPS-enabled Time-lapse Recorder 5. Home Theater PC 6. Outdoor Weather Station 7. Home Security System 8. Remote-operated Robotic Arm 9. Magic Mirror 10. Bottle Xylophone Index

Taking readings from the sensors


Now that our app is set up, we need to configure the Pi to regularly take readings from the sensors and update the database with the latest weather conditions. To do this, we will use a Python script that will communicate with the DHT11/22 and BMP180 sensors using their Adafruit libraries and the Maplin sensors using the pySerial library and perform the following steps:

  1. We must first install the pySerial library to be used by the script. All the other libraries used are either installed by default or were installed when we had set up the DHT11/22 and BMP130 sensors:

    sudo pip install pyserial
    
  2. Next, we will modify the rc.local file to perform the script run when the Pi boots:

    sudo nano /etc/rc.local
    
  3. Here, add the following line to the file:

    python /home/pi/sensor_manager.py --database /home/pi/weather_station_webapp/weather.db --poll-interval 10 --submit-interval 600 &

    The output should look as shown in the following screenshot:

    Note

    The interval at which the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image