-
Notifications
You must be signed in to change notification settings - Fork 85
Autonomy via Wifi
This guide shows how to use Snap4Arduino wirelessly by using an ESP8266 module. We will need to program the module so that it acts as a bridge between Wifi and the Arduino serial port, so that Snap4Arduino can send and receive data without the need of a cable.
The code that allows Snap4Arduino to work via wireless (including as the Wifi-serial bridge sketch) was contributed by Ove Risberg.
There are two ways to do so. If you own a USB-UART module you can program the ESP8266 right away, but if you do not, you can always use an Arduino board to program it.
(Coming soon)
These modules work at 3.3v, which is why we'll need to build a simple voltage divider or we risk damaging it. Some ESP8266 modules happen to be able to take 5v at TX, so if that's your case you can omit the voltage shifter.
If you can't get it to work, please recheck the wiring. It's very important that both the Arduino reset pin and the ESP8266 GPIO0 pins are connected to GND.
Just follow the schematic below:
Follow the instructions in this README in order to get support for the ESP8266 into your Arduino IDE.
Access the Boards Manager
in the Arduino IDE by navigating to Tools → Boards → Boards Manager
. Once there, find and install the esp8266
package by the ESP8266 Community
. You should now be able to select Generic ESP8266 Module
from the Tools → Board
Menu. You should keep the default options, that should look like this:
Except, of course, that you should select the serial port where your board is attached.
Download Ove Risberg's Wifi to Serial Sketch and load it into the Arduino IDE.
IMPORTANT: You will need to modify the sketch to set the proper SSID and password for your wireless network in lines 44 and 45, as shown below:
String localSSID = "YOUR_WIFI";
String Password = "YOUR_PASSWORD";
Navigate to Sketch → Include Library → Library Manager
. Find and install the Websockets
library.
You can now push it to the module as if it was a regular Arduino board by either navigating to Sketch → Upload
, clicking on the Upload
button or pressing Control+U
.
After a bit, a text mode progress bar should show up in the lower section of the IDE. Wait for it to reach 100%, and you're done.
IMPORTANT: First of all, disconnect both the bridge from the Arduino Reset pin and the ESP8266 GPIO2 pin to GND.
In a web browser, go to the address http://esp8266.local
. You should see something similar to:
If so, you're ready to use the module!