Make the following connections between the Metro and the ADT7410
- ADT7410 Vin to 3V or 5V (depending on the logic level of your board).
- ADT7410 GND to Metro GND.
- ADT7410 SCL to Metro SCL
- ADT7410 SDA to Metro SDA
To read data from your ADT7410, you will need to install the Adafruit_ADT7410 library. It is available from the Arduino library manager so we recommend using that.
From the Arduino IDE, open the Library Manager (Sketch -> Include Library -> Manage Libraries)
Type in Adafruit ADT7410 and click Install
You'll also need to install Adafruit Unified Sensor Library:
Open up File -> Examples -> Adafruit ADT7410 Library -> adt7410test and upload to your Arduino wired up to the sensor
/**************************************************************************/
/*!
This is a demo for the Adafruit ADT7410 breakout
----> http://www.adafruit.com/products/4089
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
/**************************************************************************/
#include <Wire.h>
#include "Adafruit_ADT7410.h"
// Create the ADT7410 temperature sensor object
Adafruit_ADT7410 tempsensor = Adafruit_ADT7410();
void setup() {
Serial.begin(115200);
Serial.println("ADT7410 demo");
// Make sure the sensor is found, you can also pass in a different i2c
// address with tempsensor.begin(0x49) for example
if (!tempsensor.begin()) {
Serial.println("Couldn't find ADT7410!");
while (1);
}
// sensor takes 250 ms to get first readings
delay(250);
// ** Optional **
// Can set ADC resolution
// ADT7410_13BIT = 13 bits (default)
// ADT7410_16BIT = 16 bits
tempsensor.setResolution(ADT7410_16BIT);
Serial.print("Resolution = ");
switch (tempsensor.getResolution()) {
case ADT7410_13BIT:
Serial.print("13 ");
break;
case ADT7410_16BIT:
Serial.print("16 ");
break;
default:
Serial.print("??");
}
Serial.println("bits");
}
void loop() {
// Read and print out the temperature, then convert to *F
float c = tempsensor.readTempC();
float f = c * 9.0 / 5.0 + 32;
Serial.print("Temp: "); Serial.print(c); Serial.print("*C\t");
Serial.print(f); Serial.println("*F");
delay(1000);
}
Upload the sketch to your board and open up the Serial Monitor (Tools->Serial Monitor). You should see the temperature in Celsius and Fahrenheit.
Temp: 23.25*C 73.85*F Temp: 23.19*C 73.74*F Temp: 23.25*C 73.85*F Temp: 23.25*C 73.85*F
Adafruit_ADT7410 tempsensor = Adafruit_ADT7410();
Initialize the sensor with:
tempsensor.begin()
This function returns True if the ADT7410 was initialized correctly, and False if it was not.
Once initialized, you can query the temperature in °C with
tempsensor.readTempC()
Which will return floating point (decimal + fractional) temperature. You can convert to Fahrenheit by multiplying by 1.8 and adding 32 as you have learned in grade school!
Page last edited January 22, 2025
Text editor powered by tinymce.