Editing Tutorial Analog IN
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 14: | Line 14: | ||
* [[ESP32 Web Kit]] with integrated OLED Display from Heltec | * [[ESP32 Web Kit]] with integrated OLED Display from Heltec | ||
* [[ESP8266 ESP-12F]] NodeMCU Module from AZDelivery | * [[ESP8266 ESP-12F]] NodeMCU Module from AZDelivery | ||
+ | |||
=== Sensors (and physical controllers) === | === Sensors (and physical controllers) === | ||
Line 22: | Line 23: | ||
= Instructional Videos = | = Instructional Videos = | ||
The videos are a first test... the ones marked with ** will be replaced over the next months with new versions. | The videos are a first test... the ones marked with ** will be replaced over the next months with new versions. | ||
− | |||
− | |||
− | |||
Line 30: | Line 28: | ||
In this video on youtube (46:23) we show how to connect to read in an analog value with MicroPython. We also show how a sensor that is based on a changing resistance can be connected using a voltage divider: https://youtu.be/gjj5KyK2qGI | In this video on youtube (46:23) we show how to connect to read in an analog value with MicroPython. We also show how a sensor that is based on a changing resistance can be connected using a voltage divider: https://youtu.be/gjj5KyK2qGI | ||
− | <youtube>gjj5KyK2qGI</youtube> | + | <youtube>gjj5KyK2qGI </youtube> |
− | |||
− | |||
− | |||
− | |||
= Schematics and Code Example = | = Schematics and Code Example = | ||
== Schematics for connecting to ESP32 == | == Schematics for connecting to ESP32 == | ||
− | |||
− | |||
This should divide the voltage by half as both resistors are the same - you should read a value of about 2000 (assuming 12Bit resolution with a range of 0-4096) | This should divide the voltage by half as both resistors are the same - you should read a value of about 2000 (assuming 12Bit resolution with a range of 0-4096) | ||
Line 54: | Line 46: | ||
[[File:Rldr.JPG|300px]] | [[File:Rldr.JPG|300px]] | ||
− | == Code Example | + | == Code Example == |
This makes Pin 34 an analog input and set it to 12 bit. It reads the analog value every second and print it to the console- | This makes Pin 34 an analog input and set it to 12 bit. It reads the analog value every second and print it to the console- | ||
Line 64: | Line 56: | ||
analogPin = ADC(Pin(34)) | analogPin = ADC(Pin(34)) | ||
analogPin.atten(ADC.ATTN_11DB) | analogPin.atten(ADC.ATTN_11DB) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
while True: | while True: |