Full Stack Web Development with Raspberry Pi 3

Book description

Discover how to build full stack web applications with the Raspberry Pi 3

About This Book

  • Leverage JavaScript, HTML5, and Cloud APIs to create visual representations and interactive web pages.
  • Learn to install and use a Node.js-based web framework to develop Raspberry Pi 3-powered web applications.
  • A step-by-step guide that will cover from setting up a embedded system to developing embedded, device-powered interactive web applications.
  • Who This Book Is For

    This book is aimed at hobbyist, enthusiasts, and developers eager to develop embedded device-powered web applications. Prior programming experience with JavaScript, HTML5, and Node.JS will be beneficial.

    What You Will Learn

  • Get up and running with your Raspberry Pi
  • Go full stack! Learn about the end-to-end development process for web applications, right from the OS up to the actual HTML web interface
  • Discover that JavaScript is one of the fastest growing languages today, and is the only language that can be used both on a browser and server. This book will empower you to develop in a complete JavaScript stack
  • See that the IoT is everywhere!Connect your application to the outside world. Make use of sensors in your Raspberry Pi to give your application an edge, and unleash the full power of the Internet of Things
  • Build a rich UI with beautiful charts and data visualizations that can run on any browser
  • Make your software data-driven. Learn how to utilize SQLite to collect and analyze data from multiple systems
  • In Detail

    Modern web technology and portable computing together have enabled huge advances in the Internet of Things (IoT) space,as well as in areas such as machine learning and big data. The Raspberry Pi is a very popular portable computer for running full stack web applications. This book will empower you to master this rapidly evolving technology to develop complex web applications and interfaces.

    This book starts by familiarizing you with the various components that make up the web development stack and that will integrate into your Raspberry Pi-powered web applications. It also introduces the Raspberry Pi computer and teach you how to get up and running with a brand new one. Next, this book introduces you to the different kinds of sensor you’ll use to make your applications; using these skills, you will be able to create full stack web applications and make them available to users via a web interface. Later, this book will also teach you how to build interactive web applications using JavaScript and HTML5 for the visual representation of sensor data. Finally, this book will teach you how to use a SQLite database to store and retrieve sensor data from multiple Raspberry Pi computers.

    By the end of this book you will be able to create complex full stack web applications on the Raspberry Pi 3 and will have improved your application’s performance and usability.

    Style and approach

    Step-by-step instructions on developing a full stack web application and deploying it to the Cloud.

    Publisher resources

    Download Example Code

    Table of contents

    1. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    2. Getting Started on the Raspberry Pi
      1. The Internet of Things
      2. A brief look at our application
        1. The sensor interface - perception
        2. The database - persistence
        3. The user interface - presentation
        4. The application server - middleware
      3. Setting up our Raspberry Pi
      4. Remote access
      5. Summary
    3. Getting Up-and-Running with Web Development on the Raspberry Pi
      1. The network
      2. The web development stack
        1. The UI - the user's first encounter
        2. The server - the brains of the application
          1. Client-server communication
          2. Interfacing with external hardware
        3. The database - adding persistence to our data
          1. Integrating the database into our application
        4. The overall architecture
      3. Summary
    4. Running a Node Server on the Pi
      1. Introducing nodes - the server side JavaScript runtime
        1. Installing node on the Pi
      2. Running our first node program
        1. Setting up a version control system
        2. Back to our program
        3. Installing external libraries
        4. Developing the application server
          1. Adding routes to the server
          2. Starting up the server
        5. Keeping the server running in the background
      3. Summary
    5. Extracting Information from the GPIO Pins
      1. The GPIO pins on the Pi
      2. The pin as a standalone component
        1. The Write mode
        2. The Read mode
      3. Fine-tuning our control - using the GPIO command-line tools
      4. The DHT11 sensor
      5. Reading from the sensor
      6. Summary
    6. Retrieving Sensor Readings from the Server
      1. Understanding how our node process takes readings
      2. Modifying our server code to show sensor readings
      3. Optimizing our server
        1. Abstracting our sensor library code
        2. Caching our results
      4. Summary
    7. Creating a Web Page to Display Sensor Data
      1. Extending our application
        1. Serving static files from the Express server
      2. Building the UI's functionality
        1. Adding client-side JavaScript
        2. Fetching sensor readings using XHR
      3. Visually enhancing the UI
        1. Changing the structure of our UI
        2. Adding style to the newly modified structure
      4. Summary
    8. Enhancing Our UI - Using Interactive Charts
      1. Considerations when implementing complex features
      2. Introducing Chart.js
        1. Installing Chart.js
        2. Creating our first chart
      3. Making the server response data-friendly
        1. Modifying the sensor dashboards to consume JSON data
      4. Integrating sensor data into our charts
        1. A code overview
          1. index.js
          2. public/index.html
          3. public/script.js
      5. Summary
    9. SQLite - The Fast and Portable Database
      1. Picking the correct tool for the job
        1. Installation
      2. Creating the temperature and humidity tables
      3. Running CRUD operations
        1. Create
        2. Read
        3. Update
        4. Delete
      4. Aggregations
        1. Advanced aggregations using subqueries
      5. Summary
    10. Integrating SQLite into Our Application
      1. Getting started: Interfacing SQLite with node
      2. Running queries with node
      3. Making our database module
        1. Adding a new temperature to the database
        2. Fetching the last "n" readings from a table
        3. Fetching readings between a certain time period
        4. Fetching the average of readings between time periods
        5. Putting the functions together in a module
      4. Integrating the database module into our server application
        1. Upgrading the sensor interface module
        2. Adding an API to get the latest ten readings
        3. Consuming the API on the client side
      5. Adding new features - the ability to view readings from a custom time period
        1. Adding the required APIs
      6. Summary
    11. Making our Application Real Time with Web Sockets
      1. Web sockets
      2. Implementing web sockets in our application
        1. The socket.io library
        2. Client-side installation
        3. Server-side installation
      3. Creating our socket implementation in our application server
      4. Client-side implementation
      5. Summary
    12. Deploying our application to Firebase
      1. The Firebase platform
      2. Migrating to Firebase
        1. The User interface
        2. Database
        3. Server application and sensor interface
      3. Creating your first Firebase application
        1. Installing the Firebase CLI
        2. Logging in to Firebase on the command line
        3. Initializing a new Firebase application
        4. Testing and deploying the application to the cloud
      4. Migrating the frontend assets
        1. Adding Firebase tools
      5. Adding the Realtime Database
      6. Enabling access to the Firebase Database
      7. Adding listeners to the client-side script
      8. Summary
    13. Using Firebase APIs to Update Our Application
      1. Application server versus application process
      2. Securing our application
      3. The application process architecture
      4. Implementing the application process
      5. Summary

    Product information

    • Title: Full Stack Web Development with Raspberry Pi 3
    • Author(s): Soham Kamani
    • Release date: August 2017
    • Publisher(s): Packt Publishing
    • ISBN: 9781788295895