|
|
| (106 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| === Micropython Kurs 2023 - Teil 2=== | | === Micropython Kurs 2023 - Teil 2=== |
| Hier werden wir den Umgang mit der Microcontroller spezifischen Hardware lernen. | | Hier werden wir den Umgang mit der Microcontroller spezifischen Hardware lernen. |
|
| |
|
| |
| ==== 1. Abend====
| |
| 14.11.2023
| |
| <br> | | <br> |
| ===== Vorstellung des Experimentierboards=====
| | Hier ein paar Dateien die für den Kurs benötigt werden: [[media:d4MPK2.zip|MPK2023_2_Dateien]] |
| <br> | | <br> |
| ===== Erster Hardware Kontakt=====
| | * Das ZIP-File kann von dieser Seite heruntergeladen werden.<br> |
| [[18. Lektion: Pin's]]<br>
| | * Anschließend auf dem Rechner entpacken und <br> |
| [[19. Lektion: Neopixel]]<br>
| | * dann den Inhalt mit Thonny auf den Pico kopieren.<br> |
| * Problem Stromversorgung!
| | * Fertig. |
| ** https://www.exp-tech.de/zubehoer/neopixel/leds/5902/adafruit-neopixel-diffused-5mm-through-hole-led-5-pack?c=1215
| |
| ** https://www.exp-tech.de/zubehoer/neopixel/leds/5310/breadboard-friendly-rgb-smart-neopixel-pack-of-4?c=1215
| |
| ** https://www.berrybase.de/adressierbare-ws2812-rgb-led-pth-5mm-diffus-5er-pack?c=2428
| |
| ** https://www.berrybase.de/adressierbare-ws2812-rgb-led-pth-5mm-klar-5er-pack?c=2428
| |
| ** https://www.berrybase.de/neopixel-breakout-board-mit-1-ws2812-5050-rgb-led?c=2447
| |
| ** https://www.berrybase.de/neopixel-rgbw-mini-button-pcb-10er-pack?c=2447
| |
| [[20. Lektion: Onewire]]<br>
| |
| [[21. Lektion: UART]]<br>
| |
| [[22. Lektion: SPI]]<br>
| |
| [[23. Lektion: I2C]]<br>
| |
| * TCA9548a
| |
| ** https://github.com/mcauser/microphyton-tca9548a
| |
| [[24. Lektion: ADC]]<br>
| |
| ** ADC des Raspberry Pi Pico | |
| ** ADC des ESP32
| |
| ** ADC ADS1115
| |
| *** https://www.ti.com/lit/ds/symlink/ads1115.pdf?ts=1693292712477&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252Fde-de%252FADS1115
| |
| *** https://www.az-delivery.de/products/analog-digitalwandler-ads1115-mit-i2c-interface?variant=19034185039968
| |
| *** https://www.berrybase.de/ads1115-4-kanal-16-bit-ad-wandler-breakout-board
| |
| *** https://github.com/wollewald/ADS1115_mpy
| |
| *** https://github.com/robert-hh/ads1x15
| |
| *** https://pypi.org/project/ADS1115-mic-py/
| |
| *** https://www.grzesina.de/az/blog_robotcar/ads1115rc.py
| |
| *** https://how2electronics.com/ads1115-16-bit-adc-module-with-raspberry-pi-pico/
| |
| [[25. Lektion: DAC]]<br>
| |
| [[26. Lektion: Puls Weiten Modulation (PWM)]]<br>
| |
| [[27. Lektion: Watch Dog Timer (WDT)]]<br>
| |
| [[28. Lektion: Interrupts]]<br>
| |
| [[29. Lektion: Timer]]<br>
| |
|
| |
|
| | === Termine=== |
| | Im 2. Teil habe ich die Themen nicht fest den Terminen zugeordnet. Ich habe sie zwar in eine m.E. sinnvolle Reihenfolge gebracht, aber grundsätzlich sind wir frei in der Auswahl der Themen, die wir am Abend behandeln wollen. |
| | ==== 1. Abend==== |
| | Di. 16.1.24 |
| ==== 2. Abend==== | | ==== 2. Abend==== |
| 21.11.2023
| | Di. 23.1.2024 |
| <br>
| |
| | |
| [[30. Lektion: Das Filesystem]]
| |
| | |
| | |
| | |
| ===== Wlan=====
| |
| * https://www.youtube.com/watch?v=Me7VM2z3_f8
| |
| | |
| ===== Unix-Zeit=====
| |
| ACHTUNG ESP32 und Pico arbeiten mit unterschiedlichen Epochen:
| |
| <pre>
| |
| MicroPython v1.20.0 on 2023-04-26; Raspberry Pi Pico W with RP2040
| |
| >>> import time
| |
| >>> time.gmtime(0)
| |
| (1970, 1, 1, 0, 0, 0, 3, 1)
| |
| >>>
| |
| </pre>
| |
| | |
| <pre>
| |
| MicroPython v1.20.0 on 2023-04-26; ESP32 module with ESP32
| |
| >>> import time
| |
| >>> time.gmtime(0)
| |
| (2000, 1, 1, 0, 0, 0, 5, 1)
| |
| >>>
| |
| </pre>
| |
| | |
| ===== NTP/RTC=====
| |
| Die RTC des ESP32 soll sehr ungenau sein.
| |
| | |
| <pre>
| |
| MicroPython v1.20.0 on 2023-04-26; ESP32S3 module with ESP32S3
| |
| | |
| Type "help()" for more information.
| |
| | |
| >>> import network
| |
| >>> import ntptime
| |
| >>> from machine import RTC
| |
| | |
| # WLAN einrichten
| |
| | |
| >>> wlan = network.WLAN(network.STA_IF)
| |
| >>> wlan.active(True)
| |
| True
| |
| >>> wlan.connect('SSID', 'PW')
| |
| >>> wlan.isconnected()
| |
| False
| |
| >>> wlan.isconnected()
| |
| True
| |
| >>> wlan.ifconfig()
| |
| ('192.168.5.109', '255.255.255.0', '192.168.5.1', '192.168.5.1')
| |
| | |
| # Die RTC mit NTP einstellen
| |
| | |
| >>> ntptime.settime()
| |
| | |
| # Die RTC einrichten
| |
| | |
| >>> rtc = RTC()
| |
| | |
| >>> rtc.datetime()
| |
| (2023, 9, 5, 1, 15, 39, 56, 427762)
| |
| >>> rtc.datetime()
| |
| (2023, 9, 5, 1, 16, 14, 5, 837765)
| |
| >>> rtc.datetime()
| |
| (2023, 9, 5, 1, 16, 21, 42, 597764)
| |
| >>> dir(ntptime)
| |
| ['__class__', '__name__', '__dict__', '__file__', 'socket', 'struct', 'time', 'timeout', 'utime', '__version__', 'host', 'settime']
| |
| >>> ntptime.time()
| |
| 747246194
| |
| >>> rtc.datetime()
| |
| (2023, 9, 5, 1, 16, 23, 49, 897771)
| |
| >>> ntptime.time()
| |
| 747246234
| |
| >>> ntptime.utime
| |
| <module 'utime'>
| |
| >>> rtc.datetime()
| |
| (2023, 9, 5, 1, 16, 24, 29, 867765)
| |
| >>> ntptime.time()
| |
| 747246276
| |
| >>> import time
| |
| >>> dir(time)
| |
| ['__class__', '__name__', '__dict__', 'gmtime', 'localtime', 'mktime', 'sleep', 'sleep_ms', 'sleep_us', 'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us', 'time', 'time_ns']
| |
| >>> time.gmtime()
| |
| (2023, 9, 5, 16, 25, 39, 1, 248)
| |
| >>> time.localtime()
| |
| (2023, 9, 5, 16, 25, 57, 1, 248)
| |
| >>> time.mktime(rtc.datetime())
| |
| 747191787
| |
| >>> ntptime.time()
| |
| 747246461
| |
| >>> time.mktime(rtc.datetime())
| |
| 747191787
| |
| >>> ntptime.time()
| |
| 747246472
| |
| >>> time.mktime(rtc.datetime())
| |
| 747191788
| |
| >>> ntptime.time()
| |
| 747246489
| |
| >>>
| |
| </pre>
| |
| | |
| ===== Datum und Uhrzeit=====
| |
| | |
| ===== Links:=====
| |
| | |
| ==== 3. Abend==== | | ==== 3. Abend==== |
| 28.11.2023
| | Di. 30.1.2024 |
| | ==== 4. Abend==== |
| | Di. 6.2.2024 |
| | ==== 5. Abend==== |
| | Di. 13.2.2024 |
| <br> | | <br> |
| * Display anschließen
| |
| ** https://github.com/TimAEllis/ssd1306-py/blob/master/ssd1306.py
| |
| ** https://www.grzesina.de/az/blog_robotcar/ssd1306.py
| |
|
| |
|
| | === Themen=== |
| | [[19. Lektion: Raspberry Pi Pico W]]<br> |
| | [[20. Lektion: Vorstellung des Experimentierboards]]<br> |
| | [[21. Lektion: Pin's]]<br> |
| | [[22. Lektion: Neopixel]]<br> |
| | [[23. Lektion: Onewire]]<br> |
| | ---- |
| | [[24. Lektion: UART]]<br> |
| | [[25. Lektion: I2C]]<br> |
| | [[25a. Lektion: Fonts]] - Spätere Ergänzung - noch in Arbeit<br> |
| | [[26. Lektion: SPI]]<br> |
| | [[27. Lektion: ADC]]<br> |
| | [[28. Lektion: DAC]] - Der Raspberry Pi Pico W hat keinen DAC<br> |
| | ---- |
| | [[29. Lektion: Puls Weiten Modulation (PWM)]]<br> |
| | [[30. Lektion: Watch Dog Timer (WDT)]] - s. 32. Lektion: Timer<br> |
| | [[31. Lektion: Interrupts]]<br> |
| | [[32. Lektion: Timer]]<br> |
| | ---- |
| | [[33. Lektion: Wlan]]<br> |
| | [[34. Lektion: NTP/RTC]]<br> |
| | ---- |
| | [[35. Lektion: HTTP Briefing]]<br> |
| | [[36. Lektion: HTML Briefing]]<br> |
| | [[37. Lektion: Request]]<br> |
| | [[38. Lektion: Webserver]]<br> |
| | [[39. Lektion: Webseiten für den Webserver erstellen]]<br> |
| <br> | | <br> |
| * Webserver
| |
| ** Raspberry Pi Pico
| |
| *** MicroWebSrv
| |
| **** https://github.com/jczic/MicroWebSrv
| |
| **** https://forums.raspberrypi.com/viewtopic.php?t=338692
| |
| *** Andere Links mit Sockets:
| |
| **** http://www.doctormonk.com/2022/09/a-better-web-server-for-raspberry-pi.html
| |
| **** https://microdot.readthedocs.io/en/latest/intro.html
| |
| **** https://wellys.com/posts/rp2040_microphyton_webserver/
| |
| **** https://github.com/miguelgrinberg/microdot
| |
|
| |
|
| |
| ==== 4. Abend====
| |
| ** https://medium.com/codex/11-python-coding-habits-that-make-you-a-bad-programmer-5e3306077686
| |
| ** https://blog.devgenius.io/50-python-features-tips-tricks-that-you-dont-know-8a2cb55cd493
| |
| ** https://medium.com/@shivam2003/20-python-concepts-i-wish-i-knew-way-earlier-40ed5674cd52
| |
| * String Bearbeitung
| |
| ** https://medium.com/@techclaw/python-split-a-comprehensive-guide-3aec8d589806
| |
| * List comprehensions
| |
| ** https://python.plainenglish.io/mastering-pythons-list-comprehensions-e93b147a8c0b
| |
| ** https://medium.com/@mr.stucknet/python-comprehensions-demystified-writing-code-like-a-wizard-a8c50d3ed428
| |
| * Menue erstellen
| |
| ** https://github.com/Lysander/snippets/blob/master/Python/python-misc/simplemenus/TUTORIAL.md
| |
| * Compiler
| |
| ** https://python.plainenglish.io/i-explored-pythons-powerful-compile-function-and-discovered-e315d23b8e7e
| |
| * Sortieren
| |
| ** https://medium.com/@huzaifazahoor654/sorting-with-all-data-structures-in-python-c697a34931c0
| |
| * Wertgleichheit == und Identität is
| |
|
| |
| * Regulare Expressions
| |
| ** https://python.plainenglish.io/introduction-to-regular-expressions-in-python-a77f1c860b13
| |
|
| |
| === Bytearray / Bytestring===
| |
| Werden nur zur Vorbereitung auf eine serielle Datenübertragung verwendet.<br>
| |
| Datenstrukturen werden in einzelne Bytes zerlegt.<br>
| |
| [https://www.freecodecamp.org/news/python-bytes-to-string-how-to-convert-a-bytestring/ python-bytes-to-string-how-to-convert-a-bytestring ]<br>
| |
| [https://www.w3resource.com/python/python-bytes.php python-bytes]<br>
| |
|
| |
| ==== 5. Abend====
| |
|
| |
|
| |
|
| ===== Kritik===== | | === Diverse Themen=== |
| | [[xxx. Lektion: Diverse Themen]] |
|
| |
|
| <br>
| | ==Navigation== |
| $ jupyter notebook<br>
| | [[Micropython Kurs 2023|Zurück zur''' "Micropython Kurs 2023" '''Startseite]]<br> |
| <br> | | [[Programmieren|Zurück zur '''Programmieren''' Startseite]]<br> |
| <br> | | [[Attraktor_Wiki|Zurück zur '''Wiki''' Startseite]]<br> |
| | |
| <br> | |