FeatherOLED

The FeatherOLED example (located in the Adafruit_WICED_Arduino/examples/Adafruit folder) uses the Adafruit_FeatherOLED library to display basic information about the WICED Feather on the 128x32 I2C OLED Feather Wing.

This advanced example demonstrates several useful concepts and libraries for the WICED Feather:

  • How to monitor the LIPO battery level
  • How to work with an external OLED display for easy user feedback
  • How to work with the Adafruit Unified Sensor Library to retrieve sensor data
  • How to work with MQTT to push data to Adafruit IO

This example optionally uses a TSL2561 light sensor to generate real sensor data, but it should be relatively straight forward to use a different unified sensor driver, or you can disable the sensor entirely if you wish to simply use the OLED or send simulated sensor data.

Setup

Before you can use the FeatherOLED sketch you will have to install the Adafruit_FeatherOLED library into your libraries folder. If you're new to Arduino our Arduino Libraries Learning Guide explains everything you need to know to get Adafruit_FeatherOLED installed on your local system.

Setting the Access Point

Once you have Adafruit_FeatherOLED installed on your system, you need to set your AP details using the WLAN_SSID and WLAN_PASS flags in the example sketch, setting them to the values used by you own access point:

Download: file
#define WLAN_SSID             "YOUR SSID HERE"
#define WLAN_PASS             "YOUR SSID KEY HERE"

Enabling LIPO Battery Monitoring (Optional)

If you wish to monitor the LIPO cell voltage level, you will also need to enable the VBAT_ENABLED flag by setting its value to '1':

Download: file
#define VBAT_ENABLED              1
#define VBAT_PIN                  PA1

Important: Make sure that the BATADC solder jumper on the bottom of your WICED Feather is soldered shut as well, since this will run the LIPO cell through a voltage divider and into the ADC pin on PA1.  See the Board Layout page for details, but the solder jumper can be seen below.

You have to solder these two metal leads together to form a 'bridge':

Enabling the TSL2561 Luminosity Sensor (Optional)

You can also enable the TSL2561 light sensor to demonstrate how to work with the Adafruit_Sensor library to read sensor data on the WICED Feather.

To enable the TSL2561 in your sketch, simply set the SENSOR_TSL2561_ENABLED flag to '1':

Download: file
#define SENSOR_TSL2561_ENABLED    1

This will cause the WICED Feather to read a new data sample from the TSL2561 every ten (10) seconds.

The TSL2561 should be connected to the WICED Feather as follows:

  • TSL2561 SCL to WICED SCL
  • TSL2561 SDA to WICED SDA
  • TSL2561 VIN to WICED 3V
  • TSL2561 GND to WICED GND

Enabling MQTT to Adafruit IO (Optional)

You can optionally push the sensor data to Adafruit IO using the AdafruitAIO helper class.

To enable MQTT to Adafruit IO support simply set the AIO_ENABLED flag to '1':

Download: file
#define AIO_ENABLED              1

You also need to enter your AIO Username and your AIO key, as well as the target feeds that data should be published to:

Download: file
#define AIO_USERNAME              "...your AIO username (see https://accounts.adafruit.com)..."
#define AIO_KEY                   "...your AIO key..."

#define FEED_VBAT                 "vbat"
#define FEED_TSL2561_LUX          "lux"

For more information on communication with Adafruit IO via MQTT see the Adafruit IO MQTT API.

Compile and Flash

You can compile and flash your sketch to the WICED Feather using the 'Download' arrow icon at the top of the IDE:

You should see the USB DFU progress as the update advances, and there will be a 'Done Uploading' message in the top left of the status bar when you are done:

Testing the Sketch

Unlike many of the example sketches, this example will not wait for the USB CDC Serial Port to open before executing the code.

If you have an OLED display properly connected, data should appear on it as soon as the USB DFU flash update process is completed:

The data rendered on the display will depend on the way that you configure the example sketch, but the top and bottom lines are reserved for WiFi and LIPO information, and the two middle lines (referred to as the 'Message Area' in Adafruit_FeatherOLED) can be used to render any text or messages.
This guide was first published on Mar 23, 2016. It was last updated on Mar 23, 2016. This page (FeatherOLED) was last updated on May 06, 2019.