ESP8266 v2.0 VS ESP8266 v3.0

@shramik_salgaonkar I am trying different libraries of DHT but it’s not working.

Do you any code with another library of DHT?
Maybe it will help me.

no, i dont have any other library. you can try to google search it.

I have tried different codes.

All codes are working in my old ESP8266 v3, but not in ESP8266 v3.

Sounds like a wiring issue to me.

@adam I have used the same wiring diagram as i used in my ESP8266 v2, but it’s not working.

Do you work with ESP8266 v3 ?

@adam Do you know which library do i need to use for AM2301 and ESP8266 v3 ?

@shramik_salgaonkar

This code is working. But i need your help to connect this code with Cayenne.

I need to show the temperature and humidity in Cayenne dashboard.

Can you help me please ?

This is the code


#include “DHT.h”

#define DHTPIN 12 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT21 // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println(F(“DHTxx test!”));

dht.begin();
}

void loop() {

delay(2000);

float h = dht.readHumidity();

float t = dht.readTemperature();

float f = dht.readTemperature(true);

if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F(“Failed to read from DHT sensor!”));
return;
}

float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);

Serial.print(F("Humidity: “));
Serial.print(h);
Serial.print(F(”% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F(“°F”));
}


so what was the difference in this code?
Combine the working DHT code with https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/Connections/ESP8266/ESP8266.ino to send data to cayenne.

@shramik_salgaonkar
The problem was not in the code.
The problem was power supply. Power supply for AM2301 need to be 3V. It doesn’t work with 5V.

1 Like