how to read module 3v3 on ESP32

If doesn't fit into any other category ....
Post Reply
Zim
Posts: 289
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 265 times
Been thanked: 129 times

how to read module 3v3 on ESP32

Post by Zim »

ESP32
If I put a jumper from 3v3 to "pin 33" and run the code, shouldn't I get 4095? I get 0. :oops:

VLT = ADC(33)
wlog VLT ' gives me 0

Am I missing something?

Thanks
Zim
User avatar
PeterN
Posts: 392
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 184 times
Been thanked: 220 times
Contact:

Re: how to read module 3v3 on ESP32

Post by PeterN »

Hi Zim

I would expect that too ... and it did work for me at gpio33 within my levitation project - but with lower input voltage at around 1.7V. [Local Link Removed for Guests]

There seems to be a general need and ability to attenuate the input: https://docs.espressif.com/projects/esp ... s/adc.html
But that attenuation is set to the maximum in Annex32 as far as I see.
So a voltage above 2.45V should return 4095
Jan Volk
Posts: 89
Joined: Wed Mar 03, 2021 1:35 pm
Been thanked: 27 times

Re: how to read module 3v3 on ESP32

Post by Jan Volk »

Zim,

I did the same and it works for me.

wlog ADC(33) ' Read voltage from pin33
VLT = ADC(33)
wlog VLT ' gives me 0

wlog: 4095
4095

LOLIN D32 PRO ESP32 WROVER
Annex32 CAN 1.49.2

Jan
bugs
Posts: 143
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 47 times
Been thanked: 51 times

Re: how to read module 3v3 on ESP32

Post by bugs »

Likewise...
Image
You do not have the required permissions to view the files attached to this post.
Jan Volk
Posts: 89
Joined: Wed Mar 03, 2021 1:35 pm
Been thanked: 27 times

Re: how to read module 3v3 on ESP32

Post by Jan Volk »

Zim,

With a potentiometer at 3.1 V -> 4088

Jan
Zim
Posts: 289
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 265 times
Been thanked: 129 times

Re: how to read module 3v3 on ESP32

Post by Zim »

Hi Gentlemen;
Found the issue. The ESP32 s2 mini has a different pin layout than conventional ESP32. Its also 13bit sar on the ADC's.
3.3v gives me 8191.
Thanks for all of your replies

Zim
https://www.espressif.com/sites/default ... eet_en.pdf

Attn: Electroguard. I know you got some of these too!
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: how to read module 3v3 on ESP32

Post by Electroguard »

Hi Zim, I dealt with the confusion of different device pinouts a while ago by creating a 'standard pin assignment block' for my scripts, and creating an S2 pinout chart to show what S2 pins correspond to the ESP8266 data pins (see below).
By using the Wemos D1 Mini D0 to D7 pin convention, it is possible to assign the relevant D? pins for any devices, thereby allowing the same script to be used with different devices simply by changing the esp$="device_type" variable for something relevant for the device.
The snippet below comes from an early development stage of a script I was developing for a colour-changing mood light that doubles as a battery-backed-up emergency light with audible alert in event of a power fail. I was only interested in the S2 device I was using at that time, so the pin assignments of the other devices were included for future use and are probably incorrect, and just included to illustrate the idea.

esp$="s2"
select case esp$
case "12E": D0=16:D1=5:D2=4:D3=0:D4=2:D5=14:D6=12:D7=13:D8=15 ' ledpin=15:ledoff=0: relaypin=2:relayoff=0: buzzerpin=35: neopin=33:
case "s2" : D0=5:D1=35:D2=33:D3=18:D4=16:D5=7:D6=9:D7=11:D8=12:A0=35: ledpin=15:ledoff=0: relaypin=2:relayoff=0: buzzerpin=35: neopin=D4:
case "w32": D0=5:D1=35:D2=33:D3=18:D4=16:D5=7:D6=9:D7=11:D8=12:A0=3: ledpin=2:ledoff=0: relaypin=2:relayoff=0: buzzerpin=35: neopin=33
case "t32": D0=5:D1=35:D2=33:D3=18:D4=16:D5=7:D6=9:D7=11:D8=12:A0=3: ledpin=22:ledoff=0: relaypin=2:relayoff=0: buzzerpin=35: neopin=D4
case "t16": D0=5:D1=35:D2=33:D3=18:D4=16:D5=7:D6=9:D7=11:D8=12:A0=3: ledpin=22:ledoff=0: relaypin=2:relayoff=0: buzzerpin=35: neopin=D4
end select
pin.mode ledpin,output:ledoff=0:pin(ledpin)=ledoff: ledflash=1
pin.mode relaypin,output:relayoff=0:pin(relaypin)=relayoff
pin.mode buzzerpin, output:pin(buzzerpin)=1



The diagram should be fairly self-explanatory...
S2c.jpg
You do not have the required permissions to view the files attached to this post.
Post Reply