logo elektroda
logo elektroda
X
logo elektroda

[Solved] How to drive the two inputs (GPIO23 and GPIO22) on the ESP32 with an external signal?

krawietz 1563 9
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20080064
    krawietz
    Level 16  
    I need to drive an external signal to two inputs on the ESP32 (specifically, I assumed the use of GPIO23 and GPIO22), and as these are two floats drowned in tanks of water, I found that I would use galvanic separation using a two-channel module with PC817 optoisolators. Generally on the 'short' it seemingly works. For testing purposes, I apply voltage (3.7V) from the 18650 battery to the input of the optoisolator module (the target is to have 5V through these floats - they act as a jumper depending on the position) and the output connected directly to the GPIO on the ESP32 and of course to ESP ground. Generally works.... until I put it together on a prototype board, wired, added connectors etc.... Then it turned out that one GPIO works correctly (we power up the optocoupler - the state changes) oh the other one triggers both.... That is, applying power to the second optocoupler causes both GPIOs to change state.... The same happens without the optocoupler if I short-circuit the GPIO directly to ground (briefly if I short-circuit only the pins on the ESP itself this does not happen). I added 10k pull-up resistors between GPIO and 3.3V and GPIOs shorted to ground work fine, the state only changes when the GPIO data is shorted to ground. The problem is that they have stopped responding if we feed a signal through the optocoupler. Applying power to the optocoupler input changes absolutely nothing about the state of the GPIO input. What have I done wrong?

    Tailor
  • ADVERTISEMENT
  • Helpful post
    #2 20080146
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #3 20080235
    mpier
    Level 29  
    Hello,
    One problem is the lack of any schematic.
    krawietz wrote:
    The same thing happens without an optocoupler if I short the GPIO directly to ground (briefly if I short only the pins on the ESP itself this does not happen).

    This sentence is also a problem at first glance.

    Greetings.
  • #4 20080663
    krawietz
    Level 16  
    Target diagram below. I will actually check the power supply, as the target is supposed to be 5V.
    How to drive the two inputs (GPIO23 and GPIO22) on the ESP32 with an external signal? .
    Of course the yellow jumpers removed so that the input side ground is separate from the ESP ground.

    I also have 24V AC available in the circuit, supposedly some documentation for the module says that 3.3 - 24V can be applied to the input - there is a 3k resistor in series and a signalling LED. There is also a 3k resistor in series between outputs V1 and V2 and the collector.
    Another thing is that the possibility of using 24V AC would simplify the whole circuit and eliminate an additional power supply.

    Krawietz

    Added after 10 [minutes]:

    mpier wrote:
    krawietz wrote:
    The same thing happens without the optocoupler if I short the GPIO directly to ground (briefly if I short only the pins on the ESP itself this doesn't happen).
    The same thing happens without the optocoupler if I short the GPIO directly to ground (briefly if I short only the pins on the ESP itself this doesn't happen).
    This sentence is also a problem at first glance.


    This worries me a bit...
    I assembled the whole thing on a prototype board .... of this type...
    How to drive the two inputs (GPIO23 and GPIO22) on the ESP32 with an external signal? .
    Goldpin sockets soldered into the board so that the ESP can possibly be removed....
    Plus connectors for wiring about this type:
    How to drive the two inputs (GPIO23 and GPIO22) on the ESP32 with an external signal? .
    All intricately connected with single-wire cables....

    And this is where it gets interesting... The ohmmeter e.g. on adjacent pins whether goldpin socket or those for cables sometimes shows some strange resistance.... several kilo ohms... several hundred... The fields themselves in the contact board do not show such miracles.... neither do the cable connectors... And after soldering some strange stories.... All in all, I don't know if these Chinese boards soak up residual flux from the tin and make a resistor or if my ohmmeter is going crazy....

    Krawietz
  • #5 20080699
    khoam
    Level 42  
    krawietz wrote:
    the goal is to have 5V through these floats - they act as a jumper depending on position
    .
    I think the use of an opto-isolator for this purpose is a bit redundant. Wouldn't a simple divider on the GPIO input of the ESP32 suffice?
  • ADVERTISEMENT
  • #6 20081104
    Anonymous
    Level 1  
  • #7 20081122
    khoam
    Level 42  
    Mariopi wrote:
    + interference immunity
    .
    For this an optocoupler is poorly suited. It is better to use a low-pass filter on the GPIO input (and right at the input) to eliminate potential interference. As a last resort, you could even use a shield cable with the shield plugged into the ground side of the ESP.
  • ADVERTISEMENT
  • #8 20081311
    starob
    Level 29  
    krawietz wrote:
    There is also a 3k resistor in series between the V1 and V2 outputs and the collector.


    Solder them out and short the pins, they spoil the whole job. The 10k pullup (+ internal pullup of the proc?) can cause the output voltage to be too high. Have you measured the voltages on the GPIO ? - this could be a clue.
  • #9 20082012
    krawietz
    Level 16  
    starob wrote:
    krawietz wrote:
    There is also a 3k resistor in series between the outputs of V1 and V2 and the collector.


    Solder them out and short the pins, they spoil the whole job. The 10k pullup (+ internal pullup of the proc?) can cause the output voltage to be too high. Have you measured the voltages on the GPIO ? - this could be a clue.
    .

    Voltages ok, 3.1V on GPIO....
    However, a 3.7V battery is not enough for the optoisolator to work properly in this configuration.
    When 5V is applied, everything works correctly.

    Krawietz
  • #10 20082017
    krawietz
    Level 16  
    starob wrote:
    krawietz wrote:
    Between the outputs of V1 and V2 and the collector is also a 3k resistor in series.


    Solder them out and short the pins, they spoil the whole job. The 10k pullup (+ internal pullup of the proc?) can cause the output voltage to be too high. Have you measured the voltages on the GPIO ? - this could be a clue.


    Voltages ok, 3.1V on GPIO....
    However, a 3.7V battery is not enough for the optoisolator to work properly in this configuration.

    When 5V is applied to the optoisolator input from the power supply, the circuit works correctly.

    Krawietz
  • Topic summary

    The discussion revolves around driving GPIO23 and GPIO22 on the ESP32 using an external signal through galvanic isolation with a PC817 optoisolator. The user encountered issues where one GPIO functioned correctly while the other triggered both GPIOs simultaneously. Suggestions included measuring the voltage on the phototransistor's collector, checking the power supply voltage, and considering the use of a low-pass filter or alternative optocouplers for better performance. The user confirmed that a 3.7V battery was insufficient for the optoisolator, and proper operation was achieved with a 5V supply.
    Summary generated by the language model.
    ADVERTISEMENT