In this tutorial, we’ll show you how to send data from cheap WiFi nodes to a Raspberry Pi over an internal WiFi network. It relies on the Flask framework for Python, which is a relatively simple-to-use method of creating a web application that can execute Python scripts.
We’ll use a Raspberry Pi 3 and SparkFun ESP8266 Thing to demonstrate. We’re going to send a very simple signal from the Thing board to the RasPi – just a signal to turn an attached LED on or off. Hopefully, it’ll be obvious from the example how to send more complex signals and run more complex scripts upon receipt.
You’ll need the items on this wishlist to complete this tutorial. Substitutions can be made; a Raspberry Pi Zero W can be substituted for the Pi 3, for instance, and individual components can be sourced instead of the full starter kit.
No special tools are required to follow this tutorial. You will need a soldering iron, solder, and general soldering accessories.
You’ll need to do some basic breadboarding to prepare for this tutorial. Don’t worry, we’ll walk you through all of it.
Raspberry Pi Connections
The connections for the Pi are simple: we’re just connecting one LED to GPIO pin 2. See the Fritzing diagram below for information on how to do that.
ESP8266 Thing Connections
Hook up two of the buttons as seen in the Fritzing diagram below.
One of the buttons will turn the remote LED on, the other will turn it off. We’re going to assume that you’re capable of soldering the headers onto the ESP8266 Thing board yourself, but if you need some help, check out our soldering tutorial.
This is also where you’ll use the long, centered breakaway headers. A six-pin group of them inserted into the breadboard aligned with the programming pins on the Thing will give you a place to plug in the FTDI board.
Raspberry Pi Software
Let’s get down to business and program the Raspberry Pi to serve a web app that we can use for data connection. This tutorial assumes that you have some familiarity with Linux and Python to follow along.
The first step is adding support for Flask to the RasPi. Python is already installed and support for using GPIO through Python, so we don’t need to worry about that.
All of these commands can be run either on a serial terminal opened on the Raspberry Pi directly with the Pi hooked up to a monitor, or remotely with a Pi via an SSH connection. However, we’re not going to get into how to set up and run a Pi without a monitor.
The first thing you need to do is install the Flask framework. There are a lot of additional packages that can be used with Flask, but we only need the basic package for this tutorial.
Read More Info…