1
\$\begingroup\$

I am using a MonkMakes board to measure the wetness of some soil in a pot. This board measures the capacitance of the soil, converts this into a wetness percentage, and sends this value to the Raspberry Pi Pico W board over a UART. Everything is powered by the regulator on the Pico. Please see figure below.

When this setup is powered by battery it works fine, but when powered by a USB phone charger plugged into the mains supply (I tried two)the wetness percentage fluctuates wildly. I’ll elide the frustrating debugging process but the result is that it works fine when powered by USB if the oscilloscope is connected, specifically when the oscilloscope ground is connected to the measurement board (connecting points 1 and 2 on the block diagram). This is a mains powered oscilloscope so I assume the scope ground is connected to earth.

This makes me suspect some sort of grounding issue but what is the solution? The USB phone chargers I have tried all have no earth pin so there is no readily available earth connection. Adding a separate mains plug just to earth the board would be very clumsy.

Is there some modification that I can make to resolve the problem?

Update: I tried connecting ground of the sensor board to the soil, in the hope of serving as a ground connection. It made the situation worse, with the wetness now measuring 100%.

block diagram of system

\$\endgroup\$
4
  • \$\begingroup\$ Is the usb connection to a laptop or desktop computer? If it’s a laptop have you tried with the laptop running on battery vs it’s adapter? \$\endgroup\$
    – Bryan
    Mar 26, 2023 at 2:10
  • \$\begingroup\$ The USB connection is to a phone charger, which is how I plan to run this in the long term (I'll update the question to clarify). I tried a laptop, and it worked fine on battery power, and also worked fine when plugged in. The laptop power supply was earthed, so I think it likely that it is also earthing the Pico. \$\endgroup\$ Mar 26, 2023 at 14:53
  • 2
    \$\begingroup\$ Best guess: Y-capacitor leakage. Please draw a schematic or block diagram of how you connected everything. \$\endgroup\$
    – winny
    Mar 26, 2023 at 15:02
  • \$\begingroup\$ @winny I've added a block diagram. Does this give you the information you are looking for? \$\endgroup\$ Mar 26, 2023 at 15:41

1 Answer 1

3
\$\begingroup\$

The block diagram you have given does not tell you the whole truth when it comes to earth. Due to EMI from switch-mode power supplies, and in your case, double isolated ones without earth, a "fake earth" is often formed using Y-capacitor and/or a small Y-capacitor is placed across the transformer to short out high frequency noise. They have tremendous positive effect on EMI but the drawback is earth leakage current both felt physically and as in your case, affects measurements. The legal maximum level is 250 uA for double-insulated devices (Class II) and 750 uA for grounded (Class I).

Here is a simplified schematic of how a Class II SMPS may look internally. Assuming flyback, CY3 from primary plus to secondary minus is normally first order of business and a divider formed by CY1 and CY2 second. Pretty much whatever fixed the EMI to be within limits without going above 250 uA leakage for the designer. It does not matter much which in your case, you end up with 50/60 Hz leakage current anyway.

schematic

simulate this circuit – Schematic created using CircuitLab

If you look at the schematic, one would wish that secondary GND is connected to primary PE since your measurement is referenced to earth and ideally PE=Earth. What you actually have is semi-floating secondary with 50/60 Hz ripple voltage. If you measure with high impedance, that limited leakage current will translate to rather high voltage. If your impedance to ground is low, then low voltage. Test with your multimeter.

There are several things you can do, either ground your secondary side to PE, find a 5 V SMPS with very low leakage (medical SMPSes have much lower legal limit for leakage current), any 50/60 Hz transformer based power supply is very unlikely to have Y-capacitors in the first place.

You could end up in a situation where your local mains situation have some 50/60 Hz voltage with respect to earth anyway and all your efforts will only attenuate it but never remove it. If you are within limits for your capacitive meter but have AC superimposed, you can run a digital or analog filter to average it out.

\$\endgroup\$
6
  • \$\begingroup\$ Thanks, that's very helpful. Is there anything that could be done just on the PicoW/MonkMakes board? Connecting to PE would need an additional mains socket, and I don't think I have a suitable alternative 5V power supply. Even the ones with a metal earth pin I tried don't connect earth to the shield. Some minor notes on the diagram. The power from the Pico W to MonkMakes board is 3.3V not 5V since the Pico has its own regulator. Also the soil is in a plastic pot so might not be earthed. I don't know if those make any significant difference. \$\endgroup\$ Mar 27, 2023 at 13:24
  • \$\begingroup\$ @StevenMurdoch The 5->3.3 V was simplified away since it does not matter for the leakage current. It's common mode anyway. Depends. Does the superimposed AC bottom out your range as is? If not, you can average it away. \$\endgroup\$
    – winny
    Mar 27, 2023 at 14:50
  • \$\begingroup\$ I don't control the firmware on the sensor board, so averaging out the noise doesn't seem feasible. It looks like medical-rated power supplies are easily available, so might be my next thing to try. For some reason finding USB power supplies that earth the shield pin seem to be hard to find. Perhaps it is not a feature most people care about. \$\endgroup\$ Mar 29, 2023 at 14:22
  • \$\begingroup\$ Correct. It’s a bane for these types of sensors though. \$\endgroup\$
    – winny
    Mar 29, 2023 at 14:38
  • \$\begingroup\$ Regarding firmware, don’t you have an MCU upstream of it? \$\endgroup\$
    – winny
    Mar 29, 2023 at 15:08

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.