Noise on ESP8266 ADC when using regulator - Page 1
Forum section: electronics / beginners

author: synoptica
author_rank: Contributor
timestamp: November 07, 2018, 02:19:16 am
content: 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.htmADC 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/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 anythingI 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!

author: Mr.B
author_rank: Unknown
timestamp: November 07, 2018, 02:43:23 am
content: QuoteYes, a picture is worth a thousand words round here...We will be able to assist more if you can show us your circuit.

author: synoptica
author_rank: Contributor
timestamp: November 07, 2018, 08:31:59 am
content: Yeah, that's fair. Here's the schematic: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!

author: mvs
author_rank: Frequent Contributor
timestamp: November 07, 2018, 05:28:03 pm
content: Perhaps ESP12E gets parasitic power over GPIO. Check its supply rail voltage with DMM.

author: Photon939
author_rank: Regular Contributor
timestamp: November 07, 2018, 05:41:56 pm
content: 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.

author: brybot
author_rank: Contributor
timestamp: November 07, 2018, 06:48:00 pm
content: 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.pdfDo 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.

author: synoptica
author_rank: Contributor
timestamp: November 08, 2018, 01:39:04 am
content: Quote from: Photon939 on November 07, 2018, 05:41:56 pmSorry - 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.Quote from: mvs on November 07, 2018, 05:28:03 pmYou 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!Quote from: brybot on November 07, 2018, 06:48:00 pmI'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.

author: LukeW
author_rank: Frequent Contributor
timestamp: November 08, 2018, 08:54:27 am
content: 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.

author: iMo
author_rank: Super Contributor
timestamp: November 08, 2018, 09:28:36 am
content: QuoteIt could be it comes from ground leads voltage drop. Try to wire the ESP12 GND to R2_GND with short wire.

author: synoptica
author_rank: Contributor
timestamp: November 12, 2018, 08:21:00 am
content: 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 fromthe 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?Quote from: LukeW on November 08, 2018, 08:54:27 amYeah, 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:Quote from: imo on November 08, 2018, 09:28:36 amThis 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!

author: kjw
author_rank: Newbie
timestamp: July 10, 2023, 10:19:08 am
content: 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. Thedatasheetstates 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.