DHT22, DHT11 and similar (Blocking version)

@peekay123 sure, is:

1 Like

@Intike I think @wgbartley is totally overworked! :wink: What’s missing at the top of application.ino after the char temp_humid[21]; line is:

elapsedMillis dhtElapsed;

That should fix the problem. :smile:

Thanks @peekay123, that fixed the problem, but now something very BASIC.
where is the serial monitor, or where can i see the results??
sorry, but is my first program. :smile:

You can use the serial monitor over USB. However, you may have to install a driver (if using Windows). I highly recommend installing the Spark CLI (command line interface) tool. Once installed, you can use spark serial monitor from a command line/terminal to get the serial output.

Hi @wgbartley, i use macintosh… is Coolterm also for serial?
but question remains, how i make it work, in the mean time i ll be looking in the internet. :smiley:

Hi @Intike

I have a mac and I use Cool Term–it works great. You have to wait for your core to reach the setup() function and do Serial.begin() and then Cool Term will have a new serial device that you can connect to.

Hi @bko, thanks for the tip.
but by wait, you mean, the core running and waiting in Coolterm (like 5min? i have now like 10) and should appear the extra option?
Thks

HI @Intike

I mean if you have in setup

void setup() {
   Serial.begin(9600);
   //other code
}

You need to wait until that code runs which will be when you see the breathing cyan LED plus a few seconds, and then click the Re-Scan Serial Ports button in Cool Term. Your core will show up with some random device name but it will be the only new serial device, so you can figure it out. Select that device and then click the big connect button on Cool Term.

What happens is that the core does not look like a serial device to your computer until you run the begin command, but once you do, it is just like you plugged in a new serial device over USB and it shows up in Cool Term.

@wgbartley, @bko, I have to run out but there is a Serial.println() missing in loop() to put out the data (temp_humid) but I was not sure how to convert the char array to a string. :smile:

thanks @bko @peekay123 and @wgbartley, did it take a moment, but it works.
sure not as easy as i though, due to my experience with arduino.
Now time for some personalization to the program.

Thanks all.

1 Like

that is what i did, and the result…

and when i added —delay(2000)---- start sending just ---- 32.00----
i think is time to learn a little bit, because i feel lost …

Hi BDub. I’ve got it set up like this (although still using D2 instead of D4) and I consistently get 0.00 for both Temp and Humidity. I’ve literally got your exact code and I get the JSON return data, so it’s basically working, but I just don’t get a valid reading. I am stumped!

@jherstein I’m working on getting one of these sensors to help you out. If anyone has one and can jump in here to help out in the mean time that would be super awexome!

I had to deal with the same error. Turned out that I tried to store the temperature in an int. Since the compiler did not throw an error (well, why would it?) it took me several hours to figure that out. But once I exchanged “int” for “float” it worked perfectly.
Rather a rookie mistake… But those are the ones that are the hardest to find sometimes :wink:

@Sydenth, the DHT22 is very finicky at 3.3V and another member has success with powering it from the Vin (5v) pin:

Perhaps this might work for you. :smile:

Thanks Peekay but my issue was related to a programming mistake :wink: fortunatley my DHTs run fine at 3.3V :smiley: I just wanted to make @jherstein aware of the fact that a wrong data type might be the problem (propaly should have tagged him then…).

@Sydenth, LOL!! I should take my time and read the entire post next time :wink:

1 Like

Hi Sydenth, can you summarize how you made this work? I tried changing to INT but am getting same (consistent) results.

That was my mistake :wink: You have to use a floating point variable like FLOAT or DOUBLE. At least that solved the problem for me…

2 Likes

Turns out my problem was the lack of a capacitor. All good now!

1 Like