Zero Values with DHT11

Hi,

I'm new to Arduino and currently I'm trying to get the DHT11 example from the Arduino website running. But I'm having problems. I'm getting zero values for temperature and humidity only and I don't see where the error is. Below you find the code of my sketch.

Hint: For programming I'm using Visual Studio 2017 with the Visual Micro plugin. Maybe that information helps for solving the problem. The DHT11 sensor works, I already used them with a Raspberry Pi and there it works.

#include "DHT11.h"
#define DHT11PIN 7

dht11 DHT11;

int temp = 0;
int humid = 0;
int chk = 0;
int counter = 0;

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

void loop()
{
	counter++;
	chk = DHT11.read(DHT11PIN);
	if (chk == 0) // read operation OK
	{
		temp = DHT11.temperature;
		humid = DHT11.humidity;
	}

	delay(2000);
}

How do you know you're getting zeroes?

Because of the debugging feature of Visual Micro. I'm using it to watch the variables. Because of the counter I know, that this feature works. It counts up but temp and humid stay at zero.

I don't trust debuggers.
Give me a scope any day.

Or maybe it is just cold and dry where you are.

Do you have a pull-up resistor on the output pin of the sensor?

It's more reliable to use print statements than relying on a debugger to try and meddle with the normal operation of a program, especially one that's as timing sensitive as this.

@TolpuddleSartre:
I don't think it's that cold and dry where I am. A prove could be, that I'm sitting here with a t-shirt and I don't feel cold. :wink:

@wvmarle:
I tryed print statements, too. But they're displaying zero, also. So this should not be the problem. BTW: How is it possible to see print statements with the Arduino IDE? As I know it doesn't have any debugging possibility.

tyradux:
@TolpuddleSartre:
I don't think it's that cold and dry where I am. A prove could be, that I'm sitting here with a t-shirt and I don't feel cold. :wink:

For all I know, you could be a Geordie on a night out.

Open the Serial monitor (ctrl-shift-M) to see the messages printed to Serial, and make sure it's set to the same baudrate as the Serial.begin() command dictates.

How about the pull-up resistor? Without it, it won't work ever.

wvmarle:
Open the Serial monitor (ctrl-shift-M) to see the messages printed to Serial, and make sure it's set to the same baudrate as the Serial.begin() command dictates.

How about the pull-up resistor? Without it, it won't work ever.

OK, I'll try that with the serial monitor. I have a pull-up resistor on my breadboard. So that should not be the problem.