Live TEMP Meter With XIAO and AHT10

by Arnov Sharma in Circuits > Microcontrollers

889 Views, 10 Favorites, 0 Comments

Live TEMP Meter With XIAO and AHT10

27.gif
25.gif
IMG_20240213_221303.jpg
ghgjh.jpg

Greetings and welcome back.

Here's something COOL, a temperature and humidity monitoring meter based on the AHT10 that measures the parameters related to the surrounding air temperature and humidity.

The objective of this project was to build a meter that I could simply put on my motorcycle so that I could visit XYZ locations and take temperature readings without having to rely on inaccurate data from my smartphone.

Here, the XIAO MCU is connected to an AHT10 sensor for data collection, and the SSD1306 display is used to show the temperature and humidity measurements.

This circuit was mounted onto the bike's handle using a 3D printed holder, and it has a built-in 3.7V 2600mAh Li-ion battery for power.

Let us get started with the building process, as this Instructables covers the entire project's build procedure.

Supplies

These were the materials used in this project:

  • XIAO M0 Microcontroller
  • AHT10 Sensor
  • Custom PCB
  • IP5306 IC
  • 10uF Capacitors
  • USB Port
  • Indicator LED 0805 Package Blue
  • 3 Ohms 1206 Resistor
  • Tactile switch
  • 5uH Inductor

AHT10 Sensor With XIAO Setup

02.gif
IMG_20240212_233920.jpg

The AHT10 Temp and Humidity Sensor Module is being used in this project, and it is a compact and highly accurate sensor designed to measure temperature and humidity in various applications. The module integrates a high-performance AHT10 sensor chip, which utilizes a capacitive sensing element to detect changes in temperature and humidity.

It provides reliable and precise measurements with a temperature accuracy of ±0.3°C and a humidity accuracy of ±2% RH.

The AHT10 module operates between 1.6V and 6V, which is ideal if we use an external 5V source to power this sensor along with the SSD1306 display and XIAO M0 Board.

The AHT10 sensor was connected to the Seeed XIAO M0 dev board in a basic breadboard setup for this project. An SSD1306 OLED screen was utilized to display the temperature and humidity readings.

CONNECTIONS-

  • 5V of XIAO gets connected to VCC of both the display and AHT10 Sensor
  • GND is connected with GND
  • SDA of Both the display and AHT10 gets connected to A4 IO Pin
  • SCL of Both the display and AHT10 gets connected to A5 IO Pin


CODE

Here's the code that was used in this project, and its a simple one.

This code essentially demonstrates how to use the AHT10 sensor library to read temperature and humidity, display the results on an OLED screen, and handle errors. The delays between measurements are implemented to avoid heating the sensor

#include <Wire.h>
#include <AHTxx.h>


#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

#define OLED_WIDTH 128
#define OLED_HEIGHT 64

#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);

float ahtValue; //to store T/RH result

AHTxx aht10(AHTXX_ADDRESS_X38, AHT1x_SENSOR); //sensor address, sensor type


