Logic level shifting with an ESP32

Attached is a screenshot of a wiring scheme that I have set up for testing. assume that the top power rail is 5v and the bottom is 3.3v

If I power on the esp32 with the wiring just the way it shows here, it wont actually start up.

if i removed the LLC and do 3.3v to VCC and remove the jumper for the JD-VCC and put 5v to that pin, it works (going directly from esp32 pin to IN1) only if i have 1 relay on. I am using the relays to switch 120v.

I have been working on circuits for about 6 months. so not an expert here. can someone tell me why this doesnt work?

Can't tell for sure as the image is poor resolution but it looks like you are trying to Level shift the power to the ESP32. They do not work that way. Provide a separate power bus to the ESP32 and level shift the data lines only

Supply a schematic of what you are trying to do

here is a higher resolution image

Im sorry, I dont know how to provide a schematic that can show my ESP32 like that one. What I can do is give you a higher resolution one but it is on my other computer. I can get to it a little later

The ESP32 is powered with a 5V 5A power supply that runs across the top rails of the breadboard. and the bottom rails are powered by the ESP32's 3.3v regulator

You don't really need a level shifter board. A simple resistor divider circuit (1K / 2K) would have worked. See http://www.martyncurrey.com/wp-content/uploads/2015/01/Arduino-to-ESP8266.jpg for what I mean.

Also, you only need a level shifting for the RX pin on the ESP32. TX from the ESP32 will be just fine.

Connect the top rail's Ground to the bottom rail's Ground.

I cannot tell what the other pins are you have connected on the ESP32.

I appreciate the response. There is no "Rx" from the relay board. on the esp32 those pins are just HIGH or LOW. here is another way of describing what is in the image.

5V+ -> VIN (ESP32) -> HV -> VCC (Relay board) 5V- -> GND(ESP32) -> GND (HV) - GND(Relay board)

ESP32 GPIO12 -> LV1 -> HV1 -> IN1 (Relay board) ESP32 GPIO13 -> LV2 -> HV2 -> IN2 (Relay board)

ESP32 3.3v -> LV ESP32 GND -> GND

pseudocode:

pinMode(12, OUTPUT); pinMode(13, OUTPUT);

loop(){ digitalWrite(12, HIGH); digitalWrite(13, HIGH); delay(1000); digitalWrite(12, LOW); digitalWrite(13, LOW); }

The other wiring setup i did is attached

5V to JD-VCC and VIN on esp32

VCC to 3.3v on ESP32

IN1 to GPIO12 on ESP32

GND to shared ground

LED for IN1 blinks on and off, but relay wont trigger.

20170526_143817.jpg

I am having a hard time understanding how your circuit is connected.

All I can do is suggest that you read https://learn.sparkfun.com/tutorials/using-the-logic-level-converter and connect up your circuit per that information.

The ESP family runs on 3.3V so just connect it directly to a 3.3V power supply.

There are many different relay boards. Not many are designed for 3.3volt logic. I didn't see a link, so I'm going to assume it's a common 5volt board. Connecting it wrong will put 5volt on the MCU, and will fry it.

Try this, at your own risk. Leave the VCC/JD-VCC jumper on. Connect 5volt to VCC of the relay board and V-in of the ESP. Outputs to relay inputs. Join all grounds.

Don't use the 3.3volt pin from the ESP. Leo..

Edit: No opto isolation this way. For that you probably have to remove (short) the onboard indicator LEDs, connect it differently, and use two supplies.

Wawa: There are many different relay boards. Not many are designed for 3.3volt logic. I didn't see a link, so I'm going to assume it's a common 5volt board. Connecting it wrong will put 5volt on the MCU, and will fry it.

Try this, at your own risk. Leave the VCC/JD-VCC jumper on. Connect 5volt to VCC of the relay board and V-in of the ESP. Outputs to relay inputs. Join all grounds.

Don't use the 3.3volt pin from the ESP. Leo..

Edit: No opto isolation this way. For that you probably have to remove (short) the onboard indicator LEDs, connect it differently, and use two supplies.

I just tried this, and the esp32 wont fully boot. it will power on, push some stuff to the serial port, but wont get into the setup() and loop().

The ESP32 can be powered from a 5v source, and I have other pieces in play that are 5v. I have that LLC already and when i try to use it, as per that document, the ESP32 wont fully boot. The first diagram is my attempt at wiring it up as per the instructions. I believe there is something missing. I also connected the GNDs after the first suggestion.

I would suggest wiring up just the Sparkfun ESP32 Thing alone and see if you are able to communicate with it.

One step at a time.

Don’t know the ESP32, but the ESP8266 uses some I/O pins for different (boot) modes.

Try connecting one relay input at the time to identify if one I/O pin creates that problem.
Leo…

Attached are the 3 different ways ive tried.

3.3v image = LEDs blink, code runs, coils dont react

all others = ESP32 wont fully boot

ieee488: I would suggest wiring up just the Sparkfun ESP32 Thing alone and see if you are able to communicate with it.

One step at a time.

it works perfectly fine. I also have an hall effect sensor hooked up, 4 onewire temp sensors, and 2 SSRs and they all work fine. just trying to troubleshoot and isolate this one.

Wawa: Don't know the ESP32, but the ESP8266 uses some I/O pins for different (boot) modes.

Try connecting one relay input at the time to identify if one I/O pin creates that problem. Leo..

here is the funny thing. if I wire just one using 3v3 logic 3v3 to VCC and 5v to JD-VCC it works about 80% of the time. the LED blinks on and off 100% of the time, but the coils tap about 80% of the time.

theskaz: here is the funny thing. if I wire just one using 3v3 logic 3v3 to VCC and 5v to JD-VCC it works about 80% of the time. the LED blinks on and off 100% of the time, but the coils tap about 80% of the time.

Did not see a link to the relay board yet.

Common relay boards have an opto LED, an indicator LED, and a 1k resistor in series. One end connected to VCC, the other end connected to a relay input. The opto LED and indicator LED have a combined Vf of about 3volt. With a 1k CL resistor, this results in 0.3mA LED current. Enough to see the indicator LED, but not enough to drive the opto coupler. Leo..

https://www.sainsmart.com/4-channel-5v-relay-module-for-pic-arm-avr-dsp-arduino-msp430-ttl-logic.html

here is the actual board

Exactly as I have explained.

I would try to find out why the ESP32 pin is behaving like that. Or use other pins for the relays. Leo..

ill give the other pins a shot and report back.

tested 6 other pins, all with same results. Im thinking i may have damaged my esp32 so Im going to order 2 more. I also have a NodeMCU 1.0 somewhere that I can test against in the mean time.

Just tried the NodeMCU 1.0 and same issue. I think it HAS to be my wiring somehow.