3.3 V range on the A0 analog input of Wemos D1 mini

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
Roberthh
Posts: 2586
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

3.3 V range on the A0 analog input of Wemos D1 mini

Post by Roberthh » Sun Nov 13, 2016 10:40 am

The A0 input of the Wemos D1 mini is connected to the ADC input of the ESP-12 through a 3.2/1 voltage divider, consisting of a 220k and 100k resistor. I verified that by checking my two devices I have on hand. That results in an analog voltage range of about 3.3V at input A0, at an impedance of roughly 300k, assuming that the input impedance of the ESP module is high (>> 1MOhm).
Whether this is good or bad, depends on your application. I did not see this on the huzzah feather, and the schematics of Node-MCU do not show that either.

User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by kfricke » Sun Nov 13, 2016 10:52 am

The ADC input range is 0.1.0 Volt. Was your post just a statement for the presence on the Wemos, or did i miss the question?

User avatar
Roberthh
Posts: 2586
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by Roberthh » Sun Nov 13, 2016 11:20 am

Yes, Sir, because there were discussions around that aspect in other posts, and Paul suggested to post this.
And, as said, it's related to Wemos D1 mini only!

User avatar
ernitron
Posts: 84
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by ernitron » Sun Nov 13, 2016 3:35 pm

Thank you Robert, very interesting.
I don't know if I may use your thread to post some more information about WeMos D1 mini and pose some questions. If not I can change topic and move to a more specific one.

I measured the PIN Voltages just after a POWER UP and I found some interesting results. I measured with no software installed i.e. after a flash erase and after a fresh installation of 1.8.6 of micropython. I couldn't find these information in the electric schema or in other forums but it wasn't a big deal to test myself. These are the measured voltages (with respect to GND on WeMos):

Code: Select all

Erased     | With 1.8.6
Tx = 3.14  | same
Rx = 3.14  | same
D1 = 0.00  | same
D2 = 0.01  | same
D3 = 0.45  | 3.12
D4 = 3.14  | same
G  = 0.00  | same
5V = 4.40  | same
===== Other Side ===
Rst= 3.13  | same
A0 = 0.00  | same
D0 = 3.15  | same
D5 = 3.15  | same
D6 = 3.15  | same
D7 = 3.15  | same
D8 = 3.15  | same
3V3= 3.15  | same
Now, some curious guy like (@kfricke) could ask the purpose of it and where is the question ;)

Actually one of my problem is finding the optimal connection of various "peripherals" to the WeMos, like the Dallas temperature sensor DS18x20 or a Relay Switch or a PIR sensor and even a Piezo Buzzer that works with 3 - 24V. My schema is actually the following:

Code: Select all

# Standard Setup For WeMos Circuits // Breadboard
Temperature Sensor on D3 (which is GPIO0) // It is pull-up
Relay Sensor       on D8 (which is GPIO15) // Starts LOW
PIR Sensor         on D2 (which is GPIO4) //
PiezoBuzzer        on D1 (which is GPIO5)
The problem arise because just after a power-on I don't want that the Relay or the Piezo buzzer receives any voltage and current (otherwise they change state) just as if they were unpowered. Imagine your IoT electric switch (with WeMos) when powered-up will turn the light on before the software put it low or a the IoT temperature sensor will start with a small beep from the buzzer. Absolutely unacceptable, right?

The basic question is why almost all Dx PIN start with some voltage instead of zero.
I can explain the:
D3 - GPIO0 -> 10k pull up resistor -> 3V3
D4 - GPIO2 -> 10k pull up resistor -> 3V3
D8 - GPIO15 -> 10k pull down resistor -> GND

But the others? Are they pull up via sw? Cannot they start low?

It comes out that I can use only the D1 and maybe D2 or D3 for relay or piezo and I cannot use anything else when it comes to control output that needs to start with zero voltage. (Why D2 has this small voltage instead of zero???)

What do you think?

PS: During testing I broke one of my beloved WeMos with a short, so be careful ;)

PPS: sorry, few editing during submission.

User avatar
Roberthh
Posts: 2586
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Start-up port levels of Wemos D1 mini

Post by Roberthh » Sun Nov 13, 2016 4:25 pm

