Posts

Showing posts with the label Micropython

Belay - Interface with hardware from your PC from within a single Python program

Image
Belay lets you write and run Python code on a host like PC and execute pieces of that code down on a connected microcontroller from inside your host Python session.  You write python code and mark up which code will run on the microcontroller (MCU).  The rest of the code runs on the host.  At runtime Belay will transfer the MCU targeted code down to the microcontroller.  The host Python code can then call that downloaded MCU based code as if it were running locally.  MicroPython CircuitPython and host Python Belay runs on Python3 on the host. It can download and interact with MicroPython or CircuitPython runtimes on the microcontroller. Belay GitHub repository Read the Docs: How Belay works MicroPython CircuitPython Code on both the Host and the Microcontroller Belay Python examples on GitHub All the Python code starts on the PC on the left. For this example, everything is in one file like the led flasher above. Both PC and MCU code is in the same Python source ...

Microcontroller - service connections and acquisition patterns

Image
I ended up with some crosscutting content when I wrote up some patterns for getting data onto and off of microcontrollers. The consumption and generation patterns are cross-matched with implementation details.  You may know where you want to send data or in how many directions you want to send data. Now you have other concerns.  Connecting the devices, triggering transfers, and balancing latency with overhead. The next step is to understand how you are going to handle the connectivity and connection initiation.  That depends on the connection types, network topologies, and tools you have.  You then need to figure out how you are going to know when to capture data or receive commands.  Is it time-based or event-based?   Then you need to understand what your payloads look like and balance that against CPU, latency, and other constraints. This was just a subset but should give you the idea. Related Video Moving IOT data onto the controller Moving IOT data...

Patterns for Moving data onto a Microcontroller

Image
Microcontrollers can operate independently in complete isolation. They can operate independently while sharing data with dashboards or other applications.  They can operate under guidance or based on information provided to them by external systems.  They can coordinate operations with other controllers, or remote applications by passing data back and forth.  Let's break this down and talk about moving information onto an IOT from remote systems or other devices. We're talking about information transfers   from  a microcontroller to  other devices, applications, and data sinks.  Transfers can be   self-initiated  or   externally initiated .  Both approaches have their advantages and disadvantages. Video Moving IOT data onto the controller Moving IOT data off the controller Microcontroller - service connections and transfer patterns Related Blog Articles Patterns for Moving data onto a Microcontroller Patterns for Moving data off of...

Patterns for moving data off of a Microcontroller to somewhere else

Image
Microcontrollers can operate independently in complete isolation. They can operate independently while sharing data with dashboards or other applications.  They can operate under guidance or based on information provided to them by external systems.  They can coordinate operations with other controllers, or remote applications by passing data back and forth.  Let's break this down and talk about moving information from an IOT to remote systems or other devices. We're talking about information transfers from a microcontroller  to other devices, applications, and data sinks.  Transfers can be self-initiated  or externally initiated .  Both approaches have their advantages and disadvantages. Video Moving IOT data onto the controller Moving IOT data off the controller Microcontroller - service connections and transfer patterns Related Blog Articles Patterns for Moving data onto a Microcontroller Patterns for Moving data off of a Microcontroller Microcontr...

Inland IIC SPI 1.3" 128x64 OLED V2.0 Graphic Display Module and MicroPython SH1106

Image
The title of this is long to hopefully help people find this when they are thinking of buying this cheap Inland OLED.  I was looking to put a display in the center of my Ikea Dekad clock hack and this OLED was priced right. I've used the Nokia LCD displays in the past but wanted to try something a little brighter with higher contrast.  Microcenter sells an Inland branded OLED module for $7.99 in 2023 dollars.  My biggest gripe with the Inland products is that they have lousy documentation.  This module appears to be made by Keystudio which apparently continues in the Seeed Studio tradition of bare minimum examples and docs.   The device can support either SPI or I2C.  It comes preconfigured for SPI and I can't find instructions anywhere on how to change it.  This means you have to use 4 MCU pins instead of just two. There are apparently two main controllers for this type of OLED. This board uses the SH1106.  There is a great MicroPython drive...

Freemometer V2.1 - Hacking the IKEA DEKAD into a notification device with a Pico and MicroPython

Image
This is V2 of a project I did a few years ago.  The IKEA DEKAD is a pretty package that makes a nice project case and comes with awesome mechanical bells. The Freemometer replaces the clock mechanism with a Servo and adds a couple status LEDs.  A microcontroller is added to run the servo, LEDs, and the motor that drives the alarm bells.  It is really the alarm bells that make the project.   The Pico is a lot more powerful than the Arduino-based first version of this device.  It is powerful enough to write code in Python which I find less stressful for a project like this that is not real-time in nature. This project uses a Pico W which means it can reach out  to some site or socket to get data and then run lights on the servo or the bell.  It also means you can stand up a web server or some other inbound listener that external parties can call.  I tend to Bluetooth into the virtual serial port on the HC-05 so I don't have to enable WebREPL or...

Replicating the MicroPython REPL across an HC-05 HC-06 Bluetooth link

Image
I wanted to run the MicroPython REPL and program code on an RP2040  over Bluetooth so I could avoid wires and still get into the device if there was some kind of Wi-Fi issue.  Read here or  watch the video . Bluetooth supports virtual serial ports in the same way USB devices can. RFCOMM-supporting Bluetooth adapters act as a transparent serial bridge between some RX/TX serial ports and the virtual serial port on a PC, phone, or another device type. Virtual serial ports appear on PCs after a successful pairing.  We can open the Bluetooth RFCOMM virtual serial port to read and write data as if it was serial over USB or a physical port.  We can leave that as a bare serial connection for data/commands or we can enable the MicroPython REPL to do programming, troubleshooting, and data transfer.  The truly awesome RP2040 has two software UARTS in addition to the USB serial connection.  We can connect either of these to serial RX/TX pairs to an RFCOMM-capable...