revoxhere / duino-coin

ᕲ Duino-Coin is a coin that can be mined with almost everything, including Arduino boards.
https://duinocoin.com
MIT License
1.09k stars 511 forks source link

Shield DHT11 with ESP8266 ESP-01 Not Reading Sensors #1498

Closed Alabaca closed 2 years ago

Alabaca commented 2 years ago

I have just upload the new ESP8266 release, and activate the DHT since I'm using a Shield DHT11 with a ESP-01. image

My code is like this:

ifdef USE_DHT

float temp = 0.0; float hum = 0.0; float temp_weight = 0.9; // 1 for absolute new value, 0-1 for smoothing the new reading with previous value float temp_min_value = 10.0; float temp_max_value = 40.0; float hum_weight = 0.9; // 1 for absolute new value, 0-1 for smoothing the new reading with previous value float hum_min_value = 0.1; float hum_max_value = 100.0;

// Install "DHT sensor library" if you get an error

include

// Change D3 to the pin you've connected your sensor to

define DHTPIN 2

// Set DHT11 or DHT22 accordingly

define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

endif

Have no errors compiling and uploading, but the results came Zero from the sensors Captura de ecrã 2022-05-04 175708 Captura de ecrã 2022-05-04 175740

Running a simple skecth using the same configuration on the DHT I can have readings

Captura de ecrã 2022-05-04 180032

Can this be something related with the code, or some parameters extra for this hardware?

revoxhere commented 2 years ago

Reading with a value of 0 may mean there's a connection issue between the ESP and DHT. Check your wiring and pin configuration (maybe 2 should be changed to D2?) I don't really know how the pins are mapped on a basic ESP8266-01 module

Alabaca commented 2 years ago

This code works fine, and the hardware is the same. The PIN mapped looks equal to yours...

ESP8266_DHT11_Web.txt

ghost commented 2 years ago

It happens to me too, but I have a NodeMCU and my DHT11 is connected to D4

ghost commented 2 years ago

Reading with a value of 0 may mean there's a connection issue between the ESP and DHT. Check your wiring and pin configuration (maybe 2 should be changed to D2?) I don't really know how the pins are mapped on a basic ESP8266-01 module

I don't think it's a wiring or configuration problem, there has to be something wrong with the code or the server, because I didn't change the wirings from the previous ones

lyovav commented 2 years ago

Hi all. I'm not very strong in programming but the output is next

ifdef USE_DHT

float newTemp = dht.readTemperature();
float newHum = dht.readHumidity();

// if ((temp >= temp_min_value) && (temp <= temp_max_value)) { // if ((newTemp >= temp_min_value) && (newTemp <= temp_max_value)) { // temp = temp_weight newTemp + (1.0f - temp_weight) temp; // keep weighted measurement value // } else { temp = newTemp; // keep current temp // } // } // else - keep newTemp as is

// if ((hum >= hum_min_value) && (hum <= hum_max_value)) { // if ((newHum >= hum_min_value) && (newHum <= hum_max_value)) { // hum = hum_weight newHum + (1.0f - hum_weight) hum; // keep weighted measurement value // } else { hum = newHum; // keep current hum // } // } // else - keep newHum as is

endif

22

define DHTPIN 4 (gpio4 - sda)

// Set DHT11 or DHT22 accordingly

define DHTTYPE DHT22

photo_2022-05-07_16-34-49

ghost commented 2 years ago

Thanks! This was a very simple fix to be honest 😄

LDarki commented 2 years ago

Hi, try using the latest code, in theory it's fixed now. Tell me if i can close this issue.

❤️

lyovav commented 2 years ago

Hi, try using the latest code, in theory it's fixed now. Tell me if i can close this issue.

❤️

Hi. Seems to be working fine.

Alabaca commented 2 years ago

Hi, it really is working now: image

But to be honest this ESP performs really slow with the DHT11 module, with very slow mining performance that don´t even appear on the wallet... Since is the first version of the ESP8266, I will assume that it does not have the power to do both things at the same time, and use it without the DHT11.

Thanks for the effort, and at least it contributes to make some improvements on the code.

For me you can close the issue.