-1

I have a circuit with a Schmitt trigger connected to GPIO 23 (on a Raspberry Pi Zero W).

It should give a high (3.3V) signal when there is an AC current on the other side of the circuit.

If there is no or a very low current, the Schmitt trigger

gives low as an output (the output of the circuit is pulled down to ground with a 10kOhm resistor).

The AC current has a frequency in the range of 1-20 kHz.

This circuit is working as it should as far as i can determine by testing it with a function generator and oscilloscope.

It is also working if there are no other wires attached to the Raspberry Pi. There is a wire which is about 2 meters long and ends on a WS2812 led strip. If this wire is connected to GPIO 18, the state of GPIO 23 changes somehow to high even if there is no AC current on the Schmitt trigger circuit. Does anyone know what causes this behavior and if there is maybe a workaround for this?

Edit:

Here is the circuit which is connected to GPIO 23: enter image description here

The connection of this circuit and the LED strip to the Raspberry PI is the following: enter image description here

A code to reproduce the error is as simple as this:

import RPi.GPIO as gpio
gpio.setmode(gpio.BCM)
gpio.setup(23, gpio.IN)
gpio.input(23)

If the LED strip is not attached on GPIO 18 and to ground then the last line will give 0 when there is no input signal to the circuit connected to GPIO 23. But with the exactly same setup and with the LED strip attached to GPIO 18 and ground it will give 1. I also measured the exact voltage value and it gives 3.3V on GPIO 23 in this case. This is the value which the Schmitt trigger gives when it is in high output mode.

Update:

When the 2 meters twisted cable is connected to the Raspberry PI but not to the LED strip the error does not appear. So i dont think the problem is due to interference with other electrical devices.

It is also unlikely that it is caused by a malfunction of the Raspberry Pi Zero W itself; i tried it with another new Pi Zero and another original Raspberry Pi power supply and the behavior stays the same.

If i only connect one wire (the ground or the data wire) to the LED strip the error also appears in both cases.

So i am pretty sure it has something to do with the interaction of the Raspberry Pi with the external 5V power supply of the LED strip.

But what can that be?

When i measure the Voltage between ground of the Raspberry Pi and +5V of the power supply (if unconnected) i don't get 5V as expected but some millivolts instead.

The voltage between the - of the power supply and ground also gives some millivolt.

The strange thing is that the power supply works as expected and it delivers 5V to the LED strip.

Controlling the LED strip with the Raspberry also works as it should. How can that be?

4
  • You need to add a wiring diagram to clarify the circuit.
    – joan
    Commented Aug 19, 2023 at 9:57
  • please add the wiring diagram and the code to your question
    – jsotola
    Commented Aug 19, 2023 at 18:52
  • Where did you get this circuit - from a tutorial, or a "how-to" page on the Internet? It may simplify things if you could share that.
    – Seamus
    Commented Aug 19, 2023 at 22:00
  • I designed it by myself Commented Aug 20, 2023 at 16:41

1 Answer 1

0

Connecting a long wire aka antenna to a Pi (or indeed ANY CMOS circuit) is likely to induce interference.

You have no filtering between the (unspecified) AC Input and the Pi and no isolation (which most of us would consider mandatory). Incidentally the Pi GPIO have hysteresis so a Schmitt trigger is unnecessary - and a Schmitt trigger is triggered by Voltage not current.

We can only speculate on the physical layout and propensity to interference.

Given the above it is hardly surprising that you get unexpected results.

5
  • Thank you for your answer. Could it maybe help in this case to isolate the long wire with adittional aluminium foil? And what do you suggest for filtering? Commented Aug 20, 2023 at 16:49
  • NOTE I am not talking about shielding - you need galvanic isolation. Most of us would use an opto-isolator. Use ceramic capacitors as bypass - or any with high frequency capabilities, which electrolytics aren't.
    – Milliways
    Commented Aug 20, 2023 at 22:50
  • Do you mean to apply this to the circuit with the Schmitt trigger or to the LED strip or to both? The frequency of the AC input is something in between 1 and 20 kHz so i think the electrolytic capacitor fits for that. Commented Aug 20, 2023 at 23:30
  • As I stated "You have no filtering between the (unspecified) AC Input and the Pi and no isolation". NOTE this belongs in your question - not in Comments.
    – Milliways
    Commented Aug 21, 2023 at 0:22
  • Any long wire aka antenna will pickup radio signals regardless of what you connect. The Pi is sensitive to these.
    – Milliways
    Commented Aug 21, 2023 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.