I'm new to this community and I've a project which I need to finish for my university.
I have two sensors (MQ-135, 5v and BMP180, 3.3v) and they're connected to my Arduino Uno, everything works fine. I want to share this data from my Uno to my ESP32 but after some research, I found out that Uno's 5v electricity won't be good for my ESP32's 3.3v and that level shifter is the best solution but I don't have a level shifter nor have time until it arrives from AliExpress (ebay or amazon are not available in my country).
I'm a CS major and my knowledge about electronics is on a minimum level. This is my sketch right now: https://i.imgur.com/Vns9vcA.png. To this I want to add just an ESP32 and send data from my Uno to it.
Can someone please tell me how can I make this voltage divider? I do have resistors but I don't know how to wire them properly and don't want to experiment on my own because I have only one ESP32 and having it die, I'll fall my subject. I know all the theory behind the voltage divider, formulas etc but I'm not 100% sure how to wire it.
Here is how I connected my Uno to an ESP8266 using a voltage divider on the serial port. It would be the same for ESP32. The resistors could be 1K (R1) and 2K (R2) or 10K and 20K or any values as long as the ratio is 1:2. This is using software serial where Uno pin 8 is RX (to ESP TX) and Uno pin 9 is TX to ESP RX.
Thank you so much for your answer, I'll try it out.
One more question, is this used for bidirectional communication? If yes, is the "construction" of the resistors the same for unidirectional (because I need unidirectional communication, just Uno -> ESP32).
Yes. if the Uno is only sending to the ESP the Uno TX voltage (5V) must be dropped to 3.3V for the ESP RX input.
Note that if one way communication, only, is required you can save a pin on the Uno by not connecting the UNO RX pin and telling SoftwareSerial not to use a pin for RX by using a constructor like: SoftwareSerial softPort(-1, 9);
so only a TX pin is defined.
ieee488:
Just curious whether it would be possible to connect MQ-135 to ESP-32 using voltage divider and eliminate the Arduino Uno.
.
Paul__B:
My question exactly. If you have a vastly more capable microcontroller in the ESP32, why do you want a UNO?
Yes, that is an option as well but my project is defined that way. I guess that my professor wants us to struggle more
groundFungus:
Yes. if the Uno is only sending to the ESP the Uno TX voltage (5V) must be dropped to 3.3V for the ESP RX input.
Note that if one way communication, only, is required you can save a pin on the Uno by not connecting the UNO RX pin and telling SoftwareSerial not to use a pin for RX by using a constructor like: SoftwareSerial softPort(-1, 9);
so only a TX pin is defined.
Thank you for the answer sir. One more question if you have time: I noticed that I have 10k resistors but not 20k. Can I combine two 10k resistors and have them "behave" like one 20k?
anthino12:
Yes, that is an option as well but my project is defined that way. I guess that my professor wants us to struggle more
It would certainly seem that way.
By the way, you do not need a voltage divider to connect a 5 V output to a 3.3 V input. You use a diode with cathode to the 5 V output and anode to the 3.3 V input. It that input does not provide a pull-up resistor, you provide a pull-up to 3.3 V. It may also be appropriate to use a low value pull-up resistor (the Arduino can easily and safely drive a 470 Ohm resistor) to speed up the response.
The advantage is that the diode is much faster to pull down and draws no current when the data is HIGH.
By the way, you do not need a voltage divider to connect a 5 V output to a 3.3 V input. You use a diode with cathode to the 5 V output and anode to the 3.3 V input. It that input does not provide a pull-up resistor, you provide a pull-up to 3.3 V. It may also be appropriate to use a low value pull-up resistor (the Arduino can easily and safely drive a 470 Ohm resistor) to speed up the response.
The advantage is that the diode is much faster to pull down and draws no current when the data is HIGH.
Can I use LED diode for data transfer (for example Arduino JSON object) from Uno to ESP32? This seems like a more simpler solution. Thank you so much sir.
groundFungus:
two 10K resistors in series equals 20K.
////_////__
10K 10K
I've made a circuit but I don't know if it's wired properly. If you have time, can you please check my wiring and see which one is correct?
This is the first option: https://i.imgur.com/8QzXTi0.png (I have two 10k resistors combined in series, the first ones from left to right. I watched a few tutorials yesterday and I guess I nailed them. I'm not really sure if the third one should be placed there. On this way I have one (two 10k) 20k resistor and one 10k. The platform where I created the circuit didn't have ESP32 microcontroller on it so guess that the upper Arduino is an ESP32)
Thank you for answering sir and sorry for my ignorance.
I was struggling with "translating" an electronic circle to, let's say, real life circle and that's why I couldn't wire it properly I guess. I downloaded a software that "translates" an arduino project to a circle and I got your circle on the end.
Can you approve if the wiring now is correct?
I uploaded my two images but if you don't want to download them, here's a link for them: