EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: synoptica on November 07, 2018, 02:19:16 am
-
Hi all,
A bit of a strange issue (which is probably very simple) on an ESP8266 project I'm working on. The MCU is used to remotely trigger a handful of relays (with low-level trigger circuits) which control devices that run on a separate voltage source between 12-18V. Relay modules are these: https://www.aliexpress.com/item/Free-Shipping-1PCS-5V-low-level-trigger-One-1-Channel-Relay-Module-interface-Board-Shield-For/32480128984.htm (https://www.aliexpress.com/item/Free-Shipping-1PCS-5V-low-level-trigger-One-1-Channel-Relay-Module-interface-Board-Shield-For/32480128984.htm)
ADC is used to monitor this separate voltage source. I'm just using a voltage divider to drop the voltage down to sub-1V so the ADC can read it. Everything shares a common ground.
I built the circuit, powered it from USB, ADC readings are all close enough to accurate for what I require. However, I need a way to power the relays from the separate voltage source, so I've tried both an AMS1117 3.3V regulator and one of these: https://goughlui.com/2018/07/04/tested-mini-360-mp2307-based-3a-buck-converter-module/ (https://goughlui.com/2018/07/04/tested-mini-360-mp2307-based-3a-buck-converter-module/)
As soon as either of these devices are used, my ADC readings become inaccurate to the point of no longer being useful. Readings displayed as expected on a multimeter.
I understand that a dirty reference voltage will cause issues when taking ADC readings, but the input to the ESP8266 is still coming from USB; the issue occurs as soon as the regulator is connected to the external voltage source (which as mentioned shares a common ground with the ESP8266) that is being also being measured by the ADC through a voltage divider.
I've tried to use a couple of decoupling caps (from memory, I tried a 100uF electrolytic and a 1uF monolythic) without success. Sadly, I don't own a scope to test anything :(
I don't think I can really solve the issue until I better understand it though; so I'm hoping someone here might be able to help me out!
Hopefully I've explained it clearly but if not I can probably throw together a schematic to help!
Thanks in advance!
-
...I can probably throw together a schematic to help...
Yes, a picture is worth a thousand words round here...
We will be able to assist more if you can show us your circuit.
-
Yeah, that's fair. Here's the schematic:
(https://i.imgur.com/OMBUVDy.png)
The AMS1117 is a pre-made board so has supporting components (not necessarily perfect reference design though). As mentioned I've also used a buck converter detailed above in the same configuration.
I've tried a combination of 100nF and 100uF decoupling caps in various places without success.
I'm about to try one of the breadboard-mount 1117 boards to see if there's any different result. Will report back!
-
Perhaps ESP12E gets parasitic power over GPIO. Check its supply rail voltage with DMM.
-
Your ADC input voltage divider is only reducing the input voltage by 1/2, wouldn't you be exceeding the ADC maximum input with VCC above 6.6v? The excess voltage will flow into the ESP VCC via the ESD protection diodes on the ADC pin.
-
Do you have a bypass cap on the output of your voltage regulator? The datasheet suggests 22uF for stability.
http://www.advanced-monolithic.com/pdf/ds1117.pdf (http://www.advanced-monolithic.com/pdf/ds1117.pdf)
Do you have bypass caps near the ESP? How are you getting your 3.3V from USB serial? Is it a stable voltage rail? Any ripple on the ESP VCC will affect your ADC readings.
Aside from the USB line, do you have any other power sources plugged into a wall? Maybe you're getting a ground loop when you connect everything up. I see that you've got 18650 batteries, so perhaps that's not an issue.
What values are you using in your voltage divider? As already mentioned, what you show in your schematic won't work, but I'm assuming you were just illustrating a concept rather than going for accuracy.
-
Your ADC input voltage divider is only reducing the input voltage by 1/2, wouldn't you be exceeding the ADC maximum input with VCC above 6.6v? The excess voltage will flow into the ESP VCC via the ESD protection diodes on the ADC pin.
Sorry - forgot to include the values for the resistors. I think I used a 20k and 360k - they definitely drop the voltage into the correct range though.
Perhaps ESP12E gets parasitic power over GPIO. Check its supply rail voltage with DMM.
You might be onto something here. I tested the input rail last night and it was raising by 0.2V when the relays were on; I've since changed the input setup and seem to have gotten it a bit more stable. I'll do some more experimentation tonight!
Do you have a bypass cap on the output of your voltage regulator? The datasheet suggests 22uF for stability.
http://www.advanced-monolithic.com/pdf/ds1117.pdf (http://www.advanced-monolithic.com/pdf/ds1117.pdf)
Do you have bypass caps near the ESP? How are you getting your 3.3V from USB serial? Is it a stable voltage rail? Any ripple on the ESP VCC will affect your ADC readings.
Aside from the USB line, do you have any other power sources plugged into a wall? Maybe you're getting a ground loop when you connect everything up. I see that you've got 18650 batteries, so perhaps that's not an issue.
What values are you using in your voltage divider? As already mentioned, what you show in your schematic won't work, but I'm assuming you were just illustrating a concept rather than going for accuracy.
I'm not sure on the values - but I think they're not 22uF (it's a pre-made board.) I actually have a bunch of 22uF SMD caps that are much bigger than what's on the board.
I suspected a ground loop - but being a relative noob I'd need to do some more research into what they are and how they occur and can be countered. The idea is that all devices will be powered from the same source, but I'll likely tap into the battery input in the middle to feed ~8.4V to the regulator just to ease the load on it a bit.
Values I think are 20k and 360k.
-
I don't think the ESP8266 internal ADC ever promised to be very good quality.
If you need it to be good, use an external chip with separate, isolated clean power supplies, separate analog reference and decoupling etc - then go into the ESP8266 over SPI or I2C.
-
I tested the input rail last night and it was raising by 0.2V when the relays were on;
It could be it comes from ground leads voltage drop. Try to wire the ESP12 GND to R2_GND with short wire.
-
A bit of an update...
I got rid of all the crap spread across breadboards and soldered everything onto a bit of perfboard, including a 5V and 3.3V AMS1117 regulator (same pre-built boards as before.)
This got rid of my unstable reference voltage, and also stablised the output voltage from the voltage divider, and readings on my meter stay stable, but the ADC reading is still dropping when the relays are powered on!
I've now narrowed this down to a single source. The only time the ADC stays stable is when powered from the 5V output of my USB TTL board.
It gets stranger though - if I power it from any other 5V source - my benchtop PSU, a couple of 18650s, or even from the 5V line of the very same USB port the USB TTL connects to, the ADC becomes unstable.
Does anyone know what magical things are happening on this 5V line, and why is the input to the relays is even affecting my ADC readings so drastically?
I don't think the ESP8266 internal ADC ever promised to be very good quality.
If you need it to be good, use an external chip with separate, isolated clean power supplies, separate analog reference and decoupling etc - then go into the ESP8266 over SPI or I2C.
Yeah, I figured as much, but this isn't just 'not good', it's unusable! An approximation here is close enough for my use case, which is just battery monitoring.
Scrub all of that... prize goes to LukeW:
I tested the input rail last night and it was raising by 0.2V when the relays were on;
It could be it comes from ground leads voltage drop. Try to wire the ESP12 GND to R2_GND with short wire.
This got me thinking - the only difference I could imagine is was that the earth of that source was a lot closer to the ESP than any of the others. Added another earth off the ESP and boom!
Thanks mate. Can't believe I missed a dodgy earth!
-
Unrelated to the noise issue, I see you have an AMS1117 and your diagram shows upper voltage of 17V due to the use of 4 lithium ion batteries. The datasheet (http://www.advanced-monolithic.com/pdf/ds1117.pdf) states an absolute maximum input voltage of 15V so unless there's some other stuff on the board it sounds like you are/were exceeding the limits at least for the first part of battery discharge?
I had one of the cheap motherboard power supplies based on the AMS1117 turn into a "passthru device" when I used an (old) transformer-based unregulated power supply because it exceeded the voltage.