Need help designing a PCB that contains an ESP8266-01, an ATMega328P and a DHT22

Thread Starter

Roberto Oliveira 1

Joined Jan 17, 2018
2
Hey reader, this is my first PCB attempt but I'm lost, I had computer programming for 3 years and no electronics, so I code awesome and am bad at hardware. I'm trying to design a PCB in Eagle that contains the famous ATMega328P, from the Arduino Uno, a temperature/humidity sensor DHT22 (digital connection) and, my issue, a WiFi module called the ESP8266 version 01. I followed SparkFun's tutorial to do my own Arduino board, I can successfully create a PCB with the AtMega with headers, like an Arduino, but that's about it. I'd appreciate your help in assisting me to do a board that connects the DHT22 to the AtMega, so it can process the data and send it to my PC through WiFi, through the ESP.

ESP8266 DHT22:
 

shteii01

Joined Feb 19, 2010
4,667
ESP is 3.3 volt system

ATmega328 can be setup to run on 3.3 volts, but at this voltage it can only run at 8 MHz. I am telling you this because last year I bought 16 MHz 5 volt Uno board (uses ATmega328). This year I bought Pro Mini which also uses ATmega328, but it is 8 MHz 3.3 volt. Both are Arduino boards, both use the same microcontroller, but each runs on different voltage and due to voltage each runs at different clock frequency. If you apply 5 volts from ATmega328 to ESP, you can damage ESP.

What voltages does DHT22 uses?

I think it would be better design to streamline everything and use 3.3 volts on all the devices, if you can. Obviously the ESP and ATmega328 can be streamlined since they both can be configured for 3.3 volts. I have no idea about DHT22. Is there a temp/humidity sensor that is designed to run on 3.3 volts?
 

JohnInTX

Joined Jun 26, 2012
3,804
Start by posting your EAGLE schematic so far (print to PDF) showing how you have things hooked up- don't forget the little stuff like power supply decoupling, oscillator for the ATmega, etc. It is also most helpful to post datasheets to the parts you need help with. I've attached the uC, humidity sensor and WiFi module below.

Good luck and welcome to AAC!

http://www.microchip.com/wwwproducts/en/atmega328p
 

Attachments

Hi Rob, Why bother with the Mega, Why not just use One-Wire on the ESP to talk to the DHT. May I ask what the reason is to use the Mega in the circuit at all?
 

shteii01

Joined Feb 19, 2010
4,667
Hi Rob, Why bother with the Mega, Why not just use One-Wire on the ESP to talk to the DHT. May I ask what the reason is to use the Mega in the circuit at all?
I am going to hazard a guess.
They are compartmentalizing the features/functions. This way they have sensor box, "cpu" box, wireless communication box. The fact that wireless communication box can do other things is... not important, at least not important at this stage.
In addition, it is possible they "borrowed" the code and not fully understand it, so they just following the "recipe" because it works and, in the end, that is the most important.
 

Thread Starter

Roberto Oliveira 1

Joined Jan 17, 2018
2
I am going to hazard a guess.
They are compartmentalizing the features/functions. This way they have sensor box, "cpu" box, wireless communication box. The fact that wireless communication box can do other things is... not important, at least not important at this stage.
In addition, it is possible they "borrowed" the code and not fully understand it, so they just following the "recipe" because it works and, in the end, that is the most important.
I reversed engineer the code and I want the AtMega because of the expansion, those boxes will get themselves even more weather sensors and I only really know how to work with the AtMega. Plus I'm an programmer only, I'm still starting with electronics, I don't still know all the abilities of my components. The code library is from GitHub, the rest is mine.
Having that said, I'm still trying to design the PCB, I need to read a lot about digital electronics before I can do something that doesn't short as soon as I plug it.
Also, the DHT22 uses prefers 5V, that's why I would love to supply 5V to the DHT22 and add a crystal oscillator to the CPU to get more clock speed, the way things are evolving, the final piece will have too many components for only 8MHz, of course I'm not sure if it's enough or not, not exactly an expert but I'm trying.
 

shteii01

Joined Feb 19, 2010
4,667
I reversed engineer the code and I want the AtMega because of the expansion, those boxes will get themselves even more weather sensors and I only really know how to work with the AtMega. Plus I'm an programmer only, I'm still starting with electronics, I don't still know all the abilities of my components. The code library is from GitHub, the rest is mine.
Having that said, I'm still trying to design the PCB, I need to read a lot about digital electronics before I can do something that doesn't short as soon as I plug it.
Also, the DHT22 uses prefers 5V, that's why I would love to supply 5V to the DHT22 and add a crystal oscillator to the CPU to get more clock speed, the way things are evolving, the final piece will have too many components for only 8MHz, of course I'm not sure if it's enough or not, not exactly an expert but I'm trying.
Ok. So the main voltage for the system is going to be 5 volts.
The way Arduino have been doing it, they put two voltage regulators on their boards, one regulator for 5 volts ATmega328, one regulator for 3.3 volts. I suggest you copy that setup/pcb layout from Arduino, they provide it for free. However, run output of 3.3V regulator to the ESP since I hope that will be the only unit that needs 3.3V.

The problem with above setup is that ESP uses 3.3V for IO. 328 will send 5 volt pulses during serial communication with ESP, ESP is not designed to receive 5 volt, it will work for a while, but how long I can not tell. There are ways to make 5V and 3.3V systems talk to each other. The best is to use level translator chips that are actually made to step down 5V to 3.3V and step up 3.3V to 5V when ESP talks to 328. This is important because I assume you will have bidirectional communication, 328 to external system and external system to 328. If you only need to send data from 328 to some external system using ESP wifi, then you don't need fancy chips, just use resistors to step down 5V to 3.3V, ESP will receive the data and send it on.
 
for a 5v to 3.3 use and use a 20k resistor and 10k resistor to convert the logic. Plus I thought Espressif posted a blog about the pins being 5V tolerant (Dead horse topic, just use the voltage divider). I know you listed a few things to have more sensors and I get were your coming from. But the DHT I think run's on 3.3 just fine. I have one on my desk hooked up to the ESP as we speak. Check this out.

https://www.aliexpress.com/item/WEMOS-D1-Mini-Pro-16M-Bytes-External-Antenna-Connector-NodeMCU-ESP8266-ESP8266F-CP2104-WIFI-IOT-Development/32826379039.html?src=google&albslr=227020878&isdl=y&aff_short_key=UneMJZVf&source={ifdyn:dyn}{ifpla:pla}{ifdbm:DBM&albch=DID}&src=google&albch=shopping&acnt=708-803-3821&isdl=y&albcp=653153647&albag=34728528644&slnk=&trgt=68416666751&plac=&crea=en32826379039&netw=g&device=c&mtctp=&gclid=EAIaIQobChMItcy--sr92AIVkoF-Ch33MA9jEAQYASABEgJPIfD_BwE

That chip is 3.3 and has a 5V supply AND AND is 80MHZ :)
 
Top