---+ Solutions to exercise 9: ADC and DAC ---++ Exercise 1: As you can see on the photo, the joystick has 5 pins: | *Pin on Joystick* | *Pin on ESP32* | | GND | GND | | 5V | 3.3V | | URx | GPIO 34 | | URy | GPIO 33 | | SW | Switch, can be connected to any GPIO<br />not used for the eercise | GPIO 33 and 34 are located on the second row of the WROVER CPU card and not connected to the !WeMos bus. <img alt="joystick.png" src="%ATTACHURL%/joystick.png" title="joystick.png" /> Creating an instance from the ADC class in the machine module is simple as is reading from it. See http://docs.micropython.org/en/latest/esp32/quickref.html ---++ Exercise 2: Connect the ESP32 DAC output to the input of the ADC (DAC: GPIO 26, ADC: GPIO 36). Ramp the DAC data, starting from 0 to its max value: 255 in steps of one. Wait for 50ms to be sure the DAC output has settled. Then read the ADC and write the result to a file in ascii format. You can use gnuplot to easily visualize the results. ---++ Exercise 3: For once the driver of the ads1115 ADC is not already included in the !MicroPython binary. Before using it, it must be uploaded to the ESP32 flash: <verbatim>ampy mkdir /lib ampy put ads1x15 /lib/ads1x15</verbatim> The first command is only needed if /lib does not exist already on the ESP32. Now we can <verbatim>from ad1x15 import ADS1115</verbatim> and use it. The program is essentially the same as the one in exercise 2. ---++ Exercise 4: Explained on the TWiki page [[ADC and DAC]] ---++ Exercise 5: For the exercises an oscilloscope is needed.We have a very cheap Hantek USB oscilloscope in our lab equipment. Connect one of the probes to the output of the DAC ( GPIO 26) and observe the result of your programs on the scope display. [[ADC and DAC]] has screen dumps of what you are expected to see. -- %USERSIG{UliRaich - 2021-02-06}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
joystick.png
r1
manage
152.2 K
2021-02-06 - 10:50
UliRaich
This topic: IoT_Course_English
>
WebHome
>
Solutions
>
SolutionsToADCAndDAC
Topic revision: r1 - 2021-02-06 - UliRaich
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