So I've been trying to get a small project set up for the upcoming eclipse, just to read changes in the humidity and temp during the eclipse.
I have two DHT11 sensors, I'm only using one.
I have downloaded this library (it's at the bottom), and this is the code I'm using.
#include <dht.h>
#define pin 13
dht DHT;
void setup() {
Serial.begin(9600);
delay(2500);
Serial.print("DHT11 Sensor: April 8 Solar eclipse data\n\n");
delay(1500);
}
void loop() {
DHT.read11(pin);
Serial.print(" ");
Serial.print(DHT.humidity);
Serial.print(" ");
Serial.print(DHT.temperature);
Serial.print(",\n");
delay(2500);
}
The goal here is to have csv's that I can copy/paste into a .csv and import to matlab to do what I need on there.
I keep getting the title and "0.00 0.00," for the two data sets. With other libraries and borrowed code sometimes I get -999 for the datasets.
My set up
schematic
simulate this circuit – Schematic created using CircuitLab
My schematic isn't super accurate, the sensor's on the breadboard. LMK your thoughts.
-
1@StarCat just delete the comment thenjsotola– jsotola2024年04月05日 18:36:24 +00:00Commented Apr 5, 2024 at 18:36
-
I attempted the resistor, I put one end in the power row between the 5V into the breadboard and the power pin for the sensor, and the other end into a slot between the data wire out to the Mega, and the pin for the sensor. Still zeros.Jayven Mason– Jayven Mason2024年04月05日 19:01:07 +00:00Commented Apr 5, 2024 at 19:01
-
Try a pin other than 13. There is additional circuitry around pin 13 for the built in LED.Delta_G– Delta_G2024年04月06日 02:33:37 +00:00Commented Apr 6, 2024 at 2:33
-
Can be a bad sensor or bad cable too.tepalia– tepalia2024年04月06日 10:32:09 +00:00Commented Apr 6, 2024 at 10:32
-
You can cross-check your sensor with this tutorial. theengineeringprojects.com/2017/08/… If your sensor does not work after following this, maybe you have to replace your sensor.tepalia– tepalia2024年04月08日 15:09:46 +00:00Commented Apr 8, 2024 at 15:09
1 Answer 1
If you are using a standalone DHT11 sensor (Without breakout board) you will need a 1KΩ pullup-resistor between 5v and Data.
The DHT's data pin is an open collector, meaning it can only pull a wire to ground to transmit data. If that wire wasn't pulled up to begin with, it won't have anything to pull down.
If your DHT11 is on a breakout board with the 1KΩ resistor already in place, I would suspect a bad sensor...
-
I have used DHT11's successfully in at least two different projects. Take a look at fpaynter.com/2021/07/… and fpaynter.com/2017/01/3d-printer-filament-de-humidifier-bin. Both these posts have the entire code.starship15– starship152024年04月10日 22:43:57 +00:00Commented Apr 10, 2024 at 22:43