Micropython Kurs 2023 - Teil 2: Difference between revisions
| Line 29: | Line 29: | ||
[[26. Lektion: I2C]]<br> | [[26. Lektion: I2C]]<br> | ||
[[27. Lektion: ADC]]<br> | [[27. Lektion: ADC]]<br> | ||
[[28. Lektion: DAC]]<br> | [[28. Lektion: DAC]]<br> | ||
[[29. Lektion: Puls Weiten Modulation (PWM)]]<br> | [[29. Lektion: Puls Weiten Modulation (PWM)]]<br> | ||
Revision as of 21:52, 19 November 2023
Micropython Kurs 2023 - Teil 2
Hier werden wir den Umgang mit der Microcontroller spezifischen Hardware lernen.
1. Abend
Di. 16.1.24
2. Abend
Di. 23.1.2024
3. Abend
Di. 30.1.2024
4. Abend
Di. 6.2.2024
5. Abend
Di. 13.2.2024
Themen
19. Lektion: Raspberry Pi Pico W
20. Lektion: Vorstellung des Experimentierboards
21. Lektion: Pin's
22. Lektion: Neopixel
23. Lektion: Onewire
24. Lektion: UART
25. Lektion: SPI
26. Lektion: I2C
27. Lektion: ADC
28. Lektion: DAC
29. Lektion: Puls Weiten Modulation (PWM)
30. Lektion: Watch Dog Timer (WDT)
31. Lektion: Interrupts
32. Lektion: Timer
33. Lektion: Wlan
34. Lektion: NTP/RTC
35. Lektion:
Wlan
Unix-Zeit
ACHTUNG ESP32 und Pico arbeiten mit unterschiedlichen Epochen:
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) >>>
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) >>>
NTP/RTC
Die RTC des ESP32 soll sehr ungenau sein.
- https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/rtc-und-ntp-in-micropython-mit-esp8266-und-esp32-teil-1
- https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/rtc-und-ntp-in-micropython-mit-esp8266-und-esp32-teil-2-tiefschlaf?utm_source=90%20Day%20Engaged&utm_medium=email&utm_campaign=220523_Hydroponik%20-%20Pflanzen%20ohne%20Erde_Blog%20%2801H0SBCNDVZF5ZP2WDDDZXW24A%29&utm_content=RTC%20und%20NTP%20in%20MicroPython%20Teil%202&utm_term=Campaign&_kx=t6chfMYPTCmi3Q3FmsDDDGHlL3Kt6ctVyJh9Hkft9JU%3D.QVRJMi
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
>>>
Datum und Uhrzeit
Links:
- Wetter-API
- Display anschließen
- Webserver
- https://github.com/jczic/MicroWebSrv2
- Raspberry Pi Pico
- MicroWebSrv - geht nicht!
- Andere Links mit Sockets:
- http://www.doctormonk.com/2022/09/a-better-web-server-for-raspberry-pi.html
- https://github.com/miguelgrinberg/microdot
- https://microdot.readthedocs.io/en/latest/intro.html
- https://wellys.com/posts/rp2040_microphyton_webserver/
- https://github.com/miguelgrinberg/microdot
- https://www.rasppishop.de/pico-w-als-webserver
- https://www.elektronik-kompendium.de/sites/raspberry-pi/2707131.htm
- https://www.youtube.com/watch?v=RN2k_0mrKxI
- https://www.youtube.com/watch?v=Me7VM2z3_f8
- https://draeger-it.blog/raspberry-pi-pico-w-programmieren-eines-webservers/
- https://hackaday.io/project/189675-raspberry-pi-pico-w-super-simple-webserver
- https://github.com/sciencedude1990/MicropythonPicoWebServer
- Dictionaries:
- Diverses:
- https://python.plainenglish.io/top-10-python-lambda-function-examples-for-beginners-fd5db038ba20
- https://medium.com/@sarperismetmakas/python-bytes-92ba69ddafba
- https://tonylixu.medium.com/python-tips-how-to-write-better-functions-part-one-27fe4578e26e
- https://python.plainenglish.io/10-cool-less-known-dictionary-methods-in-python-9eef4081c263
- https://pythonflood.com/python-bitwise-operators-building-blocks-of-advanced-programming-a953c1715883
- https://medium.com/@Scofield_Idehen/advanced-python-tips-for-development-47e061ecee70
- https://python.plainenglish.io/write-better-code-with-python-comprehension-bad8376e44ee
- https://medium.com/techtofreedom/3-uses-of-walrus-operators-in-python-207ff630fc0e
- https://levelup.gitconnected.com/lambda-functions-in-python-a124cebc2e99
- https://pythonflood.com/boost-your-coding-abilities-with-python-exec-function-bec400c53e9c
- https://medium.com/geekculture/understanding-the-ternary-operator-in-python-717bd789d373
- https://medium.com/analytics-vidhya/python-how-to-write-less-code-to-achieve-the-same-results-3b48fdb4ded4
- https://levelup.gitconnected.com/6-4-built-in-python-functions-you-cannot-miss-out-on-9dec1b566e1f
- https://medium.com/techtofreedom/19-sweet-python-syntax-sugar-for-improving-your-coding-experience-37c4118fc6b1
- 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 Formatierung
- List comprehensions
- Dokumentation
- pass
- Menue erstellen
- Compiler
- Sortieren
- Wertgleichheit == und Identität is
- 16. Lektion: Funktionen.extend()
- Generatoren
- Regulare Expressions
- Listen
- Slicing
- Konstanten
- copy deep und flach
- https://www.heise.de/ratgeber/Phyton-Welche-Auflistungstypen-es-gibt-und-wie-sie-verwendet-werden-9216638.html?seite=all
- https://levelup.gitconnected.com/30-phyton-concepts-i-wish-i-knew-way-earlier-3add72af6433
- Bool
- bool(mylist) - not
Sortieren
Mitgliedschaft
- in
For/Else
Bytearray / Bytestring
Werden nur zur Vorbereitung auf eine serielle Datenübertragung verwendet.
Datenstrukturen werden in einzelne Bytes zerlegt.
python-bytes-to-string-how-to-convert-a-bytestring
python-bytes
5. Abend
Di. 13.2.2024
Kritik
$ jupyter notebook
Zurück zu Micropython Kurs 2023 - Teil 2
Zurück zur "Micropython Kurs 2023" Startseite
Zurück zur Programmieren Startseite
Zurück zur Wiki Startseite