This book is a project. Using a step-by-step approach, it will help you explore your Raspberry Pi in a way that will help you appreciate both its hardware and its software capabilities.
In writing this book, I have tried to break away from the classic text book format of chapters, sections and long paragraphs, and instead present this highly technical topic as an engineer would approach it: with a lot of iterations, each delivering a gradual improvement to the overall functionality of the system, with each iteration comprising of several step.
Each step is marked with a number so that you can refer to it in your own notes, or in your communication with me or other readers of this book.
All of the code that I describe in this project is hosted on Github, from where you can download it on your computer. It is much better to copy code from the Github repository rather than trying to manually copy it from this book. I provide links to the file that I am discussing at different parts of the project; simply click to a link and copy the code from the screen.
In writing this project, I make a few assumptions about you:
- You can program a computer in at least one programming language, not necessarily Python
- You are not afraid of learning a new programming language
- You are comfortable working with electronics. You will need some basic beginner-level skills.
- You are not easily frustrated. What you are about to do in this project requires patience!
- You like to explore different technologies. The modern maker must be good in multiple technologies, hardware, software and different “sub-categories” of each one.
The goal is to show you how to setup a Raspberry Pi computer so that:
- It measures temperature and humidity.
- It reports the values in real time via a web browser.
- It record these values in a database.
- It retrieves these records and displays them in tabular format and in graphical format in a web browser.
- It sends the values to a graphical analysis cloud service.
You will learn:
- How to setup the minimal Raspbian operating system to the RPi.
- Install the a Python virtual environment
- Install and use Flask, a Python-based web micro-framework
- Install and use uWSGI as the application server for Flask
- Install and use Nginx light-weight web server
- Use the RPi GPIOs as digital input and outputs
- Use a DHT22 humidity and temperature sensor
- Install and use the SQLite database
- Use the Google Chart API to create visual representations of the sensor data
- Use JQuery to add interactivity to web pages
- Use Plotly for graphical analysis of sensor data
Section: 1 – Introduction to the course
- Lecture 1: Introduction 02:17
- Lecture 2: About the Raspberry Pi 04:45
- Lecture 3: Components 04:22
- Lecture 4: Detailed List of Components you will need
- Lecture 5: Please read this before continuing!
Section: 2 – The Operating System
- Lecture 6: Section Intro 00:25
- Lecture 7: Installing mini Raspbian using Mac OS X 16:35
- Lecture 8: Installing mini Raspbian using Windows 14:42
- Quiz 1: Section Quiz 3 questions
- Lecture 9: Section Conclusion 00:14
Section: 3 – Python and GPIOs
- Lecture 10: Section Intro 00:25
- Lecture 11: Set up Python 13:55
- Lecture 12: GPIO basics 08:36
- Lecture 13: Make an LED blink 17:57
- Lecture 14: Read the status of a button 09:52
- Lecture 15: Read temperature and humidity from a digital sensor 15:53
- Quiz 2: Section Quiz 4 questions
- Lecture 16: Section Conclusion 00:21
Section: 4 – Setup the Web application stack
- Lecture 17: Section Intro 00:24
- Lecture 18: What is the Web application stack? 07:03
- Lecture 19: Install Nginx, the Web server 02:49
- Lecture 20: Install Flask and venv 09:17
- Lecture 21: Install uWSGI 18:40
- Lecture 22: Setup Upstart 10:19
- Lecture 23: About log files 08:49
- Lecture 24: Serving static assets and Skeleton 11:55
- Lecture 25: Styling our Web application with Skeleton 09:12
- Lecture 26: Debugging a Flask application 05:46
- Quiz 3: Section Quiz 6 questions
- Lecture 27: Section Conclusion 00:19
Section: 5 – Building a simple Flask application on the Raspberry Pi
- Lecture 28: Section Intro 00:31
- Lecture 29: Show DHT22 sensor data in the browser 14:07
- Lecture 30: Install the SQLite3 database 14:05
- Lecture 31: Use a Python script to store sensor reading to the database 07:34
- Lecture 32: Automate sensor data logging with cron and SQLite3 12:57
- Lecture 33: Show historical sensor data in the browser 12:48
- Quiz 4: Section Quiz 3 questions
- Lecture 34: Section Conclusion 00:22
Section: 6 – Improving our application with date-time range record selector
- Lecture 35: Section Intro 00:26
- Lecture 36: Selecting historical sensor data records with a time-date range 07:12
- Lecture 37: Define a date-time range in the URL 10:49
- Lecture 38: Timezones in Rasbian 02:03
- Lecture 39: Validating timestamps 06:24
- Lecture 40: Tidying up: refactor our application code 03:32
- Quiz 5: Section Quiz 3 questions
- Lecture 41: Section Conclusion 00:31
Section: 7 – Improving the user interface
- Lecture 42: Section Intro 00:29
- Lecture 43: Adding date range radio buttons 19:17
- Lecture 44: Visualise sensor data with Google Charts 18:35
- Lecture 45: Install a datetime picker widgets 07:11
- Lecture 46: Setting up the datetime picker widget 07:57
- Lecture 47: Setting up time zones on the client side 08:31
- Lecture 48: Setting up time zones on the server side 14:00
- Lecture 49: Link the two pages of the application 05:29
- Quiz 6: Section Quiz 3 questions
- Lecture 50: Section Conclusion 00:28
Section: 8 – Setup cloud charting and analysis with Plotly
- Lecture 51: Section Intro 00:15
- Lecture 52: Setup Plotly 10:19
- Lecture 53: Add Plotly links 10:05
- Lecture 54: Add Plotly support to the Flask application script 11:11
- Quiz 7: Section Quiz 3 questions
- Lecture 55: Section Conclusion 00:28
Section: 9 – Other useful things to know
- Lecture 56: Install and configure a Wifi USB dongle for wireless networking 22:22