ESP-12E nodeMCU v3.0

Hi, Sorry to post this here, but I am stuck and can't get my question posted on the esp8266 group.

I have an ESP-12E nodeMCU ver 3.0 to replace my arduino nano and esp01 for a temperature project. I am able to compile fine and turn and LED ON and OFF, but when I try to read from a DHT22, I get "nan" in the serial output.

I read somewhere that the pins on the module are messed up or something. I found the info below, but I am not sure

whether D0 means pin D0 on the board or D0 in the software. Can someone please clarify

[I use the 1.8.3 arduino IDE]

static const uint8_t D0 = 16;

static const uint8_t D1 = 5;

static const uint8_t D2 = 4;

static const uint8_t D3 = 0;

static const uint8_t D4 = 2;

static const uint8_t D5 = 14;

static const uint8_t D6 = 12;

static const uint8_t D7 = 13;

static const uint8_t D8 = 15;

static const uint8_t D9 = 3;

static const uint8_t D10 = 1;

whether D0 means pin D0 on the board or D0 in the software. Can someone please clarify

Yes. Both.

D0 is a slightly strange pin, with some limitations but also a very useful purpose that no other pin can do. So try another pin.

Thanks. Actually left side is the physical pin, right side is the programming pin. So for future reference in case it might help someone, when I wire to pin 1, my code says

int outdoor_PIN = 5;

My board only has pins D1 to D8, A0 and S1 to S3. That would make the above table invalid.

I think it will be much less confusing, to others and to your future self, if you put

int outdoor_PIN = D1;

Then your code matches your wiring.

So, does the dht22 work ok on D1?

The table you found relates the pin names printed on the board to the ESP's GPIO pin numbers. You can use either in your code, but to me it makes much more sense to use the ones that are printed on the board.

Not sure what you are saying is invalidated or why, unless you mean that your board does not have D9, D10 pins. I think those pins are not useable to you and me because they are dedicated to some other purpose such as acessing the flash chip, as are S1 to S3.

I know the NodeMCU boards have quite a few pins that are of little or no practical use. That's one of the reasons I prefer the Wemos mini boards. They are more compact because they don't have those less useful pins.


Sorry for the very late reply. It’s been a while since I worked on it, but in my code I put this

int outdoorPin = 5;   // Physical PIN 1
int indoorPin = 2;    // Physical PIN 4

At the present time I forgot if wiring to pin 1 worked or not, but I remember testing with a DHT11 and a DHT22 and they both worked, but when I put the board in production the DHT22 didn’t work. Now that you are asking whether it worked for me on pin 1, i am guessing there is a reason it shouldn’t? May be that is what I did wrong.

I’ve been waiting for a spare one to test with, but it takes forever to come from China.

I have to mention that the one in my production environment is connected with a longer quad cable, but the distance is not that long may be 6 ft. It is a different DHT22, but I know it works because I currently have it connected to an arduino nano with a ENC28J60 module that I passionately hate

When you use

int outdoorPin = 5;

in your code, that means GPIO5, labelled D1. It is not the same as "D5".

Thanks. I changed it in the code. That makes it a lot easier rather than have to do a translation. I am having an issue with the DHT22. When I place it outside with about 6' cable I get 'nan' as a value. When I place a test DHT22 right on the board I get values. Do you think 6' or 8' could be the cause? I tried to power it with 3.3V from the board and I tried 5V from an external power source. Same thing.

I will measure the voltage tomorrow, but I was hoping for a quick answer.

The length and/or quality of the cable will be the problem. Do you have a pull-up resistor on pin 2 of the dht22? If not, try 10K. If you have one, try lower values: 10K, 4K7, 2K2, 1K, 470R. Use the highest value that works reliably.

If that does not work, the problem may be that there is some voltage drop in the cable and the dht22 is getting less than 3.3V, which is on it's limit anyway. Try powering it with 5V to pin 1, but connect the pull-up resistor between pin 2 and 3.3V, not 5V. Exposing the esp pins to 5V, even though a resistor, could damage them.

I measured the 5V at the source was 4.88 at the DHT22, so I decided to keep the additional supply. I am not exactly sure where to put the pull up resistor. I searched and found some sites have it between the D2 and the -ve and others between D2 and the positive. In any case, it still doesn't read values.

The good news is I just received the new boards I ordered, so I'll try to test them with a long cable and see if I can get it to work.

A "pull-up" resistor connects a pin to +V. A "pull-down" connects a pin to -V/GND. DHT22 data pin needs a pull-up.

In case I am using an external adapter with the -ve wired to the -ve of the esp12e, do I wire the resistor to the 3.3v of the board or the 5v of the adapter?

sed003: do I wire the resistor to the 3.3v of the board or the 5v of the adapter?

See post #7

sed003. I realize this thread hasn't seen any activity for over 120 days, yet,I have seen this seem issue with a BME280 sensor: I had to change the Serial Monitor's baud rate. Or if all you get are ??????????????, it's the baud rate.

OTS_Engineer:
I have seen this seem issue with a BME280 sensor: I had to change the Serial Monitor’s baud rate.

If changing the serial monitor baud rate fixed it, it was nothing to do with the bme280.

OTS_Engineer: sed003. I realize this thread hasn't seen any activity for over 120 days, yet,I have seen this seem issue with a BME280 sensor: I had to change the Serial Monitor's baud rate. Or if all you get are ??????????????, it's the baud rate.

I am confused about your post. Not sure if you are asking a question or providing feedback. For the nodemcu I usually use 115200 unless I run into issues then I slow it down to 9200. For reading data from a temperature sensor we don't use baud rate.

pinMode(D3, OUPTUT); // in setup() int x = digitalRead(D3); // in loop()

where D3 is the pin on the nodemcu.

This example is in its simplest form. I am not familiar with your board, but it looks like it is a 5V board so you would need to use a dual power supply; 3V3 for the nodemcu and 5V for the temperature sensor. The examples I googled use the SDI pin.

9600 perhaps? 9200 is not a standard frequency.

You’re right