To read data from the Motion and Temperature FeatherWing, you'll need to install libraries for both of the ADXL343 and the ADT7410 sensors.

To install the library for the ADXL343, visit this page and come back here when you have the library installed and tested.

Next, to install the library for the ADT7410, visit this page and come back here when you have the library installed and tested.

This guide assumes you've completed the setup required to get your Adafruit Feather HUZZAH ESP8266 up and running with Arduino IDE and Adafruit IO. 

  • If you haven't yet set up your Adafruit Feather HUZZAH ESP8266 for use with Adafruit IO and the Arduino IDE, follow along with this guide. The setup only needs to be performed once.


The code for this project is below. Copy and paste it into the Arduino IDE editor.

// SPDX-FileCopyrightText: 2019 Brent Rubell for Adafruit Industries
// SPDX-License-Identifier: MIT

// Adafruit IO - Analog Devices ADT7410 + ADXL343 Example
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
// Written by Brent Rubell for Adafruit Industries
// Copyright (c) 2019 Adafruit Industries
// Licensed under the MIT license.
// All text above must be included in any redistribution.

/************************ Adafruit IO Config *******************************/
// visit if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_KEY "YOUR_IO_KEY"

/******************************* WiFi Config ********************************/

// comment out the following two lines if you are using fona or ethernet
#include "AdafruitIO_WiFi.h"

/************************** Configuration ***********************************/
// time between sending data to adafruit io, in seconds.
#define IO_DELAY 5
/************************ Example Starts Here *******************************/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_ADT7410.h"
#include <Adafruit_ADXL343.h>

float tempC, accelX, accelY, accelZ;

// Create the ADT7410 temperature sensor object
Adafruit_ADT7410 tempsensor = Adafruit_ADT7410();

// Create the ADXL343 accelerometer sensor object
Adafruit_ADXL343 accel = Adafruit_ADXL343(12345);

// set up the 'temperature' feed
AdafruitIO_Feed *huzzah_temperature = io.feed("temperature");

// set up the 'accelX' feed
AdafruitIO_Feed *huzzah_accel_x = io.feed("accelX");

// set up the 'accelY' feed
AdafruitIO_Feed *huzzah_accel_y = io.feed("accelY");

// set up the 'accelZ' feed
AdafruitIO_Feed *huzzah_accel_z= io.feed("accelZ");

void setup()
  // start the serial connection

  // wait for serial monitor to open
  while (!Serial)

  Serial.println("Adafruit IO - ADT7410 + ADX343");

  /* Initialise the ADXL343 */
    /* There was a problem detecting the ADXL343 ... check your connections */
    Serial.println("Ooops, no ADXL343 detected ... Check your wiring!");

  /* Set the range to whatever is appropriate for your project */

  /* Initialise the ADT7410 */
  if (!tempsensor.begin())
    Serial.println("Couldn't find ADT7410!");
    while (1)

  // sensor takes 250 ms to get first readings

  // connect to
  Serial.print("Connecting to Adafruit IO");

  // wait for a connection
  while (io.status() < AIO_CONNECTED)

  // we are connected

void loop()
  //; is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  //, and processes any incoming data.;

   /* Get a new accel. sensor event */
  sensors_event_t event;

  accelX = event.acceleration.x;
  accelY = event.acceleration.y;
  accelZ = event.acceleration.z;

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("X: "); Serial.print(accelX); Serial.print("  ");
  Serial.print("Y: "); Serial.print(accelY); Serial.print("  ");
  Serial.print("Z: "); Serial.print(accelZ); Serial.print("  ");Serial.println("m/s^2 ");
  // Read and print out the temperature
  tempC = tempsensor.readTempC();
  Serial.print("Temperature: "); Serial.print(tempC); Serial.println("C");

  Serial.println("Sending to Adafruit IO...");
  huzzah_temperature->save(tempC, 0, 0, 0, 2);
  Serial.println("Data sent!");

  Serial.print("Waiting ");Serial.print(IO_DELAY);Serial.println(" seconds...");
  // wait IO_DELAY seconds between sends
  for (int i = 0; i < IO_DELAY; i++)

Code Setup

Before you upload the sketch to the Huzzah, you'll need to configure the code for your network and Adafruit IO.

Change IO_USERNAMEto your Adafruit IO username.

Then, change IO_KEYto your Adafruit IO Key.

Next, we'll configure the code for your router. Change WIFI_SSID to your router's SSID and WIFI_PASS to your router's password.

Save the code (CTRL/CMD + S). Then, verify that the sketch compiles (Tools -> Verify). 

Upload the sketch to your board (CTRL/CMD + U).

Open the Arduino Serial Monitor. The serial monitor should output that the sensors have been initialized and that the Feather Huzzah has connected to Adafruit IO:

Adafruit IO - ADT7410 + ADXL343
ADXL343 Initialized
ADT7410 Initialized!
Connecting to Adafruit IO: AdafruitIO::connect()
Adafruit IO connected.

The Huzzah reads temperature values from the ADT7410 and the accelerometer values from the ADXL343:

X: -0.55  Y: 0.12  Z: 9.85  m/s^2 
Temperature: 28.69C

And sends these values to Adafruit IO...

Sending to Adafruit IO...
Data sent!
Waiting 15 seconds.. 

The delay between sending this data is configurable (modify the DELAY_SECONDS definition at the top of the code to change it). If it's sending data too frequently (above 30 data points a minute for Adafruit IO Free users), you can increase the delay between sends.

Code Usage

Let's check that the data has been received by Adafruit IO. You can do this by visiting the Adafruit IO Monitor page. Every time the Huzzah sends data to Adafruit IO, this page shows the temperature, accelX, accelY or accelZ values.

Navigate to the dashboard you created earlier. You'll notice the Gauge block change values whenever the ADT7410 reports a new temperature to the Huzzah. As you tilt the Huzzah, you'll notice the sliders for X, Y, and Z changing their positions to reflect the ADXL343's values in m/s^2.

Taking it Further

Data Visualization

While the sliders can provide immediate information about the ADXL343 or the ADT7410 on the FeatherWing at a glance - you may want to chart your data over a longer period of time or see a list of data with previous values on the dashboard. 

Connect a Line Graph Block to the the four feeds to view data from the sensors over any period of time - from real-time to 30 days.  

Then, add a Stream Block and connect to any feed which you'd like to monitor. This block is a miniature version of the monitor page, but only displays feeds which you specify. 

Adding a Battery

Want to run your Feather without an attached USB Cable? 

For 100% wireless motion and temperature logging, pick up a Lithium Ion Polymer battery (we recommend this one - it's ideal for the Feather family) and connect it to the JST-PH port on the Feather ESP8266.

This guide was first published on Mar 21, 2019. It was last updated on Nov 22, 2019.

This page (Arduino Code) was last updated on Mar 04, 2019.

Text editor powered by tinymce.