Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Gawan
#34120 Hi,

I am using a ESP8266 SP12E devkit V2 and want to transmit values from my AM2302 DHT22 temp. and humid. sensor.

The sketch itself works fine (output to serial), but as soon as I add one additional line (that has nothing to do with DHT22 or the humidity var) its getting crazy ...

This is how it works:

Code: Select all
void loop()
{
  delay(dht.getMinimumSamplingPeriod());
  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

  Serial.println(String(millis()));
//  Serial.println("Uptime: " + String(millis()/60000) +" min  " + String(millis()/1000) + " sec");
 
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.println(temperature, 1);


In this case the output looks like:
........
WiFi connected
Server started
10.0.0.29
6811
45.2 24.2
8816
45.2 24.2


You can see this one line that is commented out.

As soon as I comment it in:

Code: Select all
void loop()
{
  delay(dht.getMinimumSamplingPeriod());
  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

  Serial.println(String(millis()));
  Serial.println("Uptime: " + String(millis()/60000) +" min  " + String(millis()/1000) + " sec");
 
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.println(temperature, 1);


this is what I get:

........
WiFi connected
Server started
10.0.0.29
6811
Uptime: 0 min 6 sec
6553649.0 24.2
8816
Uptime: 0 min 8 sec
6553649.0 24.2


The humidity value is just scrap.
I have no idea how this can happen ...
Does anyone have a hint for me ?

BR
Gawan
User avatar
By GengusKahn
#35859
Gawan wrote:Hi,

I am using a ESP8266 SP12E devkit V2 and want to transmit values from my AM2302 DHT22 temp. and humid. sensor.

The sketch itself works fine (output to serial), but as soon as I add one additional line (that has nothing to do with DHT22 or the humidity var) its getting crazy ...

This is how it works:
................................

this is what I get:

........
WiFi connected
Server started
10.0.0.29
6811
Uptime: 0 min 6 sec
6553649.0 24.2
8816
Uptime: 0 min 8 sec
6553649.0 24.2


The humidity value is just scrap.
I have no idea how this can happen ...
Does anyone have a hint for me ?

BR
Gawan



Hi there, this DHT library uses strict timing when the void from the library is run, use an interrupt driven library, try searching the github....(the line is having an effect on timing).....

https://github.com/rDuinoStar/rDHT11--DHT11-Arduino-Lib

I have used this when there have been "issues".......