Chat freely about anything...

User avatar
By SentinelAeon
#88574 Hello,

I am making a simple control system using technology that i have been using for about 2 years now with no problems. This is the first time i have a bit of difficulty.

Hardware:

1) ESP8266 Wemos D1, powered through 5.1V (external 12V 2A power suply + step-down to get 5.1V, step-down can supply up to 1.5A, much more than i need)

2) 4x DHT22 sensor

Alright so this is 4 sensors on an ESP8266. I power the sensors from the 5V pin on esp8266 board. To clarify, i tried also using 3.3V pin on wemos d1 board with no difference.

Pins used:

- D2, D3, D4, D5 (here i am talking about pins on wemos d1 board, that is, that is how pins are numbered on a board)

The sensor wires are about 1-1.5m long, i used old UTP cable for that.

This is the first time i am actualy using 4 sensors on 1 board, till now i only used 1 or 2 at most. As you can see on image in the attachment, first 3 sensors on pins D2, D3 and D4 are working ok, only the sensor on pin D5 is giving me trouble. I tried switching sensors/wires to see if it helps, i even tried connecting a separate sensor with only 10cm long wire to it, with no difference.

Software used:

- arduino ide and i am using a DHT library for arduino, gave me no problems so far.

Code:

Code: Select allfor(int i=0;i<3;i++) {     

    sensor4_temperature = dht4.readTemperature(); // Gets the values of the temperature 

    if(!isnan(sensor4_temperature) && (0 < sensor4_temperature < 100)) break;

    else {

      delay(50);     

    }     

}


So what could be the problem in this case ? Right now pin D5 is giving me problems but yesterday it was pin D4. My first thought would be the long cables but i read that some people use DHT22 on cables as long as 20 meters and have no problems. And even if this is the reason, it makes no sense that when i connect the sensor with short cable, it makes no difference.
Attachments
server.JPG
server.JPG (23.6 KiB) Viewed 3811 times
User avatar
By eriksl
#88603 Yeah, I really think it's the long cables, indeed.

I'd use I2C sensors instead. They can span a few meters without issues. If you need more sensors than addresses available, you can use an I2C bus multiplexer. This will also add extra pull-up to the lines thereby making it less susceptible to noise. For the ones loving an adventure, you could use an I2S bus extender, which makes it possible to span over 50 meters. Engineers at NXP even managed to span 200 meters with some carefully chosen cable and resistor values.

Or even more simple (which I also tend to do), have every location where you need to have (a) sensor(s) it's own ESP8266.
User avatar
By SentinelAeon
#88636 Thank you for your replies. I am infact running out of pins on my ESP8266 wemos d1 mini board ... i am only using 2 pins for relays, 4 pins for sensors and all i am left with are 3 for status leds ... in reality i would need at least 8 leds for it to be optimal. So if using I2C can run all sensors on a single pin, that would be awesome. Could you please give me some direction, maybe on a similar sensor as DHT22 (it would be great if it was of similar price and had a nice library written for arduino, to save me some work) and also this multiplexer you mentioned ..

I still decided to write some of my findings about the sensors. I did some more testing and things are interesting. Right now i have the ESP8266 wemos d1 connected to usb port of my computer. And for some reason sensor 3 isn't working. I tried swaping the existing 1m cable with a short 10cm wires and it still isn't working. But there are 2 ways i CAN make it work. First is simply disconecting and reconecting the sensor while the program is running. That will fix it and it will run no problem. And second is using anything other than computer to power the board. So far i tried a mini 5V DC phone charger, i tried powerbank and i tried using step-down to get from 12V to 5V. It all works without a single error. As soon as i use computer, sensor 3 is giving me problems. I tried different usb ports, front ones, back ones on motherboard, i even tried the USB 3.0 port just to make sure its not running out of juice. Since all USB ports are able to give out 100x more amps than the sensors need, i am thinking, could it be the problem of interference ? Swapping sensor makes no difference, its the same with any sensor and any wire length.

Now this won't be an issue since i will be using external power suply. But it still makes me wonder what could be the reason.

To sum it up:

1) Sensor 3 is giving problems (Sensor 3 is on D4 pin of the ESP8266 wemos board). That is supposed to be GPIO2 pin so i am wondering if there is anything special about it that is giving the problems.
2) Using a different sensor OR using a short 10cm wires makes no difference.
3) Only see this problem if using ANY USB port on pc to power the ESP8266 wemos d1 mini board. If i use anything else, any external power suply, the problem disapears and all sensors read with no errors.
4) Even if i run it from computer usb and i get errors AKA not even 1 succesful value read from sensor ... if i disconect the sensor while the program is running and i reconnect it, the sensor will work properly from that moment on. But if i disconect USB cable and reconnect it, i will get errors again with not a single succesful read (nan value on sensor non stop).

So what do you say, is it pc interference ? Because as far as amps go ... usb 3.0 is supposed to be able to provice 0.9A .... while the gsm charger i used is 1.55A ... both of them should be able to handle not 4, but 100 of those sensors no problem.