Datasheet
// 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.connected())
{
feedVBAT = vbatFloat/1000;
}
}
/**************************************************************************/
/*!
@brief The setup function runs once when the board comes out of reset
*/
/**************************************************************************/
void setup()
{
// Wait for Serial Monitor
// while(!Serial) delay(1);
// Setup the LED pin
pinMode(BOARD_LED_PIN, OUTPUT);
// Setup the OLED display
oled.init();
oled.clearDisplay();
// Initialize tsl sensor if enabled
#if SENSOR_TSL2561_ENABLED
if (tsl.begin())
{
_tslFound = true;
tsl.enableAutoRange(true);
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); /* medium resolution and speed */
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* 16-bit data but slowest conversions */
}
#endif
// Get a VBAT reading before refreshing if VBAT is available
#if VBAT_ENABLED
pinMode(VBAT_PIN, INPUT_ANALOG);
oled.setBatteryIcon(true);
updateVbat();
#endif
© Adafruit Industries https://learn.adafruit.com/adafruit-oled-featherwing Page 27 of 32