void setup()
{
#if defined(ESP8266)
WiFi.persistent(false); //disable saving wifi config into SDK flash area
WiFi.forceSleepBegin(); //disable AP & station by calling "WiFi.mode(WIFI_OFF)" & put modem to sleep
#endif

display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();

Serial.begin(115200);
Serial.println();

while (aht10.begin() != true) //for ESP-01 use aht10.begin(0, 2);
{
Serial.println(F("AHT1x not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free

delay(5000);
}

Serial.println(F("AHT10 OK"));

//Wire.setClock(400000); //experimental I2C speed! 400KHz, default 100KHz
}


void loop()
{
/* DEMO - 1, every temperature or humidity call will read 6-bytes over I2C, total 12-bytes */
Serial.println();
Serial.println(F("DEMO 1: read 12-bytes"));

ahtValue = aht10.readTemperature(); //read 6-bytes via I2C, takes 80 milliseconds

display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(30, 0);
display.println(F("Temp-"));

// Serial.print(F("Temperature...: "));

if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs
{

display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(35, 25);
display.println(ahtValue);
display.display();
// Serial.print(ahtValue);

}
else
{
printStatus(); //print temperature command status

if (aht10.softReset() == true) Serial.println(F("reset success")); //as the last chance to make it alive
else Serial.println(F("reset failed"));
}

delay(2000); //measurement with high frequency leads to heating of the sensor, see NOTE

ahtValue = aht10.readHumidity(); //read another 6-bytes via I2C, takes 80 milliseconds

display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(30, 0);
display.println(F("Humd-"));


// Serial.print(F("Humd-"));

if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs
{

display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(35, 25);
display.println(ahtValue);
display.display();


// Serial.println(F(" +-2%"));
}
else
{
printStatus(); //print humidity command status
}

delay(2000); //measurement with high frequency leads to heating of the sensor, see NOTE

/* DEMO - 2, temperature call will read 6-bytes via I2C, humidity will use same 6-bytes */
Serial.println();
Serial.println(F("DEMO 2: read 6-byte"));

ahtValue = aht10.readTemperature(); //read 6-bytes via I2C, takes 80 milliseconds

Serial.print(F("Temperature: "));

if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs
{
Serial.print(ahtValue);
Serial.println(F(" +-0.3C"));
}
else
{
printStatus(); //print temperature command status
}

ahtValue = aht10.readHumidity(AHTXX_USE_READ_DATA); //use 6-bytes from temperature reading, takes zero milliseconds!!!

Serial.print(F("Humidity...: "));

if (ahtValue != AHTXX_ERROR) //AHTXX_ERROR = 255, library returns 255 if error occurs
{
Serial.print(ahtValue);
Serial.println(F(" +-2%"));
}
else
{
printStatus(); //print temperature command status not humidity!!! RH measurement use same 6-bytes from T measurement
}

delay(10000); //recomended polling frequency 8sec..30sec
}

void printStatus()
{
switch (aht10.getStatus())
{
case AHTXX_NO_ERROR:
Serial.println(F("no error"));
break;

case AHTXX_BUSY_ERROR:
Serial.println(F("sensor busy, increase polling time"));
break;

case AHTXX_ACK_ERROR:
Serial.println(F("sensor didn't return ACK, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)"));
break;

case AHTXX_DATA_ERROR:
Serial.println(F("received data smaller than expected, not connected, broken, long wires (reduce speed), bus locked by slave (increase stretch limit)"));
break;

case AHTXX_CRC8_ERROR:
Serial.println(F("computed CRC8 not match received CRC8, this feature supported only by AHT2x sensors"));
break;

default:
Serial.println(F("unknown status"));
break;
}
}

PCB DESIGN

SCH_page-0001.jpg
01.PNG
board.PNG

The next step of this project was to put everything together to create a basic PCB that would contain all of the components we used to create the breadboard version, in addition to a lithium cell with a charge discharge circuit to power the XIAO module, display, and sensor.

First, we construct the schematic, which is divided into two main sections: the MCU part, which has an XIAO microcontroller paired to an SSD1306 OLED screen and an AHT10 sensor, and the power supply section, which has a standard IP5306 IC arrangement.

Let's have a look at the power supply section first.

The power management IC (IP5306) being utilized here is a popular boost converter IC that is typically used for power bank applications. It boosts the voltage of lithium cells from 3.7V to a stable 5V/2A so that XYZ USB devices may be powered.

To charge the lithium cell, we have added a USB Micro B port.

In order to avoid overcharging or overdischarge, it has low and high cuts for the lithium cell in addition to an onboard battery fuel indicator.

Checkout few of my projects in which i have used this IC-

https://www.instructables.com/SYNTHESIZER-Made-From-Scratch/

https://www.instructables.com/Cyber-PY-Zero-Two/

https://www.instructables.com/The-Ultimate-Camera-RIG-With-Portable-Display/

Then we have the microcontroller section, which consists of the XIAO M0 DEV board connected with an AHT10 sensor and SSD1306 display.

The VCC of the AHT10 sensor and the display are both connected to the 5V output of the power management IC. Since the AHT10 and Display are both I2C devices, their SDA and SCL are linked in parallel to the D4 and D5 pins of the XIAO, respectively.

Connections are the same as in the breadboard version.

After creating the schematic, we created a PCB with the screen in the center, the AHT10 on the left, and the XIAO M0 on the right using the dimensions from the CAD model of this project created in Fusion 360.

SEEED FUSION

Image2.jpg
01.gif

After finalizing the PCB and generating its Gerber data, I sent it to SEEED Studio for samples.

The PCB was ordered in a white solder mask with black silkscreen.

PCBs were received in a week, and their quality was super good considering the rate, which was also pretty low.

Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly, and as a result, they produce superior quality PCBs and fast turnkey PCBAs within 7 working days.

Seeed Studio Fusion PCB Assembly Servicetakes care of the entire fabrication process, from Seeed Studio Fusion Agile manufacturing and hardware customization to parts sourcing, assembly, and testing services, so you can be sure that they are getting a quality product.

After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.

Next is the PCB assembly process.

PCB ASSEMBLY

05.gif
04.gif
03.gif
06.gif
07.gif
08.gif
09.gif
  • Using a solder paste dispensing needle, we first add solder paste to each component pad individually to begin the PCB assembly process. In this instance, we are using standard 37/63 solder paste.
  • Next, we pick and place all the SMD components in their place on the PCB using an ESD tweezer.
  • With extreme caution, we lifted the complete circuit board and placed it on the SMT hotplate, which increases the PCB's temperature to the point at which the solder paste melts and all of the components are connected to their pads.
  • Next, we add all the THT components, which include the relay, header pin, AHT10 sensor, switch, and SSD1306 display, to their locations and then solder their pads using a soldering iron.
  • On the bottom side, we solder the 18650 cell holder in its location using the soldering iron.

POWER SOURCE

10.gif
11.gif

The IP5306 Power Management IC is attached to the 3.7V 2600mAh 18650 Li-ion Cell, which serves as the power source. It raises the 3.7V to a stable 5V so that the XIAO MCU, display, and sensor can function.

When we insert the cell into its holder and push the tactile switch, the LED turns on, indicating that the circuit is functional.

The IP5306 IC's output voltage of 5.1V, which we measured using a multimeter, indicates that the circuit is operating as intended.

3D DESIGN

02.PNG
03.PNG
04.PNG
14.gif

Let's have a look at the design of this TEMP Meter project, which was made in Fusion360.

The first holder that we modeled is made up of an upper and a lower holder that are both going to be tightened to the handle of the motorcycle. This holder is attached to a simple lever part that is fastened to the holder with a long bolt and nut. This simple lever part rotates, allowing the meter PCB that is mounted on the lever part to move along its axis.

Initially, the PCB was modeled with every component positioned on it, such as the screen, XIAO, sensor, and battery holder section on the front.

Once the model was finished, we used a 0.4mm nozzle, 0.2mm layer height, and 20% infill to 3D print each of the three sections out of grey PLA.

Downloads

FINAL ASSEMBLY

15.gif
16.gif
17.gif
  • Using two M2 screws, we first attach the basic lever component to the TEMP circuit. Two holes have already been created on the PCB for mounting the screws with the lever part.
  • Next, we mount the lever part assembly with the upper holder using two washers and a long M3 bolt and nut.
  • Next, we use two M3 Allen bolts and nuts to join the bottom and upper holders. This component is used to attach the entire assembly to the motorcycle handle.

RESULT SO FAR

19.gif
20.gif
21.gif

Here's the result so far: The TEMP Meter setup is working pretty well.

By pressing the Tactile switch, the device turns on and remains on for one minute. The IP5306 IC then shuts down and the device turns off; this function is essentially an auto-shutoff one that helps to preserve battery life and boosts the device's backup power.

The TEMP Meter setup can be rotated because of its hinge design.

Mounting the Meter on Bike

22.gif

Once the TEMP Meter device is finished, we mount it on the motorcycle handle by first removing the Allen bolts and nuts that hold the upper and lower holders together, and then reattaching the holders to the handle.

Overall Result

23.gif
24.gif
25.gif

This is the culmination of this strange but amusing build: a live temperature and humidity meter attached to the motorcycle handle.

Now that we have this meter configured, we can get real-time temperature and humidity readings in any location without having to rely too heavily on erroneous data from Google Maps.

With this meter, I want to take a lengthy road trip into the mountains and record temperature data while it snows.

Leave a comment if you need any help regarding this project. This is it for today, folks.

Thanks to Seeed Studio for supporting this project.

You guys can check them out if you need great PCB and stencil service for less cost and great quality.

And I'll be back with a new project pretty soon!