Hello @ernitron. I do not know whether this is the right post to discuss your question, but let's go on.
I repeated your measurement with one of my devices here. You did your test with the typical high impedance volt meter, which explains why you see tome low voltages on D1 and D2. These are just inputs with are not pulled up or down.
Since I noticed small variations of the readings between the high level ports, I repeated the test with a load resistor of 10k. With that, it turned out, that D5 and D6 seem to be initialized as inputs with internal pull-up of about 40k. With a 10k load, the voltage reading was about 0.7 V. So these should not drive a Piezo, until the port is switch to output. But beware, that each GPIO must not drive more than 12 mA. Using a load resistor of 3.3k will result in a current of 1 mA, and a voltage of 0,27V at start-up. If that's the only load, you may even chose a lower value.
But that is not 'clean'.
The better choice for possibly low impedance loads like a relay or piezo is to use a driver (unless the drivers are already included). Then you can invert the polarity of the signal by using inverters and can deal happily with high levels at boot.

User avatar
ernitron
Posts: 84
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by ernitron » Sun Nov 13, 2016 5:31 pm

Robert thank you very much (also to host me in your thread but maybe I can move the whole thing if it gets too fat here ;)

However I am a bit puzzled. I use a piezo buzzer (this one from https://wholesaler.alibaba.com/product- ... 83581.html I use exactly the SFM-27-W) As you can see it has max 12ma so it should not harm the device, I guess.
Besides, I use D1 (GPIO5) which is IO and works just fine. It is the ONLY IO I can use as all the others before initialized OUT and put low, have voltage and make a buzz. Try to believe ;)

I added also 4.7KOhm resistor and the result with D5 and D6 is a buzz at startup. Low but is there and I cannot stand it :D

User avatar
deshipu
Posts: 1385
Joined: Thu May 28, 2015 5:54 pm

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by deshipu » Sun Nov 13, 2016 6:03 pm

Most of the pins, (except for, gpio0, gpio1, gpio2, gpio3 and gpio15) will start in INPUT mode, that is, high-impedance mode that makes almost no current flow, and therefore should not trigger any devices. The reason your voltmeter is still showing some current on them is that it has very high impedance itself, and is very sensitive even to low currents.

Now, you have already discovered the pull-up and pull-down resistors on the gpio0, gpio2 and gpio15 -- they are there on most development boards to make sure the esp8266 module boots into the correct boot mode (it depends on the voltages found on those pins at boot). You may also find that the case is a little bit more complex with gpio0, because it is often connected with a small circuit, connected to the USB port, which switches it for flashing.

Finally, the gpio1, gpio2 and gpio3 are used for UART at boot -- so they will either get pulled up, or will change state quite fast (which your voltmeter will average and show as some lower voltage). There is nothing you can do about it, short of adding some circuits to cut off the pins during boot, and only connect them to your devices after the board has booted and your program is running.

Of course, when you are using a bare module, you have more control about where you put resistors and what you pull up or down -- but you still have to somehow make sure that your module boots into the right mode.

User avatar
Roberthh
Posts: 2586
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by Roberthh » Mon Nov 14, 2016 8:52 am

Hello @ernitron
I added also 4.7KOhm resistor and the result with D5 and D6 is a buzz at startup.
Did you put the 4.7k Resistor in series or parallel to the piezo? You should put it parallel, to reduce the inital voltage at the output to about 0.4V. And obviously you should then configure that port to output & low. But still it's better to use a driver, transistor or open collector gate.

User avatar
ernitron
Posts: 84
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: 3.3 V range on the A0 analog input of Wemos D1 mini

Post by ernitron » Mon Nov 14, 2016 3:17 pm

Roberthh wrote:Hello @ernitron
I added also 4.7KOhm resistor and the result with D5 and D6 is a buzz at startup.
Did you put the 4.7k Resistor in series or parallel to the piezo? You should put it parallel, to reduce the inital voltage at the output to about 0.4V. And obviously you should then configure that port to output & low. But still it's better to use a driver, transistor or open collector gate.
In parallel! Yes! It's right... You were right!! Solved, no more buzz! Thanks!!!
(what a poor engineer I am ;)

Post Reply