Connecting the AM2320 to Wemos D1 Mini

Wemos D1 Mini, a popular ESP8266-based development board, provides an excellent platform for building IoT projects. In this guide, we’ll walk you through the process of connecting an AM2320 temperature and humidity sensor to the Wemos D1 Mini. Additionally, we’ll demonstrate how to read sensor data and display it on the Serial Monitor using the Arduino IDE.

Materials Needed:

  1. ESP8266 Development Board (such as NodeMCU) (Affiliate) –
  2. AM2320 Temperature and Humidity Sensor (Affiliate) –
  3. Breadboard and jumper wires (Affiliate) –
  4. Arduino IDE installed on your computer

Wiring Connection:

Connect the AM2320 sensor to the Wemos D1 Mini as follows:

  • Connect the VCC pin of the AM2320 to the 3.3V pin on the Wemos D1 Mini.
  • Connect the GND pin of the AM2320 to the GND pin on the Wemos D1 Mini.
  • Connect the SDA pin of the AM2320 to the D2 pin on the Wemos D1 Mini.
  • Connect the SCL pin of the AM2320 to the D1 pin on the Wemos D1 Mini.



Your connections should look like this:



Arduino IDE Setup:

In the Arduino IDE, go to “Sketch” -> “Include Library” -> “Manage Libraries.” Search for “AM2320_asukiaaa” and install the library by Asuki Kono.



Write the code:

Copy and paste the following Arduino code into your Arduino IDE:


#include <AM2320_asukiaaa.h>

AM2320_asukiaaa mySensor;

void setup() {

void loop() {
  if (mySensor.update() != 0) {
    Serial.println("Error: Cannot update sensor values.");
  } else {
    Serial.println("temperatureC: " + String(mySensor.temperatureC) + " C");
    Serial.println("temperatureF: " + String(mySensor.temperatureF) + " F");
    Serial.println("humidity: " + String(mySensor.humidity) + " %");
  Serial.println("at " + String(millis()) + " ms");


  • Upload the code: Select your Wemos D1 Mini board from the “Tools” -> “Board” menu and choose the appropriate port. Then, click the right arrow button to upload the code to your Wemos D1 Mini.
  • Open the Serial Monitor: Once the code is uploaded, open the Serial Monitor by clicking “Tools” -> “Serial Monitor” or pressing Ctrl + Shift + M. You should see the temperature and humidity values being printed .



Frequently Asked Questions (FAQs):

  1. Q: Why am I getting “nan” for humidity in the Serial Monitor with the AM2320 sensor and the “AM2320” library?
    • A: The “nan” issue may persist due to wiring problems, power supply issues, or communication errors. Make sure your connections are correct, the power supply is stable, and try power cycling both the Wemos D1 Mini and the AM2320 sensor.
  2. Q: How do I resolve the “Failed to read from AM2320 sensor” message with the “AM2320” library?
    • A: The error suggests a communication problem. Confirm that the wiring is accurate, and the power supply is stable. Additionally, check if you have the correct library installed and consider trying an external power source.
  3. Q: Can I use the “AM2320” library with other microcontrollers?
    • A: Yes, the “AM2320” library is designed for use with various microcontrollers that support I2C communication. Adjust the code as needed for your specific microcontroller.


  1. Problem: Incorrect Wiring with the “AM2320” Library
    • Solution: Verify that the wiring connections between the Wemos D1 Mini and the AM2320 sensor are accurate. Pay special attention to the VCC, GND, SDA, and SCL pins.
  2. Problem: Power Supply Issues
    • Solution: Connect the AM2320 sensor to the 3.3V pin on the Wemos D1 Mini and ensure a stable power supply. Consider using an external power source if available.
  3. Problem: Communication Issues
    • Solution: Power cycle both the Wemos D1 Mini and the AM2320 sensor. Confirm there are no conflicting I2C addresses with other devices connected to the Wemos D1 Mini.
  4. Problem: Sensor Failure
    • Solution: If the issues persist, consider trying another AM2320 sensor to rule out a potential hardware failure.


Congratulations! You’ve successfully connected an AM2320 temperature and humidity sensor to the Wemos D1 Mini and displayed the sensor data on the Serial Monitor. This simple setup serves as a foundation for more complex IoT projects where sensor data can be utilized for monitoring and control purposes. Feel free to explore further and integrate this setup into your own projects!