Book Image

Raspberry Pi Home Automation with Arduino - Second Edition

By : Andrew K. Dennis
Book Image

Raspberry Pi Home Automation with Arduino - Second Edition

By: Andrew K. Dennis

Overview of this book

Table of Contents (16 chapters)
Raspberry Pi Home Automation with Arduino Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Temperature Storage – Setting Up a Database to Store Your Results
Index

Database updates


On your Raspberry Pi, use the following command to connect to the SQLite3 database that you created in Chapter 4, Temperature Storage – Setting Up a Database to Store Your Results:

sqlite3 control.db

We are now going to add a humidity column. Run the following SQL statement:

ALTER TABLE Temperature ADD COLUMN Humidity FLOAT(8);

This code modifies the temperature table and adds a humidity column. The column is set to accept values in float format. Next, we need to add the basement/shed to our room table:

INSERT INTO RoomDetails (Room) VALUES ('Basement');

Note

Remember to update the Arduino sketch with the ID of the room you insert.

Now we have a place to store the humidity data. Next, we need to create a new version of the request.py code from Chapter 4, Temperature Storage – Setting Up a Database to Store Your Results, to write the value to the database.