0
\$\begingroup\$

I'm trying to build a simple circuit that allows a Raspberry Pi to detect AC voltage in a piece of wire inductively.

I have the following circuit which basically uses an antenna wrapped around the wire to collect stray capacitance, triggering a series of transistors that steps the voltage up to 5 V:

schematic

simulate this circuit – Schematic created using CircuitLab

The circuit above works great, and the LED comes on when 120 V AC is live near the antenna.

My problem is that when I connect the circuit to an input pin on the Pi, the Pi reads inconsistently. When off, it reads correctly as off, but when on, it reads as if the pin is only receiving signal for a second every few seconds.

schematic

simulate this circuit

I feel like it has something to do with the input pin not providing enough of a ground for the transistors to fully saturate, because when I put an LED inline with the input line it only comes on very dimly. However, I don't know how else to wire it so that it works.

\$\endgroup\$
9
  • \$\begingroup\$ You don’t want to put 5V into a gpio! 3.3V only. Feed your circuit with 3.3V. Add a 10k resistor from gpio to 0V \$\endgroup\$
    – Kartman
    Dec 7, 2021 at 6:17
  • \$\begingroup\$ @Kartman It's unlikely that the output will be more than about 3.5 V to a very weak 4.0 V (given who knows what at the antenna), even with 5 V at the collectors. Clamped I/O protection diode currents will be quite low and probably safe against latch-up. That said, it's always better to just design it right in the first place. Agreed. But this isn't a great design to begin with. I'd go with a JFET input pre-amp stage. \$\endgroup\$
    – jonk
    Dec 7, 2021 at 7:18
  • \$\begingroup\$ Have you tried it with the LED still in place while connected to the GPIO? \$\endgroup\$
    – HandyHowie
    Dec 7, 2021 at 7:34
  • \$\begingroup\$ I would think that the gpio alone would behave similarly to the darlington darlington configuration. You’d want some ESD protection though. \$\endgroup\$
    – Kartman
    Dec 7, 2021 at 12:55
  • \$\begingroup\$ Yea the voltage at the output of the circuit reads about 2 volts, I'm almost wondering if its not enough for the pin to read. \$\endgroup\$
    – Dyverge
    Dec 7, 2021 at 15:54

1 Answer 1

1
\$\begingroup\$

First of all the Pi only tolerates 3.3V, 5V is too much for it's input. You could clamp it with a zener, for example. Also what you are seeing is probably not a continuous signal but some impulsive one (at 100-120Hz line frequency maybe) so depending on when you sample it you have inconsistent readings.

As other commented it could also be that the signal is not quite of the level required for the GPIO to work reliably. A standard LVCMOS for example (not 100% sure if these are the level employed in the Rasp) should be below about 900mV to be read as zero and more than 2.3V to be read ad one. In between it's not really defined, it depends on many factors.

In general it's not a good idea to feed an analog signal to a digital port, unless it has a Schmitt trigger input buffer.

I'd suggest to clean your signal with a comparator and maybe some filter/monostable to make it more amenable to processing. Also that 3 BTJ gain chain is really ugly (sadly is quite popular on the internet), there are better way to make non-contact voltage detectors

\$\endgroup\$
2
  • \$\begingroup\$ Don't know how I clicked on -1, sorry! Will remove it if you edit it, it's locked now. \$\endgroup\$
    – awjlogan
    Dec 7, 2021 at 10:06
  • 1
    \$\begingroup\$ @awjlogan I sympathize, and will +1 in your honor. My fat fingers have gotten me into worse trouble. \$\endgroup\$ Dec 16, 2021 at 11:46

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.