Tags:
tag this topic
create new tag
view all tags
---+ Analogue Signals Up to now, we only treated digital signals in output mode (LED) and in input mode (pushbutton). Sensors often produce analogue signal levels, however. A thermistor, for example, returns a voltage level which corresponds to the temperature. How can we treat signals like these? Our slider potentiometer produces a similar signal level, and we will connect it to an <b>A</b>nalogue to <b>D</b>igital <b>C</b>onverter (ADC). The ESP32 chip already supplies a 12 bit ADC. With 12 bits 4096 different numbers can be represented, and we therefore get a resolution of our measurement of 1/4096 which corresponds to ~0.025 % <img alt="slider.png" height="384" src="%ATTACHURL%/slider.png" title="slider.png" width="467" /> The potentiometer has 3 pins: OTA (or OTB), VCC, GND which must be connected to the triple base as follows: #PotConnection | *Potentiometer* | *Triple Base* | | OTA | A0 (ADC) GPIO 36 | | VCC | 3V3 | | GND | GND | Use the male/female Dupont wires to make the connections. <img alt="slider_conn.png" height="206" src="%ATTACHURL%/slider_conn.png" title="slider_conn.png" width="470" /> You find a description of the !MicroPython driver in the [[https://docs.micropython.org/en/latest/esp32/quickref.html#adc-analog-to-digital-conversion][doc]] again. The ADC works for a range of 0..1V only while the potentiometer produces signal levels of 0..3.3V. A signal attenuator allows adapting the ranges. It must be set to ADC.ATTN_11DB for our 0..3.3V slider. <verbatim>from machine import ADC,Pin from time import sleep_ms slider = ADC(Pin(36, atten=ADC.ATTN_11DB) # use the ADC on GPIO 36 and set the attenuator to 11 dB while True: print("Raw 12 bit value from slider: ",slider.read()) sleep_ms(100)</verbatim> The only hardware still missing is the [[rgb LED chain]] -- %USERSIG{UliRaich - 2022-10-16}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
slider.png
r3
r2
r1
manage
152.9 K
2022-10-24 - 10:58
UliRaich
png
slider_conn.png
r1
manage
77.7 K
2022-10-24 - 10:59
UliRaich
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r3 - 2022-10-24
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
AFNOG Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback