Blog Post

Getting Started with the WiFi Arduino Interface for PiStorms

857

Not sure where to start with your WiFi Arduino Interface for PiStorms? Here's a step-by-step guide on getting started.

First we'll install the Arduino IDE, you might actually have it already.

This board runs on the ESP8266 (the main, shiny, all-in-one package in the bottom-right) mounted on an NodeMCU board (the entire black bottom half). The Arduino Uno and Nano are included when you download the Arduino IDE, but the NodeMCU is a custom board so we'll need to add it. This will let the Arduino program know how to upload and perform other operations to the board (different than an Uno).

Then we'll connect the NodeMCU board and upload a simple program to make sure we installed the board right. With this finished we will move on to downloading the required libraries. The EVShield library is used for the primary functions. But wait, isn't this a PiStorms? Yes, but the EVShield already runs on an Arduino so we adapted it to work with this WiFi Arduino Interface for PiStorms. The EVs_UIModule is an add-on to the EVShield to give it a screen. The PiStorms already has one built in, so we'll just use this library to control it. This library is built off the Adafruit_ILI9340, which is built off of the Adafruit-GFX-Library. Don't worry, all the links are in the details below.

Finally, we can upload the MSBrowser program! To make things simple for you, this template sets things up and lets you upload multiple programs. You will be able to select program 1, 2, or 3 on the PiStorms, which should save you from uploading so many times. Did you know you can upload programs wirelessly to this board‽ The MSBrowser template also gives you a spot to type in your WiFi SSID and password to set it up for you.

Basic Setup covers the essentials, More Help has additional explanations and a few other tutorials.
Let's get started.

Basic Setup

1. Download the Arduino IDE

2. Add the NodeMCU board

  • Go to https://github.com/esp8266/Arduino#installing-with-boards-manager for instructions (or read below)
  • Open the Arduino IDE
  • Go to File → Preferences (Ctrl+Comma)
  • In the "Additional Boards Manager URLs" field paste in "http://arduino.esp8266.com/stable/package_esp8266com_index.json"
  • Go to Tools → Board: "Arduino/Genuino Uno" → Boards Manager...
  • Search "esp8266" and install it

3. Select and connect the NodeMCU board

  • Go to Tools → Board: "Arduino/Genuino Uno"
  • From the list, select "NodeMCU 1.0 (ESP-12E Module)". It will be under the second section labeled "ESP8266 Modules"
  • Plug in your WiFi Arduino Interface for PiStorms (for now without the PiStorms connected) using a microUSB cable
  • Go to Tools → Port and select the Serial port (for example, "COM9")

4. Upload a simple test program

  • Go to File → Examples → ESP8266 (this will be under "Examples from Custom Libraries") → Blink
  • Click upload (the second icon on the toolbar, a right arrow) (Ctrl+U)
  • Once it finishes you should see the bright blue LED near the top-left of the board flash on and off at one-second intervals

5. Install custom libraries

6. Upload MSBrowser template

  • Go to File → Examples → EVShield → WiFiInterfaceForPiStorms_examples → MSBrowser
  • ! important ! Click the second tab "credentials.h" and enter your WiFi SSID and password
  • Disconnect your WiFi Arduino Interface, attach the PiStorms, then reconnect the microUSB cable (remember the PiStorms will need external power if you want to run motors)
  • Click upload (Ctrl+U)
  • Give it a minute to compile, upload, and connect to your WiFi network. You will see three colored boxes. Select a program and tap "GO" and it will print "setup#" with the number of the program you chose
  • Note: make sure you press the GO button to turn on the PiStorms! The Arduino can put stuff on the screen even if the PiStorms is off, so don't be mislead.

7. Write your own program

  • Click on the tab "program1", "program2", or "program3" and let your imagination run wild!
  • Remember to save! Because the template is read-only the Arduino IDE will let you save it in a different folder.

More Help

1. Examples

  • Additional examples are available in File → Examples → EVShield → WiFiInterfaceForPiStorms_examples
  • They include a simple paint program and a bit more involved examples of graphics and WiFi

2. The EVShield and EVs_UIModule libraries

  • This is the WiFi Arduino Interface for PiStorms, why are we using the EVShield library? The EVShield, as you might know, interfaces with an Arduino (not Raspberry Pi). This library was adapted to work also with this Arduino interface for the PiStorms.
  • The EVShield has a UI Module that fits on top of the board to add a screen. To keep things consistent, you can use the EVs_UIModule library to draw to the PiStorms screen. It inherits from the Adafruit_GFX library, so you can also use all of those standard methods used everywhere.
  • However, the EVShield UI Module does not have a touchscreen (but the PiStorms does!). For this reason you use the EVShield library to access the touchscreen values and the EVs_UIModule library to draw graphics.
  • If you are using the MSBrowser template, an instance of each library has already been made for you to use in program1, 2 or 3. There is an EVShield object identified `ev` and a EVs_UIModule object `uim`.
  • As you can see in the example program1, 2 or 3, you can call `.println()` on the `uim` object itself. So instead of `Serial.println()` to see something in the Serial Monitor, use `uim.println()` to put text on the screen. You can also move the cursor around, change colors, draw shapes, all that. See the Adafruit tutorial here.
  • The `ev` object is what you will use to access the EVShield. As you can see in the examples, you can use `ev.ledSetRGB(255,0,0)` to set both LED colors (red in this case), or something like `evshield.bank_a.ledSetRGB(0,255,0)` to set the Bank A LED green.
  • In the example `ev.getButtonState(BTN_GO)` is used to reset the board when you press the GO button. The button parameter (here BTN_GO) is there to retain compatibility with the EVShield. The EVShield has a left and right button, the PiStorms does not. If an example program asks you to press the left button to continue, the left and right buttons have been mapped to the F1 and F2 software buttons.
  • You also use the EVShield library to control motors, (for example `evshield.bank_a.motorRunRotations`), read from sensors, etc. To get touchscreen information you can use `ev.checkButton` to check if a certain area is touched, or maybe `ev.getTouchscreenValues` to get the actual X and Y coordinates (example).

3. Over The Air (OTA) uploading

  • You can upload new programs to your WiFi Arduino Interface for PiStorms over WiFi, without any microUSB cable keeping your robot tethered
  • The MSBrowser program takes care of making the Arduino listen for your upload request, but long calls (such as repeatedly filling the entire screen) can block this from happening fast enough
  • The network port will only show up if it was there when the Arduino application was launched. This is a bug in the Arduino IDE. If your device is on and running the MSBrowser sketch, close and re-open the Arduino IDE.
  • Look for something along the lines of "esp8266-0b55a5 at 192.168.1.15" in Tools → Port

4. Remove trailing "-master" from the library names

  • When downloading the libraries in step 5, the folder ended in "-master" because you downloaded it from the master branch
  • Go to File → Preferences (Ctrl+Comma)
  • Copy the "Sketchbook location:" field and paste it in the Address Bar of Windows Explorer (or navigate to that folder yourself)
  • Open the libraries folder (for example, C:UsersmindsensorsDocumentsArduinolibraries)
  • Right-click each folder and select Rename (or select the file and press F2), then delete "-master" from the end and press enter

Comments (0)

No comments at this moment
Please Login to add your comments

Featured Posts

The mindsensors Grove Sensor Adapter makes it easy to use a variety of unique Grove sensors with the...

Read more

The mindsensors Grove Sensor Adapter makes it easy to use a variety of unique Grove sensors with the...

Read more

Poll

  • What do you use to program your FRC Robot?
    Total: