Notifications
Clear all

DHT Sensors

31 Posts
7 Users
0 Reactions
3,753 Views
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

Ok, let's make sure we are on the same page.

 

* Have you ever got the sensor to work while connected to the 5V source, power switching or not?

    If not we may have new problems to deal with.

* If you haven't got it to work while connected to 5V, did you level shift the 5V signal out of the sensor down to the 3.3V signals your processor needs. If not please do this before damage is done to the processor. Or switch back to the 3.3V source for the sensor.

 


   
ReplyQuote
(@mikeburton_2000)
Member
Joined: 5 years ago
Posts: 22
Topic starter  

@byron Hi again Byron. I think it's my poor description that's clouding the waters.

If the sketch is left as is and D5 is used to connect to VCC on the sensor, it will power up when the pin is on, but the sensor returns "nan".

With no other changes, only moving the VCC of the sensor to either a 3v pin on the MCU or 3.3v or 5v supply from a breadboard power supply, then the sensor returns a T & H reading as it should.

In another scenario, again with the same sketch set up using D5 to switch a 2N2222 transistor in turn switching on the sensor, it again returns nan.

I've also tried connecting it into the transistor switching the soil moisture probes on the larger project (different example of the same NodeMCU) but again, nan is the result.

I am awaiting some PNP transistors to come to try instead of the NPN, as per the reply from Ruplicator above.

I hope this clears things a little but let me know if not. Thanks again for your assistance.

Ooops, I did it again!


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1123
 

@mikeburton_2000

OK a couple of thoughts for what they're worth. From your explanation the only difference from a working DHT11 to a not working one is how you supply the VCC.  If 3.3 or 5 volts is direct supplied it works but if VCC comes from the D5 is does not.  So whats going on with D5? Well you are driving it high though code. but whats voltage are you getting from the pin.  Also, the 3,3 or 5 volts supplied direct to VCC is presumable on all the time.  What happens if you put a switch in this circuit to mimic the on-off you do with the D5 pin in code. Does the DHT11 still play?

This post was modified 4 years ago 2 times by byron

   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

Mike,

Trying Byron's suggestion is good and will give you another diagnostic point. I believe this is all pointing to 2 different problems in the same area.

1. Trying to drive the DHT directly from the GPIO is not providing enough stable power to the sensor. The 3.3V output is very close to the DHT11's operational limits and any fluctuation in the sensor's power source is causing data corruption which results int nan you keep seeing.

2. Trying to use the 2N2222 means you are not switching the power to the sensor but you are removing the ground. If it was a perfect world where transistors were perfect switches it wouldn't matter. But the transistor has a voltage drop across it when it is turned on. The 2N2222 is one of the better switching transistors with only about .3 volts between the collector and emitter when it is turned on hard. However, this means your sensor's ground is not the same as the processor and this is never good when trying to transfer digital data.

After reading the spec sheet I believe you will need to use the 5V source (because of transistor losses) and you will need to also add a capacitor between the PNP transistor's output collector and ground. My guess it will need to be larger than what the spec sheet called out as it was written with the assumption that power would be continuously supplied with no components in series between the sensor and the supply voltage. You may want to start with something like a 1 uf and see if that is enough.

Also when I proposed the PNP circuit I was thinking your processor would have and open collector output on its GPIO pins during output. That is a mistaken assumption on my part. The GPIO pin on your processor swings between 0V for a LOW output and 3.3V for a HIGH output. The base on the PNP transistor connected in the configuration I proposed earlier will be setting .6V below the supply voltage ( 5V - .6V = 4.4V). You can see the GPIO pin does not go high enough to ever turn the PNP transistor off. 

There is an easy solution. Use your current 2N2222 setup to drive the 4.7K resistor on the base of the PNP transistor. When the existing 2N2222 is turned off it will place 5V on the base of the PNP turning it off. When the 2N2222 is turned on current will flow through the PNP emitter to base junction turning it on, providing power to the sensor.

Don't forget that you will need a voltage divider on the sensor's data pin to ensure there is no damage done to your processor. The sensor will now output 0-5V on its data pin and your processor input accepts 0-3.3V.


   
ReplyQuote
(@mikeburton_2000)
Member
Joined: 5 years ago
Posts: 22
Topic starter  
This post was modified 4 years ago by MikeBurton_2000

Ooops, I did it again!


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

Glad to hear of your progress. I also tried the ESP8266 on a weather station project I'm working on but unfortunately I had to switch to the ESP32 because the number of I/O pins on the ESP8266 was much less in reality than I thought. Have you thought about making your own capacitance probes? 

 


   
ReplyQuote
(@mikeburton_2000)
Member
Joined: 5 years ago
Posts: 22
Topic starter  

@ruplicator Yes I would like to make the probes at some point. I am taking baby steps at the moment in developing my ability but it is something I am interested in trying. I made the resistive probes because I understood how and why they work as I use something similar in my work. I am balancing things around available time for the hobby and "real life" at the moment and whilst we are in the midst of this pandemic I find I have some extended periods of hobby time followed by random periods of manic working time. 

I will continue to tinker and add to this project until I have something I am happy is working correctly and has the possibility of a sensible life span. As it is with the cheap sensors etc I don't think it is a viable long term 'product' and despite it only being for my personal interest it needs to last.

Adding the auto watering for certain zones within the greenhouse comes next but the pumps and valves will have a bit of power draw so I am awaiting the Orient Express to bring the solar power stuff to run it all. Then as we head towards winter, everything will need keeping warm, so there is an excuse to add temperature control too.

The whole reason for picking up the gauntlet with microcontrollers again was because I want to make a rig to test 3 phase BLDC pumps I use at work. I have a lot to learn to before I get to a solution for that and this project was a complete diversion (though most if not all the principals in the project can relate back to things found in my work), but I have learned some valuable stuff - not least the power of community!

Ooops, I did it again!


   
ReplyQuote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 

@ruplicator

I'm curious as to what you are doing that requires so many IO pins?

For my master station, it's primarily a Collector from the remotes using the LRF24L01's to communicate with all of the remotes.

So far, it appears that the Arduino NANO could be used for the remotes which would only report Temp, Humidity, & possibly a soil moisture Reading to the Master...  when the Master calls for it.

The Master will probably be the UNO because of the Program Memory required...  but will not be strapped for IO pins.

Thank you.

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

A little background to explain all the I/O required for my project. The weather station project I'm working on uses ultrasonic sound for wind speed and direction. The 4 sonic transducers used for measurement have to be used in both transmit and receive mode. To accomplish this and use low-cost components I used the transducers from 2 HC-SR04 and an analog multiplexer to route the signals from the transducers to one HC-SR04 logic unit.

The I/O requirements are 2 outputs for mux addressing and 1 for mux chip enable. One output for the HC-SR05 trigger and one input for Echo. So just for wind measurements there are 4 outputs and 1 input. The other sensors in the station include rain amount and rate requiring one input, a BME280 for temp, humidity and pressure taking 2 pin for the I2C interface, one analog input for the UV sensor and another digital input for particle detection unit for pollen detection.

The ESP8266 was very close to accomplishing my needs but there are additional restrictions that some pins can't be pulled low and other can't be pulled high during boot that I was not aware of when I started with the MCU that kept tripping me up. After several days of research, trial and error experimentation, no combination gave the needed I/O without a restriction.

The ESP32 is much more functionality than I needed but for a similar cost I now see why people are switching to it. In my short experience with the two MCUs I found the ESP32 is less finicky about it's power requirements and has significantly less got-ya's on boot restrictions.


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 

@mikeburton_2000

I think a lot of us hobbyist are in the mode of having a solution that is looking for a problem they can solve. It's great to see some practical application for these MCUs.

I was watching a YouTube video last night about a guy who built a robot (it looked very much like a scaled-up version of a 3D printer) called FarmBot.  The bot had access to several different types of tools that magnetically attached to a movable head for planting, watering and weeding. It looked like a lot of technology and cost to solve minor problems. But is was fun to watch it watering and weeding unattended.


   
ReplyQuote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 
Posted by: @ruplicator

@mikeburton_2000

I think a lot of us hobbyist are in the mode of having a solution that is looking for a problem they can solve. It's great to see some practical application for these MCUs.

I was watching a YouTube video last night about a guy who built a robot (it looked very much like a scaled-up version of a 3D printer) called FarmBot.  The bot had access to several different types of tools that magnetically attached to a movable head for planting, watering and weeding. It looked like a lot of technology and cost to solve minor problems. But is was fun to watch it watering and weeding unattended.

Do you have a LINK to such a Video?!   Sure sounds interesting!  YES?!

And it knows a weed from a tomato seedling?  🙂

 

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 

@ruplicator

WOW!  You're really into it!

I picture Remotes...  Wind Reporting Remote...  Rain Measurement Remote... Temp., Humidity, Pressure Remote...  Pollen sensing Remote...  etc. etc.

Then, in the Master Station, all remotes will be interrogated as required gathering & processing it's information...  Setting OFF any required ALERTS and communications to Action Remotes like Turn on the Water...  Activate Weed Eating remote...  Remote to call the cat due to recognizing a mouse / rat...

The Master is just controlling when to look at the various remotes... 

All remotes having their own I.D. Char/number... using the NRF24L01's to communicate to the Master,   Saving all readings (+ date & time stamp) from all remotes to a SDcard file for further analysis... as well as Displaying key information on a screen...  Buttons to control various screens for various types of information.

Some remotes may be super simple using the ATiny MCU...  NANO...  UNO...  as required to do the job.

Result is using the KISS principle... 

The Master may have to be a MEGA just for the additional memory that may be needed.  (?)

Am I on the wrong track thinking this way?

Bill has done a great job in introducing & working with the ESP32...  Makes one think a little... 

Could be using an ESP32 CAM in certain Remotes to report VIDEO of someone stealing those Avocados from your avocado tree, sounding off a Silent alarm causing the police to be called, if required.   

Of course, the WeedEating Remote would have to have the ESP32 Cam so it could detect good-stuff from weeds!  🙂   

Then comes the Laser Armed Remotes to detect insects like Grasshoppers, Beetles, etc. and ZAP them in their tracks stopping them from eating those great tomatoes, etc.!

Isn't this FUN!  🙂

 

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @joelyddon

Do you have a LINK to such a Video?!   Sure sounds interesting!  YES?!

And it knows a weed from a tomato seedling?  🙂

Here is the link to FarmBot

And yes and no on does it know weed from seedling. Since it is used to plant the seedlings it knows where they should be and it was implied that it tracks the growth of the plant. With that information any thing outside of the calculated area of the plant is defined as a weed.


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @joelyddon

WOW!  You're really into it!

Ha ha! Well not to that degree. I only got into this stuff a month or so back. I had dabbled in software in my career but nothing serious, just small hacks to solve specific problems. But being exposed to these inexpensive MCUs and sensors peeked my interest. Like most I wanted to try something that would use a number of functions and would like to create something useful. 

The primary thing that got me fired up was the discovery of the sonic wind sensor. Even though I could buy one off the shelf I was very interested in the technology, the math, the fact there would be no moving parts and I thought I had a chance to build some of it myself. The rest of the sensors got added just because I could.

Using components from HC-SR05 that is built for measuring distance and repurposing them to measure the difference in sound speed due to wind movement was very appealing to me. Using these sensors for an outdoor project is not the smartest idea but it started as more of a proof of concept and if it appears to work I can always change them out.

I must admit I'm at the limit of what the HC-SR05 and it's components can perform. I now have is a lot of software involved to make up for its lack of repeatability and the noisy environment. My current environment is a mass of wires on a breadboard. The electrical noise with all the sensors running is having a significant impact on repeatability of my wind sensor readings. When I recently moved to the ESP32 I had to rebuild most of the circuitry. I started with the wind sensor and got very stable reading with no other sensors operational. So I'm hoping the move from breadboard to perf board will reduce the electrical noise associated with long wires.


   
ReplyQuote
JoeLyddon
(@joelyddon)
Member
Joined: 5 years ago
Posts: 157
 

@ruplicator

Thank you!

That's awesome!  It's just like a CNC machine!!

Great work he did...   If he could use a Magazine for seeds, it could be a lot faster to plant'em!  🙂 ll seeds might be a problem... very fine to larger...  looks like it would like Radish & onion seeds...

Yes, if he used a Pi with a Camera, it could be trained to recognize GOOD plants vs weeds and pluck'em before they got very big.

Thank you!  COOL!

 

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


   
ReplyQuote
Page 2 / 3