{"id":14967257,"url":"https://github.com/peterhinch/micropython-samples","last_synced_at":"2025-05-15T15:08:26.725Z","repository":{"id":40414459,"uuid":"47072457","full_name":"peterhinch/micropython-samples","owner":"peterhinch","description":"Assorted code ideas, unofficial MP FAQ, plus index to my other repositories.","archived":false,"fork":false,"pushed_at":"2025-02-06T11:12:31.000Z","size":3396,"stargazers_count":494,"open_issues_count":13,"forks_count":96,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-03-31T20:07:34.572Z","etag":null,"topics":["embedded","esp32","esp8266","micropython","stm32"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterhinch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-29T17:12:45.000Z","updated_at":"2025-03-31T12:09:32.000Z","dependencies_parsed_at":"2024-01-03T15:44:54.994Z","dependency_job_id":"d1c8cd27-b301-47e7-93b1-506d60b84603","html_url":"https://github.com/peterhinch/micropython-samples","commit_stats":{"total_commits":283,"total_committers":7,"mean_commits":40.42857142857143,"dds":0.02473498233215543,"last_synced_commit":"d2929df1b4556e71fcfd7d83afd9cf3ffd98fdac"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterhinch","download_url":"https://codeload.github.com/peterhinch/micropython-samples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730069,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded","esp32","esp8266","micropython","stm32"],"created_at":"2024-09-24T13:37:43.609Z","updated_at":"2025-04-07T21:12:15.415Z","avatar_url":"https://github.com/peterhinch.png","language":"Python","readme":"# micropython-samples\n\nThe first part of this repo comprises assorted code ideas for MicroPython and\nalso serves as an unofficial MicroPython FAQ. Some samples are targeted at\nPyboard variants. Some are intended as pointers for programmers rather than\nbeing complete solutions. Egregious bugs will be fixed but I may not accept\nfeature requests.\n\n[Section 5](./README.md#5-module-index) is an index to complete applications\nand modules which are documented and supported.\n\nPlease also see the [official examples](https://github.com/micropython/micropython/tree/master/examples).\n\n# 0. Index\n\n 1. [Installation guides](./README.md#1-installation-guides)  \n  1.1 [Installing MicroPython libraries](./README.md#11-installing-micropython-libraries)  \n  1.2 [Fastbuild](./README.md#12-fastbuild) Build scripts and udev rules  \n  1.3 [A web framework](./README.md#13-a-web-framework) Microdot.  \n  1.4 [Buildcheck](./README.md#14-buildcheck) Check firmware build date  \n  1.5 [A USB pitfall](./README.md#15-a-usb-pitfall) A problem with platforms which share their filesystem with the PC.  \n 2. [Hardware information and drivers](./README.md#2-hardware-information-and-drivers)  \n  2.1 [ESP32](./README.md#21-esp32) Pinout and notes on the reference board  \n  2.2 [SSD1306](./README.md#22-ssd1306) Write large fonts to the SSD1306.  \n  2.3 [Pyboard D](./README.md#23-pyboard-d) Some information remains absent or hard to find in the docs.  \n  2.4 [DS3231 MAX31328 precision RTC](./README.md#24-ds3231-max31328-precision-rtc) Use cheap hardware to calibrate Pyboard RTC.  \n 3. [Essays](./README.md#3-essays) General thoughts.  \n  3.1 [Resilient](./README.md#31-resilient) A guide to writing resilient WiFi code  \n  3.2 [Serialisation](./README.md#32-serialisation) Review of MicroPython's five serialisation libraries  \n  3.3 [Measurement of relative timing and phase of fast analog signals](./README.md#33-measurement-of-relative-timing-and-phase-of-fast-analog-signals) For Pyboard.  \n  3.4 [Import subtleties](./README.md#34-import-subtleties) Ways to save RAM with import statements.  \n 4. [Code samples](./README.md#4-code-samples) Samples prefixed Pyboard are Pyboard specific  \n  4.1 [Pyboard Mutex](./README.md#41-pyboard-mutex) Share data between threads and ISR's.  \n  4.2 [Pyboard watchdog](./README.md#42-pyboard-watchdog) Access a Pyboard hardware WDT.  \n  4.3 [Software Watchdog](./README.md#43-software-watchdog) Cross-platform soft WDT.  \n  4.4 [Reverse](./README.md#44-reverse) Reversal algorithms for bytearrays.  \n  4.5 [Timed function](./README.md#45-timed-function) Time execution with a decorator.  \n  4.6 [ESP8266 MQTT benchmark](./README.md#46-esp8266-mqtt-benchmark) Test performance of MQTT with official library.  \n  4.7 [Rotary incremental encoder](./README.md#47-rotary-incremental-encoder) Fast, simple, proven algorithm.  \n  4.8 [Pseudo random number generators](./README.md#48-pseudo-random-number-generators)  \n  4.9 [Verifying incrementing sequences](./README.md#49-verifying-incrementing-sequences) Test communications drivers.  \n  4.10 [Bitmaps](./README.md#410-bitmaps) Non-allocating ways to access bitmaps.  \n  4.11 [Functors and singletons](./README.md#411-functors-and-singletons) Useful decorators.  \n  4.12 [Quaternions](./README.md#412-quaternions) Scale, move and rotate 3D objects with minimal mathematics.  \n  4.13 [A Pyboard power meter](./README.md#413-a-pyboard-power-meter) One of my own projects.  \n  4.14 [NTP time](./README.md#414-ntp-time) More portable than official driver with other benefits.  \n  4.15 [Date](./README.md#415-date) Small and simple classes for handling dates.  \n  4.16 [Greatest common divisor](./README.md#416-greatest-common-divisor) Neat algorithm.  \n  4.17 [2D array indexing](./README.md#417-2d-array-indexing) Use `[1:3, 20]` syntax to address a 2D array.  \n  4.18 [Astronomy](./README.md#418-astronomy) Derive Sun and Moon rise and set times, moon phase.  \n  4.19 [Tone detection](./README.md#419-tone-detection) Goertzel algorithm.  \n 5. [Module Index](./README.md#5-module-index) Supported code. Device drivers, GUI's, utilities.  \n  5.1 [asyncio](./README.md#51-asyncio) Tutorial and drivers for asynchronous coding.  \n  5.2 [Memory Device Drivers](./README.md#52-memory-device-drivers) Drivers for nonvolatile memory devices.  \n  5.3 [Inertial Measurement Units](./README.md#53-inertial-measurement-units) Gravity, gyro and magnetic sensors.  \n  5.4 [Other hardware drivers](./README.md#54-other-hardware-drivers)  \n  5.5.[Communications](./README.md#55-communications)  \n  5.6 [Displays](./README.md#56-displays) Fonts, graphics, GUIs and display drivers  \n  5.7 [Pyboard micropower](./README.md#57-pyboard-micropower)  \n  5.8 [Pyboard DSP](./README.md#58-pyboard-dsp) Fourier transforms and filters.  \n  5.9 [rshell](./README.md#59-rshell) Fork of rshell with text macros.  \n  5.10 [Hard to categorise](./README.md#510-hard-to-categorise) Other modules.  \n\n# 1. Installation guides\n\n## 1.1 Installing MicroPython libraries\n\nPlease read\n[the official docs](http://docs.micropython.org/en/latest/reference/packages.html#packages).\n[This doc](./micropip/README.md) describes a simple way to override modules\nwhich have been incorporated in firmware as frozen bytecode.\n\n## 1.2 Fastbuild\n\nScripts for building MicroPython for various target hardware types and for\nupdating your local source. Now detects and builds for Pyboard D. See\n[docs](./fastbuild/README.md)\n\n## 1.3 A Web Framework\n\nPaul Sokolovsk's [PicoWeb](https://github.com/pfalcon/picoweb) requires his\nfork of MicroPython and requires some modification to run under official\nMicroPython.\n\nThe solution preferred by MicroPython maintainers is\n[Microdot](https://microdot.readthedocs.io/en/latest/).\n\n## 1.4 Buildcheck\n\nRaise an [exception](./buildcheck/buildcheck.py) if a firmware build is earlier\nthan a given date.\n\n## 1.5 A USB pitfall\n\nBy default the Pyboard's `/flash/boot.py` enables MSC (mass storage) mode. This\nmakes the Pyboard look like a USB stick, making its filesystem visible to the\nPC. This helpful feature ignores a fundamental flaw which leads to filesystem\ncorruption. This is because the USB standard requires mass storage devices to\nbehave like disks with static content. By contrast a Pyboard can independently\nmodify the \"disk\" contents causing chaos.\n\nTo fix this, edit `/flash/boot.py` so that the `usb_mode` line reads:\n```python\npyb.usb_mode('VCP')\n```\nOn reboot the Pyboard will no longer appear as a mass storage device on the PC.\nVarious tools are available to manage the device's storage via USB. I use\n[rshell](https://github.com/dhylands/rshell).\n\n# 2. Hardware information and drivers\n\n## 2.1 ESP32\n\nPinout diagram for the reference board with notes and warnings about reserved\npins etc. See [this doc](./ESP32/ESP32-Devkit-C-pinout.pdf). See also this\nexcellent [resource](https://randomnerdtutorials.com/esp32-pinout-reference-gpios/).\n\n## 2.2 SSD1306\n\nA means of rendering multiple larger fonts to the SSD1306 OLED display. The\n`Writer` class which performs this has been substantially improved and may now\nbe found as part of [this repository](https://github.com/peterhinch/micropython-font-to-py).\n\n## 2.3 Pyboard D\n\nAssorted [information](./pyboard_d/README.md) not yet in the official docs or\nhard to find.\n\n## 2.4 DS3231 MAX31328 precision RTC\n\nThis is a low cost precision battery backed real time clock (RTC) accurate to\n+-2 minutes/year. Two drivers are provided, one portable across platforms and\none which is Pyboard specific.\n\nThis driver also supports the MAX31328 which is a 100% compatible chip from the\nsame manufacturer.\n\nThe Pyboard-specific driver provides a facility to calibrate the Pyboard's RTC\nfrom the DS3231. Calibration to high precision may be achieved in five minutes.\n\nThe drivers are [documented here](./DS3231/README.md).\n\n##### [Index](./README.md#0-index)\n\n# 3. Essays\n\n## 3.1 Resilient\n\nA [guide](./resilient/README.md) to writing reliable ESP8266 networking code.\nProbably applies to other WiFi connected MicroPython devices.\n\n## 3.2 Serialisation\n\n[A discussion](./SERIALISATION.md) of the need for serialisation and of the\nrelative characteristics of five libraries available to MicroPython. Includes a\ntutorial on a Protocol Buffer library.\n\n## 3.3 Measurement of relative timing and phase of fast analog signals\n\nThis describes ways of using the Pyboard to perform precision measurements of\nanalog signals of up to around 50KHz. It is documented [here](./phase/README.md).\n\n## 3.4 Import subtleties\n\n[This doc](./import/IMPORT.md) describes a way to save RAM with Damien's lazy\nloader, a `reload` function, and ways to use wildcard imports.\n\n##### [Index](./README.md#0-index)\n\n# 4. Code samples\n\n## 4.1 Pyboard mutex\n\nA [class](./mutex/README.md) providing mutual exclusion enabling hard interrupt\nhandlers and the main program to access shared data in a manner which ensures\ndata integrity.\n\n## 4.2 Pyboard watchdog\n\n[Access](./watchdog/wdog.py) the simpler of the Pyboard's watchdog timers.\n\n## 4.3 Software watchdog\n\nA [software watchdog](./soft_wdt/soft_wdt.py) timer with a fixed or variable\ntimeout. Supports temporary suspension and permanent cancellation. The latter\ncan be useful when debugging code to prevent a machine reboot when the\napplication fails, terminates or is interrupted with ctrl-c. See code and\ncomments in [the test script](./soft_wdt/swdt_tests.py).\n\n## 4.4 Reverse\n\nFast [reverse](./reverse/reverse.py) a bytearray in Arm Thumb assembler: this\nreverses the byte order of the array so `[1,2,3,4]` becomes `[4,3,2,1]`.  \n\nAlso includes cross-platform Python code to bit-reverse (fast-ish) 8, 16 and 32\nbit words.\n\n## 4.5 Timed function\n\nTime a function's execution using a [decorator](./timed_function/timed_func.py)\nand implement timeouts using a [closure](./timed_function/timeout.py).\n\n##### [Index](./README.md#0-index)\n\n## 4.6 ESP8266 MQTT benchmark\n\n[This benchmark](./ESP8266/benchmark.py) tests the performance of MQTT by\nperiodically publishing while subscribed to the same topic. Measures the\nround-trip delay. Uses the official `umqtt.simple` library. Adapt to suit your\nserver address and desired QOS (quality of service, 0 and 1 are supported).\nAfter 100 messages reports maximum and minimum delays.\n\n[This connect utility](./esp32/conn.py) connects in station mode using saved\nconnection details where possible.\n\n## 4.7 Rotary Incremental Encoder\n\nThese devices produce digital signals from a shaft's rotary motion in such a\nway that the absolute angle may be deduced. Specifically they measure\nincremental change: it is up to the code to keep track of absolute position, a\ntask which has some pitfalls. [This doc](./encoders/ENCODERS.md) discusses this\nand points to some solutions in MicroPython code.\n\n## 4.8 Pseudo random number generators\n\nOn the Pyboard V1.1, true random numbers may be generated rapidly with\n`pyb.rng()` which uses a hardware random number generator on the\nmicrocontroller.\n\nThere are a few use-cases for pseudo random number generators. Some platforms\nlack a hardware generator (e.g. the Pyboard Lite) and some ports don't support\n`uos.urandom`. There is also a case for running a RNG in an interrupt service\nroutine.\n\nPseudo random number generators provide repeatable sequences of numbers which\ncan be an advantage, for example in testing. The RNG is seeded with an initial\nvalue. On each call to the function it will return a random number, but (given\nthe same seed) the sequence of numbers following initialisation will always be\nthe same.\n\nSee [random.py](./random/random.py) for usage and timing documentation. The\n[yasmarang generator](./random/yasmarang.py) is also included, along with my\nown [cheap random](./random/cheap_rand.py). The latter constrains calculations\nto 30 bits, allowing its use in an ISR. It comes with no guarantees of random\nquality and the only statistical test is that the mean converges on the right\nvalue. None of these generators are suitable for cryptography.\n\n## 4.9 Verifying incrementing sequences\n\nWhen testing communications applications it is often necessary to check for\nmissing, duplicated, or out-of-order messages. To do this, the transmitter test\nscript ensures that messages include an incrementing message number. The\nreceiver script verifies the sequence. [The CheckMid class](./sequence/check_mid.py)\ndoes this, also detecting transmitter reboots\n\n##### [Index](./README.md#0-index)\n\n## 4.10 Bitmaps\n\nA bitmap stored in a pre-allocated, fixed size bytearray may be viewed in two\nways:\n 1. As a set of positive integers whose values are constrained within limits.\n 2. As a fixed size one dimensional array of booleans.\n\nThese views provide a Pythonic interface while retaining the non-allocating\nperformance advantage relative to native sets and lists.\n\nThe file [bitmap.py](./bitmap/bitmap.py) offers classes supporting these views.\n\nThe constraint `0 \u003c= value \u003c= max_value` applies where `max_value` is a\nconstructor arg. The `max_value` arg defines the size of the underlying\nbytearray. For example if `max_value` is 255, the bytearray will use 32 bytes.\nThe constraint applies to member values of a set, and to index values of a\nboolean array. So the set will be capable of storing integers from 0 to 255,\nand the array will accept indices in the same range.\n\nThese classes are lightweight. For example the `IntSet` class does not include\nall the dunder (magic) methods required to match the native `set` class. These\nmay readily be added as required.\n\n## 4.11 Functors and singletons\n\nTwo simple class decorators for objects useful in hardware interfacing.\nDocumented [here](./functor_singleton/README.md).\n\nSingletons denote classes for which only a single instance can ever occur.\nThey can be useful for hardware interface classes. Their use avoids the need\nfor a global instance: the sole instance may be retrieved efficiently from\nanywhere in the code.\n\nA functor is a class which is accessed via function call syntax. There is only\none instance, like a singleton. Initial access calls the constructor, with\nsubsequent accesses being via `__call__`. As an object it can retain state. As\nan example, a functor might have a continuously running task: successive calls\nmodify the behaviour of the task.\n\n## 4.12 Quaternions\n\nQuaternions have a reputation for being mathematically difficult. Surely true\nif you intend using them to write Maxwell's equations (as per Maxwell). If your\nambitions are limited to manipulating three dimensional objects or processing\nIMU data they can be remarkably simple.\n\nThe `Quaternion` class lets you create, move, transform and rotate 3D objects.\nThey assume no maths beyond familiarity with an `xyz` coordinate system.\nIncludes a demo where a wireframe cube rotates in response to movements of a\nBNo055 IMU, plus a demo of moving wireframe graphics. Neither demo uses trig\nfunctions. See [the docs](./QUATERNIONS.md).\n\n## 4.13 A pyboard power meter\n\nThis uses a Pyboard to measure the power consumption of mains powered devices.\nUnlike simple commercial devices it performs a true vector (phasor) measurement\nenabling it to provide information on power factor and to work with devices\nwhich generate as well as consume power. It uses the official LCD160CR display\nas a touch GUI interface. It is documented [here](./power/README.md).\n\n## 4.14 NTP Time\n\nThe official code has a number of drawbacks, mainly a lack of portability.\n 1. It does not check the host device's epoch. This version returns the number\n of seconds since the host device's epoch. [Official version is now fixed].\n 2. It uses socket timeouts while the docs recommend select.poll as being more\n portable. This version remedies that.\n 3. This version has very basic support for local time in the form of an offset\n in hours relative to UTC.\n 4. In the event of a timeout this version returns 0: the caller should check\n for this and re-try after a period.\n\nCode is [here](./ntptime/ntptime.py).\n\nIt seems impractical to write a portable version of `settime` as the\n`machine.RTC` class is not yet fully portable.\n\nIt's worth noting that NTP queries do time out. The default timeout is 1s: on\nmany WANs this is quite demanding, yet for obvious reasons a longer value does\nnot benefit precision. Another issue is that issuing NTP queries too frequently\ncauses the time server to send a KoD (Kiss of Death) packet. The official\nversion issues a large negative number which causes `.settime` to throw an\nexception. The version here returns 0: the caller should test for this. I\nsuspect that this also occurs occasionally in non-KoD circumstances.\n\nFinally, an option is to run the NTP daemon on a local server which can be as\nsimple as a Raspberry Pi. This gives high accuracy and should eliminate\ntimeouts. Install with:\n```bash\n$ sudo apt install -y ntp ntpdate\n```\nand point the MicroPython device at the local server with:\n```python\nntptime.host=\"192.168.0.10\"  # Server address.\nntptime.time()\n```\n## 4.15 Date\n\nThe official [datetime module](https://github.com/micropython/micropython-lib/tree/master/python-stdlib/datetime)\nis fully featured but substantial. This `Date` class has no concept of time,\nbut is very compact. Dates are stored as a small int. Contrary to normal MP\npractice, properties are used. This allows basic arithmetic syntax while\nensuring automatic rollover. The speed penalty of properties is unlikely to be\na factor in date operations.\n\nThe `Date` class provides basic arithmetic and comparison methods. The\n`DateCal` subclass adds pretty printing and methods to assist in creating\ncalendars.\n\nThe classes are documented [here](./date/DATE.md)\n\n## 4.16 Greatest Common Divisor\n\nThis was found [here](https://github.com/micropython/micropython/pull/8331#issuecomment-1556291482):\n```python\ndef gcd(a, b) :\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n```\n## 4.17 2D array indexing\n\nThis enables a class to be written that maps a 2D address onto an underlying 1D\naddressable object such as an array, list or random access file. An instance\ncan then be accessed with syntax such as\n```python\ns = sum(obj[5, 0:20])  # Sum row 5, cols 0..19 (or x = 5, y = 0..19)\nobj[10, 10] = 42\nobj[0:5, 3] = iter(range(100, 105))\n```\nSee [the docs](./parse2d/README.md).\n\n##### [Index](./README.md#0-index)\n\n## 4.18 Astronomy\n\nThis module enables Sun and Moon rise and set times to be determined for timing\napplications or for lunar clocks. Moon phase can also be accessed. Designed to\nwork at global locations and timezones. See [docs](./astronomy/README.md).\n\n## 4.19 Tone detection\n\nThis module may be used for detection of audio tones. It uses the Goertzel\nalgorithm which is effectively a single-bin Fourier transform. See\n[docs](./goertzel/README.md).\n\n# 5. Module index\n\nThis index references applications and device drivers that I have developed, in\nsome cases as collaborations. This is acknowledged in their respective docs.\n\nUnlike the code samples these are fully documented and supported.\n\n## 5.1 asyncio\n\n[Tutorial](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/TUTORIAL.md)\nMain focus: using asyncio to drive and communicate with hardware devices.  \n[Drivers](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/DRIVERS.md)\nAsynchronous device drivers for switches, pushbuttons and ADC's. Also has\ninformation on interfacing interrupts to asyncio.  \n[Asynchronous monitor](https://github.com/peterhinch/micropython-monitor) Use a\nraspberry Pico and a logic analyser or scope to monitor asynchronous code.  \n[Schedule](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/SCHEDULE.md)\nSchedule events at specified times and dates.  \n[HTU21D](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/HTU21D.md)\nAsynchronous driver for this temperature and humidity sensor.  \n[I2C Slave](https://github.com/peterhinch/micropython-async/tree/master/v3/docs)\nUses the Pyboard's I2C slave mode to implement a full duplex asynchronous\nlink. Principal use case is for ESP8266 which has only one UART.  \n[GPS](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/GPS.md)\nSee [section 5.4](./README.md#54-other-hardware-drivers).  \n\n## 5.2 Memory device drivers\n\n[EEPROM](https://github.com/peterhinch/micropython_eeprom) Support for EEPROM,\nFRAM and Flash chips and modules. In all cases devices or sets of devices can\nbe configured as a single memory array supporting access either as an array of\nbytes or as a filesystem.  \n\n## 5.3 Inertial Measurement Units\n\n[BNo055](https://github.com/micropython-IMU/micropython-bno055) In my view the\nbest IMU as it performs internal sensor fusion.  \n[MPU9x50](https://github.com/micropython-IMU/micropython-mpu9x50) Driver for\nthe popular InvenSense MPU9250, MPU9150, MPU6050 devices.  \n[BMP180](https://github.com/micropython-IMU/micropython-bmp180) Driver for the\nBosch BMP180 pressure/temperature sensor.  \n[Fusion](https://github.com/micropython-IMU/micropython-fusion) Sensor fusion:\ncombine IMU readings to produce heading, pitch and roll or Quaternion data.  \n[Quaternions](./README.md#412-quaternions) The proper way to deal with 3D\nrotations. Amazingly requires less maths than Euler angles.  \n\n## 5.4 Other hardware drivers\n\n[Asynchronous GPS driver](https://github.com/peterhinch/micropython-async/blob/master/v3/docs/GPS.md)  \n[Thermal IR](https://github.com/peterhinch/micropython-amg88xx) Support for the\nAdafruit 3538 thermal camera. Includes optional bicubic interpolation.  \n[Audio](https://github.com/peterhinch/micropython-vs1053) High quality audio\nI/O with the Adafruit VS1053 board. Synchronous and asynchronous options.  \n[IR remotes](https://github.com/peterhinch/micropython_ir) Support for various\ninfra red protocols in receiver or transmitter ('blaster') applications.  \n[433MHz remote](https://github.com/peterhinch/micropython_remote) Supports\n433MHz remote controlled wall sockets. Captures the signal enabling replay so\nthat mains devices may safely be controlled at low cost.  \n[BME280](https://github.com/peterhinch/mpy_bme280_esp8266) A bugfix fork of an\nabandoned project. Supports the BME280 combined temperature, pressure and\nhumidity sensor on ESP8266.  \n\n## 5.5 Communications\n\n[Asynchronous MQTT](https://github.com/peterhinch/micropython-mqtt/blob/master/mqtt_as/README.md)\nThis improves on official MQTT drivers by recovering from WiFi outages and\noffering asynchronous operation. Now also supports micropower applications on\nESP32 using ESPNow (via an MQTT subset).  \n[IOT](https://github.com/peterhinch/micropython-iot) An IOT solution. Provides\na socket-like interface between WiFi clients and a server with wired ethernet.\nThe interface is resilient in the presence of WiFi outages. The server (e.g.\nRaspberry Pi) does any internet work, improving security.  \n[MessagePack](https://github.com/peterhinch/micropython-msgpack) Serialisation\nwith usage almost identical to `ujson` but with message compression and other\nadvantages.  \n[Radio](https://github.com/peterhinch/micropython-radio) Simplify use of the\nofficially supported NRF24l01 radio.  \n\n## 5.6 Displays\n\nFonts, graphics, GUIs and display drivers.\n\nAll GUIs are based on asyncio. Where input is supported a callback-based\ninterface is provided: knowledge of asyncio is not required for their use.\n\n[font-to-py](https://github.com/peterhinch/micropython-font-to-py) Converts\nindustry standard font files to Python source which may be frozen as bytecode.\nFiles use minimal RAM when frozen.  \n[writer](https://github.com/peterhinch/micropython-font-to-py/blob/master/writer/WRITER.md)\nA simple way to render text to displays where the driver is subclassed from\n`framebuf`.  \n[nano-gui](https://github.com/peterhinch/micropython-nano-gui) Simple output\nonly GUI for displays where the driver is subclassed from `framebuf`. Repo\nincludes display drivers for various displays including TFT, OLED, ePaper and\nSharp. Supports a range of hosts with low RAM usage.  \n[micro-gui](https://github.com/peterhinch/micropython-micro-gui) Derived from\nnano-gui and supporting the same displays and hosts, this provides for user\ninput via pushbuttons or a navigation joystick.  \n[micropython-touch](https://github.com/peterhinch/micropython-touch/) Similar to\nmicro-gui but uses touch input. Supports multiple displays, hosts and touch\ncontrollers.  \n[LCD160CR](https://github.com/peterhinch/micropython-lcd160cr-gui) Touch GUI\nfor the official display module.  \n[TFT-GUI](https://github.com/peterhinch/micropython-tft-gui) A fast touch GUI\nfor large displays based on SSD1963 controller with XPT2046 touch controller.  \n[RA8875-GUI](https://github.com/peterhinch/micropython_ra8875) Touch GUI for\nlarge displays based on the RA8875 controller (e.g. from Adafruit).  \n\n## 5.7 Pyboard micropower\n\n[micropower](https://github.com/peterhinch/micropython-micropower) Support for\nlow power applications on Pyboard 1.x and Pyboard D.  \n\n## 5.8 Pyboard DSP\n\n[fourier](https://github.com/peterhinch/micropython-fourier) DFT using Arm\nThumb assembler. Primarily for processing data received on an ADC.  \n[Filters](https://github.com/peterhinch/micropython-filters) FIR filters\nusing ARM Thumb assembler. Using an online utility you can go from a graph\nof required frequency response to a filter implementation.  \n\n## 5.9 rshell\n\n[rshell](https://github.com/peterhinch/rshell) is a fork of Dave Hylands'\nexcellent utility. My fork adds text macros to improve its power and\nusability, notably when maintaining complex Python packages. The fork includes\ndocumentation, but [these notes](./RSHELL_MACROS.md) provide a usage example\nwhere each project has its own set of automatically loaded macros.__\n\n## 5.10 Hard to categorise\n\n[data to py](https://github.com/peterhinch/micropython_data_to_py) Convert\narbitrary objects to Python files which may be frozen as bytecode. Can be\nused to freeze images for display.  \n\n##### [Index](./README.md#0-index)\n\n# License\n\nAny code placed here is released under the MIT License (MIT).  \nThe MIT License (MIT)  \nCopyright (c) 2016 Peter Hinch  \nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterhinch%2Fmicropython-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython-samples/lists"}