Adafruit OLED FeatherWing Created by lady ada Last updated on 2017-08-07 08:34:17 PM UTC
Guide Contents Guide Contents Overview Pinouts Power Pins I2C Data Pins Optional Buttons Reset Button Assembly 2 4 8 8 9 10 11 12 Prepare the header strip: Add the FeatherWing: And Solder! Usage Install Adafruit SSD1306 Library Install Adafruit GFX Run Example Code Do more! FeatherOLED Library Downloading the Library Adafruit_FeatherOLED Base Class void init ( void ) void setBattery ( float vbat ) void setBatteryVisible ( bool enable ) void setBatteryIcon ( bool enable ) void clearMsgArea ( void ) Adafr
Download Schematics Fabrication Print © Adafruit Industries 31 31 31 https://learn.adafruit.
Overview A Feather board without ambition is a Feather board without FeatherWings! This is the FeatherWing OLED: it adds a 128x32 monochrome OLED plus 3 user buttons toany Feather main board. Using our Feather Stacking Headers (http://adafru.it/2830) or Feather Female Headers (http://adafru.it/2886) you can connect a FeatherWing on top of your Feather board and let the board take flight! © Adafruit Industries https://learn.adafruit.
These displays are small, only about 1" diagonal, but very readable due to the high contrast of an OLED display. This screen is made of 128x32 individual white OLED pixels and because the display makes its own light, no backlight is required.
Tested works with all of our Feather boards. The OLED uses only the two I2C pins on the Feather, and you can pretty much stack it with any other FeatherWing, even ones that use I2C since that is a shared bus. © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Pinouts The OLED FeatherWing plugs into any Feather and adds a cute little display. To make it as cross-platform compatible as possible, we use only I2C to control the display. This is not as fast as SPI but it uses only two pins, can share the I2C bus and is fine for the small 128x32 pixel OLED. Power Pins © Adafruit Industries https://learn.adafruit.
OLED displays do not have a backlight, and are fairly low power, this display will draw about 10mA when in use. The display uses 3V power and logic so we just connect to the 3V and GND pins from the feather, as indicated above. I2C Data Pins The cute little OLED does all of the data transfer over the I2C pins, highlighed aboveSDA and SCL. No other pins are required. There are two 2.2K pullups to 3V on each. These pins can be shared with other I2C devices. © Adafruit Industries https://learn.adafruit.
The I2C address is 0x3C and cannot be changed Optional Buttons We had a little bit of space so we added three mini tactile buttons that you can use for user interface.
Button C is #PC5 Button B has a 100K pullup on it so it will work with the ESP8266(which does not have an internal pullup available on that pin). You will need to set up a pullup on all other pins for the buttons to work. Reset Button Sometimes its nice to be able to restart your program, so we also have a reset button. It is tied to the RST pin marked above. © Adafruit Industries https://learn.adafruit.
Assembly Prepare the header strip: Cut the strip to length if necessary. It will be easier to solder if you insert it into a breadboard - long pins down Add the FeatherWing: Place the featherwing over the pins so that the short pins poke through the two rows of breakout pads © Adafruit Industries https://learn.adafruit.
And Solder! Be sure to solder all pins for reliable electrical contact. (For tips on soldering, be sure to check out our Guide to Excellent Soldering (http://adafru.it/aTk)). Start by soldering the first row of header © Adafruit Industries https://learn.adafruit.
Now flip around and solder the other row completely © Adafruit Industries https://learn.adafruit.
You're done with the two header strips. Check your solder joints visually and continue onto the next steps © Adafruit Industries https://learn.adafruit.
OK You're done! You can now plug your FeatherWing into your Feather and get your OLED on! © Adafruit Industries https://learn.adafruit.
Usage The OLED display we use is well supported and works for all Feathers, all you need is a little library support and you will be drawing in no time! Install Adafruit SSD1306 Library Start by installing the support library for the OLED display, you'll need it to talk to the OLED controller chip. We have the Adafruit SSD1306 library repository on GitHub (http://adafru.it/aHq) if you're interested in looking at the code. Start by downloading the library.
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use (http://adafru.it/aYM) Install Adafruit GFX You will need to do the same for the Adafurit_GFX library available here (http://adafru.it/aJa) Download Adafruit GFX Library http://adafru.it/cBB Rename the uncompressed folder Adafruit_GFX and check that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.
#define BUTTON_B 3 #define BUTTON_C 8 #define LED 13 #elif defined(ARDUINO_FEATHER52) #define BUTTON_A 31 #define BUTTON_B 30 #define BUTTON_C 27 #define LED 17 #else // 32u4, M0, and 328p #define BUTTON_A 9 #define BUTTON_B 6 #define BUTTON_C 5 #define LED 13 #endif #if (SSD1306_LCDHEIGHT != 32) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif void setup() { Serial.begin(9600); Serial.println("OLED FeatherWing test"); // by default, we'll generate the high voltage from the 3.
display.println("Sending val #0"); display.setCursor(0,0); display.display(); // actually display all of the above } void loop() { if (! digitalRead(BUTTON_A)) display.print("A"); if (! digitalRead(BUTTON_B)) display.print("B"); if (! digitalRead(BUTTON_C)) display.print("C"); delay(10); yield(); display.display(); } You should see the OLED display a splash screen then spit out some text. If you press the A B or C buttons it will also print those out Do more! © Adafruit Industries https://learn.
You can use any of the Adafruit GFX library commands to draw onto your OLED, that means that you get all sorts of shapes, fonts, lines, etc available. Check out GFX for all the underlying graphics support functions and how they work (http://adafru.it/doL) Dont forget you have to call display() after drawing to push the buffer out to the display! © Adafruit Industries https://learn.adafruit.
FeatherOLED Library To make it easier to work with the OLED FeatherWing with specific Feather boards we've published an optional BETA library called Adafruit_FeatherOLED (http://adafru.it/m3b). The library consists of a base class called Adafruit_FeatherOLED which breaks the 128x32 displays in four rows of eight pixels each, and you can extend the base class with your own OLED implementation to render custom icons, etc.
void setBatteryIcon ( bool enable ) Setting this to 'true' will cause an icon to be displayed for the battery level. Setting this to 'false' will cause the raw voltage level to be displayed as a text string. void clearMsgArea ( void ) Calling this function will clear the middle 128x16 pixels message area on the OLED display. Adafruit_FeatherOLED_WiFi This sub-class is designed to display basic WiFi details like your IP address, connection status and the RSSI level for your connection.
of the OLED display. A single 32-bit integer is sent to this function, where each 8-bit component of the 4 byte IP address is seperated and printed out. void setIPAddressVisible ( bool enable ) Enables or disables the IP address in the bottom 8 pixel status bar. Setting this to true ' ' enables the IP address. void refreshIcons ( void ) Calling this function will redraw all of the status icons, and should be called if you have made any changes to the values using the helper functions like .setRSSI, .
#include #define WLAN_SSID #define WLAN_PASS #define VBAT_ENABLED #define VBAT_PIN "SSID" "PASSWORD" 1 PA1 #define SENSOR_TSL2561_ENABLED 0 #if SENSOR_TSL2561_ENABLED #include bool _tslFound = false; Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345); #endif #define AIO_ENABLED #define AIO_USERNAME #define AIO_KEY 0 "...your AIO username (see https://accounts.adafruit.com)..." "...your AIO key...
oled.clearMsgArea(); } else { // Display the error message err_t err = Feather.errno(); oled.setConnected(false); oled.refreshIcons(); oled.clearMsgArea(); oled.println("Connection Error:"); switch (err) { case ERROR_WWD_ACCESS_POINT_NOT_FOUND: // SSID wasn't found when scanning for APs oled.println("Invalid SSID"); break; case ERROR_WWD_INVALID_KEY: // Invalid SSID passkey oled.
// Multiply the ADC by mV per LSB, and then // double the output to compensate for the // 10K+10K voltage divider vbatFloat = ((float)vbatADC * vbatLSB) * 2.0F; oled.setBattery(vbatFloat/1000); // Push VBAT out to MQTT if possible if (AIO_ENABLED && aio.
// Refresh the screen oled.refreshIcons(); oled.clearMsgArea(); // Try to connect to the AP if ( !connectAP() ) { // Enter a while(1) loop here since any connection error // is handled in .connectAP() above while(1); } #if AIO_ENABLED // Attempt to connect to a Broker oled.clearMsgArea(); oled.println("io.adafruit.com"); oled.display(); // Connect to AIO server if ( aio.connect() ) { oled.println("Connected!"); oled.display(); }else { oled.print("Failed! Error: "); oled.println(aio.errno(), HEX); oled.
updateVbat(); if ( Feather.connected() ) { // Update the RSSI value int8_t rssi = Feather.RSSI(); oled.setRSSI(rssi); // Get a light sample and publish to MQTT if available #if SENSOR_TSL2561_ENABLED if (_tslFound) { oled.clearMsgArea(); sensors_event_t event; // Get a new data sample bool sensor_data = tsl.getEvent(&event); if (sensor_data) { if (AIO_ENABLED && aio.connected()) { feedLUX = event.light; oled.clearMsgArea(); oled.print("Lux -> AIO: "); oled.println(event.light); oled.
/**************************************************************************/ /*! @brief AIO callback when there is new value with Feed VBAT */ /**************************************************************************/ void aio_vbat_callback(float value) { // oled.println("AIO VBAT: "); // oled.
Download SSD1306 (http://adafru.it/aJK) Datasheet OLED UG-2832HSWEG02 Datasheet (http://adafru.it/qrf) PCB Files in EagleCAD format (http://adafru.it/nbc) Fritzing object available in the Adafruit Fritzing Library(http://adafru.it/aP3) Schematics Fabrication Print Dimensions in inches © Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2017-08-07 08:34:17 PM UTC Page 32 of 32