IOT not working properly

I have a simple IOT sketch that should be reading my DHT22 and returning the temperature but it is not working. I have tried multiple DHTs to no avail. I added a random number and that works. I tested the esp32 and the dht with a library example and things worked.
SKETCH:
/*
Sketch genrated by the Arduino IoT Cloud Thing "Untitled"
https://creeate.arduino.cc/cloud/things/4fc4f4c0-42a3-4668-9f41-322365fea168

Arduino IoT Cloud Variables description

The following variables are automatically generated and updated when changes are made to the Thing

float fhumid;
float ftemp;
int randoNum;

Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"

#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 4
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);

// Defined in thingProperties.h
initProperties();

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}

void loop() {
ArduinoCloud.update();
// Your code here
delay(5000);
randoNum = random(1000);
ftemp = (dht.readTemperature() * 1.8) + 32;
fhumid = dht.readHumidity();
Serial.print("temperature is ");
Serial.println(ftemp);
Serial.println("this is a test");
Serial.println(randoNum);
Serial.print("humidity is ");
Serial.println(fhumid);
}

MONITOR DUMP:
L�$
�¡aI��***** Arduino IoT Cloud - configuration info *****
Device ID: 1944616a-357c-491a-aaf9-a25ce58b80f9
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi.status(): 255
temperature is nan
this is a test
189
humidity is nan
Connection to "SouthKlein" failed
Retrying in "4000" milliseconds
temperature is nan
this is a test
184
humidity is nan
Connected to "SouthKlein"
temperature is nan
this is a test
846
humidity is nan
temperature is nan
this is a test
121
humidity is nan
temperature is nan
this is a test
174
humidity is nan
temperature is nan
this is a test
249
humidity is nan
temperature is nan
this is a test
656
humidity is nan
ArduinoIoTCloudTCP::handle_WaitDeviceConfig device waiting for valid thing_id
temperature is nan
this is a test
221
humidity is nan
temperature is nan
this is a test
313
humidity is nan
temperature is nan
this is a test
686
humidity is nan
temperature is nan
this is a test
280
humidity is nan
Connected to Arduino IoT Cloud
Thing ID: 4fc4f4c0-42a3-4668-9f41-322365fea168

--

Steve Klein
1stQuartile@gmail.com

I was trying out a new ESP32 C3 Super Mini yesterday, all worked great, even with its limited antenna it connected almost instantly. So I soldered on the headers and slapped it into a mini breadboard and even added a DHT11 (even though I wasn't sure if the DHT11 was 5v or 3v3), then it stopped being able to connect to the net. After an hour or so I dismantled it and just used Dupont connectors and it went back to connecting as fast as before...

I believe there was too much resistance or something in the breadboard, preventing enough power getting to the wifi.

I've not had this issue with many standard dev modules but I do get it on ESP32 Cam modules too where brownouts are common. Sometimes a better USB cable does the trick, or using a powered USB hub instead. In operation I prefer a 2A wallwort and a short cable.

So, maybe try removing the sensors and just test the boards wifi on its own?

Also what board are you using?

I am using esp32 wroom da.I v
e tried switchin processors, dhts, cables, power source, etc. ithe board and sensor work fine locally. he one thing I dont understand is whyndht.readHumidity doesnt get highlightedin red.

thanks for your reply
steve

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.