DHT22 reading sensor, First post,

Hello, Im sorry, I recognize this post will be moved. Please accept my apologies for making more work for you.
I posted here because I am embarking of a data collection device from sensors. And thought my post fit here. But I do see that it might be putting the cart before the horse.

I am trying to start small project with a DHT22 and see the data in the serial viewer. But my code is not doing it.
Or Im setting up my environment wrong.
I have this hardware

  • List item

Esp32S 38p dev board - not connecting to the com
Esp wroom 32 - id2ac7z-espwroom32 - connects fine but when hard wird to gnd-3v3-pin4 or g4 I get cant read dht22 sensor data in serial monitor
windows 11 IDE 2.3.2

my code is

//Ronald M. Pare
//xTrainer
//alpha 1.0 DHT intergation

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

#define DHTPIN 4     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22   // DHT 22 (AM2302), AM2321

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);
  dht.begin();
}

void loop() {
  delay(2000);

  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print(" °C ");
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");
}

Thank you for your time and patience while I properly learn the etiquette. Yes I read the getting started documents, but I am on the spectrum and while I see the rules I over complicate things in my head.

Welcome to the forum

Your topic has been moved to the Programming Questions category of the forum

Please edit the title of the topic to something more appropriate

1 Like

Hello, please read How to get the best out of this forum and post accordingly .

I wrote already that I did that.
BTW happy fathers day to the fathers here.

Post the exact circuit and describe how things are powered

Happy father day

Ok I intend to use the development board (unplugged, should I plug it in to power? or is the usb good enough?). But it isnt being recognized.
While I haven't tried the uart cable (haven't used it yet its new) my micro usb wont show a com.

However when I connect directly to the esp itself unconnected to dev board with micro-usb i get my com3 and it uploads but doesn't show the sensor data. powered by usb

I connected the dht22 to gnd at bottum of board across from 3v3, the 3v3 and g4 or p4 as described on board.

Thank you, I hope to hear the kids say it this year.

Powered through USB should be OK.
If you don’t see a com port either the board is damaged or you miss a driver or the cable is just a power cable and not a data + power cable.

Can you put a link to your exact board ?

ESP32 Deveopment Board TYPE-C/MICRO USB CP2102 WiFi+Bluetooth Dual Core ESP32-DevKitC-32 ESP-WROOM-32 Expansion Board 38PINS

ESP Dev Board

Do you have (need ?) this driver on your OS?

I don’t use windows

Ill check, I am pretty sure I have it. I will install it now and see.

At this point i am saying yes, as I have been to this page and installed a driver.

Yes I do.

Connected the uart to the dev board and get this error. tx connected to rx and visa versa

Sketch uses 269549 bytes (20%) of program storage space. Maximum is 1310720 bytes.
Global variables use 17024 bytes (5%) of dynamic memory, leaving 310656 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.6
Serial port COM6
Connecting......................................

A fatal error occurred: Failed to connect to ESP32: No serial data received.
For troubleshooting steps visit: Troubleshooting - ESP32 - — esptool.py latest documentation
Failed uploading: uploading error: exit status 2

debug info

Waiting for gdb server to start...[2024-06-16T19:02:26.178Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:\Users\decke\AppData\Local\Arduino15\packages\esp32\tools\openocd-esp32\v0.12.0-esp32-20230921/bin/openocd" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "c:\Users\decke\Documents\Arduino\xtrainer-a1-0" -f "C:/Program Files/Arduino IDE/resources/app/plugins/cortex-debug/extension/support/openocd-helpers.tcl" -f board/esp32-wrover-kit-3.3v.cfg
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:40)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
CDRTOSConfigure
Info : auto-selecting first available session transport "jtag". To override use 'transport select '.
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Error: unable to open ftdi device with description '', serial '' at bus location '*'
C:/Users/decke/AppData/Local/Arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20230921/bin/../share/openocd/scripts/target/esp_common.cfg:9: Error:
at file "C:/Users/decke/AppData/Local/Arduino15/packages/esp32/tools/openocd-esp32/v0.12.0-esp32-20230921/bin/../share/openocd/scripts/target/esp_common.cfg", line 9
[2024-06-16T19:02:26.803Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

I am going to wait till I get my next package to try replacing items and see if something is broken.

user error, I notice when I went to change the gpio pin. I had the wrong wire on the signal wire. Dang it.
Thanks for the assistance