Skip to content

Raspberry Pi Pico & RP2040 microcontrollers notes

Notifications You must be signed in to change notification settings

WA9ONY/Pico-RP2040

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<-- WA9ONY - YouTube - RPi - Website -->
AI - Arduino - Electronics - GNURadio - Pico-RP2040 - Python - Raspberry-Pi

Pico and RP2040 Projects Notes Index


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 0: Raspberry Pi Pico and RP2040 Microcontrollers Interduction

The Raspberry Pi RP2040 microcontroller IC is a small computer, 0.267 square inches chip,
with 56 pins of which most of the pins are used to interface to other electronic devices.

David Haworth, WA9ONY

Introduction

This repo focuses on microcontroller-based projects and edge computing. These project notes include ML (Machine Learning) and edge computing. It documents WA9ONY learning experinces, resources used and projects. This includes the new (2021) RP2040 microcontroller ecosystem that has shook the microcontroller industry with it's high performace, low cost ($1), small size (0.267 square inches) and availablity to other companies so that they can products that include the RP2040 products (Arduino NANO RP2040 Connect). Microcontrollers would not be complete without understanding how to use the defacto microcontroller standard since 2005, the Arduino microcontroller ecosystem.

The ham radio projects range from a microcontroller board showing its temperature by using its on board LED to indicate the board's temperature in Morse code to a transceivers built with a microcontroller with other hardware. In the below project 1: ham radio microcontroller books browse through the book contente in the table to see the various ham radio microcontroller projects (>150) that have been written about. Also, YouTube and the Internet is filled with ham radio microcontroller projects.

Microcontroller projects range from using only the microcontroller developement board to attaching various components and various subsystem boards with standardized serial interfaces (SPI, I2C, STEMMA QT, etc.).

Software is needed to program the microcontroller. The long time defacto standard is Arduino IDE (since 2005) which is based on C++. Also, MicroPython and CircuitPython have large strong microcontroller ecosystems. This results in different ways to program the microcontroller.

Summary of What is Needed for Microcontroller Project.

  • Microcontroller developement board.
  • Additional electronics and subsystem boards needed for the project.
  • Computer
    • To develope software with the IDE.
    • To upload the software to the microcontroller board usually with USB interface.
    • To power the microcontroller board with the USB interface.
  • Software IDE to develope the microcontroller software.
  • Power the project after software is completed and the computer is not needed.
    • USB power souce
    • Batteries
    • Solar cells


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 1: Ham Radio Micorocontroller Books

The below table identifies books on microcontrollers in ham radio.

Look at the contents column to see the various ham radio microcontroller projects that have been written about in these books. The books are sorted with the newest books at the top of the table.

Summary of the eight books:

  • 130 chapters
  • 2,937 pages
  • 135 projects
    • Here is one project taken from each book.
      • FM radio
      • Simple DDS based CW TX
      • DSP post processor
      • 40 meter QRP JT65 transceiver
      • DDS VFO
      • Talking SWR meter
      • APRS data logger
      • RTTY reader

Review

Ham radio microcontroller books table 1.1.

Book Title

Author

Publisher

Date

Contents

Projects

Pages

uC

Software

Price

Raspberry Pi Pico for Radio Amateurs G7SCU Elektor 2021 PDF 43 310 Color PDF RP2040 Files

€29.95
PDF

Microcontroller Know How Amateur Radio
projects and much more

G0MGX RSGB 2021 PNG 9 175 Color Kindle

Arduino
Blue Pill

Files $21.99 Kindle
More Arduino for Ham Radio KW5GP ARRL 2021 PNG 10 384

Arduino

Files $39.95
Microcontroller Projects for Amateur Radio W8TEE & AC8GY ARRL 2020 PNG 7 400 B&W

Arduino

Files ?

$39.95
More Arduino Projects for Ham Radio KW5GP ARRL 2017 PNG 14 500 B&W

Arduino

Files $34.95
Arduino Projects for Amateur Radio W8TEE, W6DQ, et al. O'Reilly, Mc Graw Hill 2014 PDF 14 464 B&W

Arduino

Files

$25.45
Arduino for Ham Radio KW5GP ARRL 2014 PNG 19 352 B&W

Arduino

Files Out of Print $76.06
Ham Radio for Arduino and Picaxe WA5ZNU ARRL 2013 PNG 19 352 B&W

Arduino

Files $34.95


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 2: Micorocontrollers Books

HackSpace Free Books PDFs

Raspberry Pi

  • Raspberry Pi Pico Python SDK, 48 pages PDF
  • Getting started with Raspberry Pi Pico, 80 pages PDF
  • Raspberry Pi Pico C/C++ SDK, 171 pages PDF
  • Connecting to the Internet with Raspberry Pi Pico W, 30 pages PDF

Elektor Books

Make Books

Best Arduino Books

Amazon Books

Internet Archive

Sign up for a account and you can borrow books.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 3: Micorocontrollers in Magazines

Raspberry Pi Press Free Magazines

Elektor magazine

  • 2022 Dec issue, Arduino (free 40 pages of the 140 page issue)
  • Back issues are available with a Green membership (no print, only PDFs)

Make magazine

  • Volumn 83 contains the 2022 annual Boards Guide (79 boards) on microcontrollers and SBCs.
  • Back issues are available with a digital subscription.
  • Make maganizes are online
    • Register and have access to borrow the issue you want.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 4: Micorocontrollers Videos

Videos on microcontrollers.

  • Exploring the Next Generation of Arduino Microcontrollers (Pico) video - Glen Popiel, KW5GP
  • YouTube
    • Raspberry Pi Pico list
    • ExplainingComputers Pico list
    • Hamshield: Arduino meets amateur radio video

Arduino Channel

Raspberry Pi Channel

Make Magazine Channel

Adafruit Industries Channel


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 5: Forums

Forums related to microcontrollers.

Groups.IO

  • SoftwareControlledHamRadio group
    • This is the support group for the book Microcontroller Projects for Amateur Radio.
    • The files for book Arduino Projects for Amateur Radio are in the group files section.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 6: Micorocontrollers Applications

Two AD9833 Function Generators Boards & Raspberry Pi Pico Microcontroller Board.

Microcontrollers are used to configure and operate ICs and electronic subsystem modules.

Building electronic projects has changed over the years. Today ICs are very samll surface mount packages that are a challenge to work with by themselves. Sometimes the IC can be found mounted on a small circuit board with other components as is shown in the above photo of two AD9833 21 page data sheet PDF 0 MHz to 12.5 MHz Sine Square Wave DDS Signal Generator modules (module front side view & back side view). Three AD9833 modules cost $12.99 with free shipping from Amazon

Therefore, enstead of building a project with ICs it is common to use modules that contain the IC. The modules bacome functional subsystems of the project. For example, the AD9833 module contains seven other componets (25 MHz XTAL, caps & resistors) to make the AD9833 operational and eaiser to use.
Also, in the past ICs had dedicated pins to control their functions. To reduce cost and size those pins were replaced by serial interfaces (I2C, SPI, etc.) The benefits are less pins, lower cost and smaller size. In order to use the AD9833 a serial interface to a microcontroller or microporocessor with a three wire SPI interface is needed to configure and use the AD9833. See the AD9833 Programmable Waveform Generator YouTube video show how to use the AD9833 module with a Arduino microcontroller.

In the above photo, the AD9833 module interface requires Vcc, DigitalGND, AnalogGND, three wire SPI (SDATA SPI serial data, SCLK SPI serial clock, FSYNC SPI frame synchronization) and the function generator output signal is at OUT.

YouTube

Microcontrollers are used to read, process, log and communicate sensor data.

For example, a microcontroller with a temperature sensor can be used as a remote weather station that uses a solar cel power system and Wi-Fi to report temperature to the Internet.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 7: RP2040 Microcontroller Introduction

Rasperry Pi Pico boards area new popular low cost, powerful microcontroller that was created for education, makers, hobbyiest, etc. in January 2021. In less than two years over 2 million have been sold. The RP2040 is the microcontroller IC used in the Pico boards. The RP2040 is sold for $1 and is used by many other companies to create boards that include the RP2040.

The RP2040 is a dual core, 32-bit ARM Cortex M0+ (Wikipedia processor that has very low power requirements. Therefore, it is a good choice for battery operation.

The Raspberry Pi SBC, single board computers, are the third most popular personal computer behind Apple Mac OS, and Window PCs. A SBC runs an operation system to interface to the user and runs various programs. In contrast the RP2040 is a microcontroller design to interface to hardware to do a signal task.

To use a microcontroller it is connected to additional electrical hardware using digital I/O, analog I/O, buses (I2C, SPI, UART, etc.). A compuer is used to develop the software to run one the microcontroller. The software is downloaded from the computer to the microcontroller board where is runs. The software is saved on flash memory on the microcontroller board and runs when the board is power up and not connected to the computer. When problems occur the computer is connected to the microcontroller board to debug it.

Raspberry Pi Foundation helped redefine the personal computer market with the Raspberry Pi low cost single board computer running Linux. In January 2021, Raspberry Pi Foundation entered the microcontroller market with a high performace low cost (1$ single unit) microcontroller RP2040 and its boards. Raspberry Pi Foundation make the RP2040 available to other companies: Adafruit, Sparkfun, Ardinuo, etc. This has caused a explosion of low cost microcontroller boards that include the RP2040.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 9: RP2040 Development Boards Lists

Goal: Identify RP2040 microcontroller development boards that are available.

There is greater than 40 RP2040 microcontroller boards.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 10: Raspberry Pi RP2040 Boards

The board on the bottom is a Pico and the board on the top is a Pico W. Both boards have pins soldered on them.

Raspberry Pi Pico boards

  • Pico $4 has RP2040, clock chip, flash chip and 3.3V regulator chip
  • Pico H $5 adds two 20 pin headers to the Pico.
  • Pico W $6 adds WiFy chip to the Pico
  • Pico WH $7 adds two 20 pin headers to the Pico W.
  • RB2040 $1 is the RP2040 chip.

Wikipedia

Assembly Language on the Raspberry Pi Pico


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 11: Adafruit Industries RP2040s Boards

Adafruit (Wikipedia) is develops and sells open source hardware and is localed in New Your city. Adafruit is an offical distributer of Raspberry Pi products. Therefore, they sell the Raspberry Pi Pico family of products and the Raspberry Pi SBC produccts. Also, Adafruit develops there own RP2040

Above photo left to right:

Some Adafriut product are available on Amazon.

Adafruit STEMMA QT is a easy to use (no soldering) I2C interface with small connectors on sensor boards and some RP2040 boards.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 13: Seeed Studio RP2040 Boards

Some Seeed Studio products are available from Amazon


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 14: SparkFun RP2040 Boards

 

Some SparkFun products are available from Amazon


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 15: Waveshare RP2040 Boards

Some Waveshare products are available from Amazon


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 16: Micorocontrollers Programming

Software


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 18: Build a Computer for Microcontroller Development

  • The computer needs to run these IDEs

    • MicroPython - Thonny IDE
    • CircuitPython - Mu IDE
  • Limitations

    • Arduino Web Editor is not support because the Arduino Create Agent does not run of the Raspberry Pi computers.
    • Arduino V2 has no install for the Raspberry Pi computers.

To use the Pico a computer with a Pico IDE is needed. To use the Pico.

  1. Create a Pico program in the IDE.
  2. Download the program into the Pico.
  3. Run the program.
  4. Debug the program in the IDE.

Use Raspberry Pi P400 computer. Create a new microSD card with latest OS with full install. The full install includes Thonny and Mu.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 19: Setup GitHub

Goals

  • Create GitHub account
  • Create RP2040 and Arduino repo.
  • Use GitHub web interface to create the README.md file.

GitHub is a global home for all developers, GitHub is the complete developer platform to build, scale, and deliver secure software. Over 100 million people, including developers from 90 of the Fortune 100 companies, use GitHub to build amazing things together across 330+ million repositories. With all the collaborative features of GitHub, it’s never been easier for individuals and teams to write faster, better code.

Embedded World 2023 session: DevOps with arm Virtual Hardware enabled GitHub Actions by Clay Nelson

GitHub is a great way to document and share RP2040 and Arduino projects.

  • The GitHub home READ.md file provides a place to documenting the projects.
  • The GitHub provides free file storage (repository) and version change control.
  • GitHub uses a web interface or a Linux CLI interface.
  • The Raspberry Pi P400 full install includes git CLI.

GitHub Repo

Resources


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 20: Learn Micropython on the Pico

Goals

Resources


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 21: Setup Pico with MicroPython

Goal

  • Setup the Pico to run MicoPython with the Raspberry Pi P400 computer.
  • Configure the Pico for MicoPython.
  • Use Thonny to create, edit and debug MicoPython programs to run on the Pico.

Steps

  • Download the MicoPython UF2 file.
  • Hold the Pico Boot switch down when plugging the Pico into the P400.
  • The Pico will mount as a memory device.
  • Drage and drop the MicoPython UF2 file of the Pico memory.
  • The Pico will unmount and be ready to use MicoPython with Thonny with is all ready installed on the P400.

Links


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 22: Run Pico on Batteries

Goal

  • Design a circuit so that the Pico automatically runs on the USB micro connector or a battery input.
  • The Pico automatically switch to the highest voltage.
  • Protect both sources from loading down the other souce.

Design


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 23: Power the Pico on Solar Cells

Goal

  • Use a low cost solar cells that are design for remove cameras that provide upto 5V, 5 Watts.
  • Find a solar cell with a micro USB connector that will plug directly into the Pico microcontroller board.
  • Test the solar cell/battery power configuration.
  • Find a water proof box for the Pico and battery.

Results

  • Plastic 0.30 Caliber Ammo Box
  • The solar cell panel plugs into the Pico micro USB connector.
  • More testing will be done.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 24: Use Pico A/Ds to Measure Vbus, Vsys and Vbattery Voltage

Goal

  • Use the Pico three A/D converters to measure Vbus, Vsys and Vbattery voltage.
  • Design a 50% voltage divider to prevent damage to the A/D inputs that have a maximum of 3.3 Volts.
  • Test how low Vbattery can go before the Pico stops operating.

Implementation:

  • The Raspberry Pi Pico A/D inputs have a maximum voltage rating of 3.3 Volts.
  • The Vbus is the USB voltage which can be upto 5.25 Volts.
  • A voltage divider of two 1 Mohm 1% 1/4 watt resistors are used to reduce the voltage in half.
  • The two 1 Mohm 1% resistors will provide a small load of 2 Mohms to the voltage sources being measured.
  • The software has a single point calibration adjustment to agree with an external DMM reading.
  • The above image is of the six resistors and the Schottky diode (1N5817) for the battery supply portection from the USB 5 Volts.
  • Treedix Compatible with Raspberry PI PICO Expansion Board PCB Shield Board Gold Plated Finish with Pin Header is being used.
  • Two AA batteries are connected to the Vsys through the 1N5817 Schottky diode.

Results

  • Pico will operate down to ~1.9 volts on two AA batteries. This is very impressive.
  • The internal Schottky diode between Vbus and Vsys has a very low volage drop of ~.2 Volts.
  • The 1N5817 Schottky diode voltage drop is ~.4 Volts.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 25: Use Pico A/D to Measure CPU Temperature

Goal

  • Use the A/D converter to measure CPU temperature.
  • Use the A/D converter to measure the Vbus, Vsys and Vbattery voltage.
  • Use the internal real-time clock to time mark the data readings.
  • Save time, Vbus, Vsys, Vbattery and temperature to data log on the Pico flash memory.

Data log is saved to Pico flash memory. Below is the first few lines of the data file that was stored on the Pico flash memory.

Day Time    VBUS  VSYS  VBat  Temp 2022/11/28
28 17:28:11 5.29V 5.16V 1.87V 72.25F
28 17:28:21 5.30V 5.16V 3.55V 72.25F
28 17:28:31 1.04V 3.05V 3.41V 72.25F
28 17:28:41 1.03V 3.06V 3.44V 70.56F
28 17:28:51 1.03V 3.06V 3.44V 70.56F
28 17:29:1  1.02V 3.05V 3.44V 71.41F
28 17:29:11 1.02V 3.06V 3.42V 72.25F
28 17:29:21 1.02V 3.06V 3.42V 72.25F
28 17:29:31 1.02V 3.05V 3.42V 70.56F
28 17:29:41 1.02V 3.07V 3.42V 70.56F
28 17:29:51 1.01V 3.05V 3.42V 70.56F
28 17:30:1  1.00V 3.06V 3.44V 70.56F
28 17:30:11 0.99V 3.07V 3.41V 69.72F
28 17:30:21 0.98V 3.05V 3.41V 69.72F
28 17:30:31 0.98V 3.06V 3.41V 68.88F
28 17:30:41 0.98V 3.04V 3.41V 69.72F
28 17:30:51 0.97V 3.04V 3.41V 68.88F
28 17:31:1  0.96V 3.06V 3.41V 68.88F
28 17:31:11 0.96V 3.04V 3.41V 68.04F
28 17:31:21 0.95V 3.05V 3.41V 68.04F


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 27: Using the GiHub Web Interface

The free GitHub account supports two types of interfaces.

  • GitHub web interface operated with a web browser.
  • GitHub to git interface. On a Linux computer git is a CLI command.

The GitHub has a web inferface to

  • Create the repo README.md file, this file you are reading.
  • Create, edit & delete files in the repo.
  • Upload and delete files in the repo.
  • Create folders in the repo.

The GitHuib web interface changes to the repo all require a Commit Changes to take effect.

On the repo home page is a README.md file that is shown to the user when the repo is shown in a browser. The README.md explains the purpose and how to use the repao.

README.md file

  • README.md file formating syntax
    • Basic writing and formatting syntax
    • GitHub Flavored Markdown Spec
    • markdown-it demo
  • My README.md file is supported by two folders:
    • BookContents contains PDFs and PNGs of the eight books related to ham radio.
    • Images contains images used in the README.md file.
  • Some HTML code works in the .md file.
  • To create a folder a new file is created in the new folder at the same time.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 34: Steps in Building a Microcontroller Project

The following steps are used to create a microcontroller project.

  • Project concept
  • Determine the project requirements.
  • Select the microcontroller.
  • Mount the microcontroller on a breadboard.
  • Wire up other components to the microcontroller.
  • Create and debug software on computer attached to the microcontroller USB interface.
  • Replace breadboard with PCB
  • Find a case for the project.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 35: Electronic Breadboards

Electronic breadboard is used in the early stages of prototyping the project. The breadboard alows wires, ICs, small PCSs with pins, etc. to be connected electrically without soldering. Electronic breadboard available in different sizes and configurations. For microcontroller projects the breadboard needs to be compatible with the microcontroller developement board with male header pins attached to it.

Breadboard are a plastic body holding strips of metal strips that grab the wires insterted into the breadboards.

On Amazon

For more information


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 36: PCBs

PCBs (Printed circuit board) are are used to transfer the microcontroller project from the quick breadboard to a perminet implementation.

PCBs are available in may sizes and configurations. I look for PCB configrations that work well with the microcontroller developemnt board.

On Amazon

For more information


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 42: USB

The USB interface is a commaon way to connect the computer with the IDE to the microcontroller development board. Below are several ways to check that the microcontorller board USB interface is connected to the computer.

Arduino Web Editor

The above image of Arduino Web Editor shows Arduino MKR WiFi 1010 connected to Linux USB interface /dev/ttyACM0

Arduino Create Agent

Arduino Create Agent, Open Debug Console "list" command

  • VendorID: 0x2341 is Arduino LLC
  • ProductID: 0x8054 is Arduino MKR WiFi 1010
list

Serial Ports:
[
  {
    "Name": "/dev/ttyACM0",
    "SerialNumber": "1EFE803450553133352E3120FF012734",
    "IsOpen": true,
    "VendorID": "0x2341",
    "ProductID": "0x8054"
  }

Linux CLI "lsusb" command

david@wa9ony-nuc8i7hvk:~$ lsusb
Bus 001 Device 043: ID 2341:8054 Arduino SA Arduino MKR WiFi 1010  

Linux CLI "sudo dmesg" command

david@wa9ony-nuc8i7hvk:~$ sudo dmesg 
[1475146.372531] cdc_acm 1-11.2:1.0: ttyACM0: USB ACM device
[1475150.341574] usb 1-11.2: USB disconnect, device number 41
[1475151.105206] usb 1-11.2: new full-speed USB device number 42 using xhci_hcd
[1475151.245207] usb 1-11.2: New USB device found, idVendor=2341, idProduct=8054, bcdDevice= 1.00
[1475151.245212] usb 1-11.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1475151.245214] usb 1-11.2: Product: Arduino MKR WiFi 1010
[1475151.245216] usb 1-11.2: Manufacturer: Arduino LLC
[1475151.245217] usb 1-11.2: SerialNumber: 1EFE803450553133352E3120FF012734


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 47: AC Power Suppies for Microcontroller Boards

There are multiple ways to power a microcomputer board.

  • USB
  • 120 Volts AC to DC Volts power supply
  • Battery
  • Solar cells

Different microcontroller boards accept different DC voltages.

For example,

  • Arduino MEGA 2560 2.1mm center-positive plug accepts 7 to 12 volts.
    • The above image shows an used 7.5 Vdc power suppy from Goodwill that is perfect for the MEAG 2560.
    • A higher voltage results in higher temperature for the on microcontroller board voltage regulator.
    • Therefore, using a 7.5 Volts power supply is better than using a 12 Volts power supply.
  • Raspberry Pi Pico square pins Vsys accepts 1.8 to 5.5 volts.
    • The above 7.5 power supply would damage the Pico.

A good soure of used low cost 120 Volts AC to DC Volts wall wart power supplies is Goodwill. Goodwill price tags have a color and one color is 50% off for a week. The discount color changes every Sunday.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 50: WA7ABU Repeater Project Net

The weekly Project Net covers many topics including microcontroller projects.

Anateur radio operators on the net with microcontroller projects.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 52: Microcontroller Development Boards Price Table

Prices are as of January 10, 2023

Model

Manufacturer

Store

Price

Notes

Pico Raspberry Pi Adafruit $4.00
</TD>
Pico H Raspberry Pi Adafruit $5.00 Best lowest cost uC to start with.
Pico W Raspberry Pi Adafruit $6.00
</TD>
Pico WH Raspberry Pi Adafruit $7.00
</TD>
UNO R3 Arduino Arduino $27.60 Very old uC with the largest ecosystem. Over 10 million sold.
MEGA 2560 Rev3 Arduino Arduino $48.40
</TD>


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 53: Starting with Microcontrollers

How to start with microcontroller depends upon the person's background and experineces.

Beginner

  • No electronics experiences
  • No programming experiences
  • No soldering tools and no soldering skills.

Goal

  • Low cost
  • Easy to learn
  • Lots of tutorials

Assumptions

  • A person has a compute that can run IDE.
    • Free Thonny with MicroPython

Free Microcontroller training materials

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages free PDF

Low cost Microcontroller hardware

  • Raspberry Pi Pico H $5.00
  • micro USB cable from Dollar Tree for $1.25.

Kits


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 60: Fritzing

Fritzing Features

  • Prototype documentation
    • Library include Arduino and other microcontorller boards.
    • Various breadboards are available to use.
    • Online parts to expand Fritzing library.
      • My focus of using Fritzing is to document my prototypes to share them with others.
  • Schematic capture
  • Circuit simulation
  • Circuit board design
  • Order circuit board

Schematic

The above image is the schematic of the prototype documentation at the top of this project section.

Circuit Simulation

The above image shows the LED burning out because of too much current. The LED current limiting resistor is too low at 10 Ohms.

Adding Parts to the Library

The above image shows the Raspberry Pi Pico W part that was added to the Fritzing parts library.

Steps to add Raspberry Pi Pico and Pico W to the Parts library.

  • Download parts
    • Pico-R3-Fritzing.fzpz
    • PicoW-Fritzing.fzpz
  • In Fritzing Parts, upper right corner, Import... these two files.
  • Both part show up in Mine section of Parts.

Fritzing Videos

Fritzing Install on Ubuntu

  • Price ~$9 to Paypal
  • Installed on Ubuntu 22.04 LTS.
    • Create directory: /Home/appimages
    • Add libraries: sudo apt install libfuse2
    • Download Fritzing-20221215T224353Z-001.zip into /Home/appimages
    • If necessary extract the zip file. There is only one file in the zip file.
    • Change fritzing-0.9.10-l2134-40d23c29.AppImage permissions to execute
    • Double click on fritzing-0.9.10-l2134-40d23c29.AppImage to start Fritzing.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 63: I²C-bus: Inter-Integrated Circuit Bus

Above image credit: AN10216-01, 51 pages

I²C-bus is a two wire (SDA & SCL) serial communication bus for a controller and a target to communicate with each other. Most microcontroller support the I²C-bus and a wide varity of senors use the I²C-bus. For example, there can be over ten sesnors in a cell phone use the I²C-bus.

I²C-bus is a serial half-duplex protocl using two open collector/open drain wires for data and clock.

Seven bit address is the most common, there is a specification for 10-bit addressing with is not commonly used.

Controller (master) controls the bus, target (slave or peripheral) waits for the controller.

I²C-bus speed history

  • 1982: 100 kHz, I²C-bus can go slower.
  • 1992: 400 kHz, High Speed mode
  • 2007: 1 MHz Fm+, Fast-mode Plus, fastest speed for bidirectional
  • 3.4 MHz
  • 2012: 5 MHz UFm, Ultra Fast-mode

Book

I²C-bus Specification PDFs

NXP

Analog Devices

  • I²C Primer: What is I²C? (Part 1)
  • I²C Timing: Definition and Specification Guide (Part 2)

Texas Instruments

Reference URLs

Videos

Tutorials

Digi-Key

Hackaday

I²C Product Lists

In 1998 the I²C-bus specification reported "The I2C-bus has become a de facto world standard that is now implemented in over 1000 different ICs and licensed to more than 50 companies."

  • Amazon I²C list
  • Adafruit I²C-bus list
  • Adafruit I²C-bus Address list
  • Sparkfun I²C-bus list
  • Seeed Studio I²C-bus address list
  • I²C-bus Device list


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 64: SPI: Serial Peripheral Interface

SPI is a serial communication bus for short distances on a circuit board. Most microcontroller support the SPI bus.

Tutorials

Reference

Videos


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 65: OLED: Organic Light-Emitting Diode

OLEDs are a common way to display information from the microcontroller

Tutorials

Reference

Videos


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 66: I²C-bus: Sparkfun Qwiic

Sparkfun Qwiic is a small I2C 4-pin JST connector, 1mm pitch: 3.3 V power, ground, I2C data and I2C clock.

The above image is a Qwiic connection on an OLED display. No soldering Qwiic cable between the Sparkfun SerLCD Qwiic connector to the Raspberry Pi Pico breadboard with the Qwiic cable pins.

Sparkfun Qwiic benfits

  • Small
  • I2C supports multiple devices with different I2C address.
  • Provides 3.3 V power and ground.
  • Easy to connect I2C devices with no soldering.
  • Qwiic cable kits.
  • I2C address: 0x72 or 114 decimal
  • Input voltage: 3.3V-9V (3.3V only via Qwiic connector and "+" pin)

Tutorials

  • SparkFun (OVERVIEW | PRODUCTS | FAQS | RESOURCES ) Qwiic

Videos

Sparkfun Qwiic product list

SparkFun Qwiic Cable Kit

Sparkfun QWIIC cable color pinout

  • Red: 3.3 Vdc
  • Black: ground
  • Blue: serial data - SDA
  • Yellow: serial clock - SCK

Qwiic cable connection to Raspberry Pi Pico microcontroller development board.

  • Pin 36 3V3(OUT) - Red: 3.3 Vdc
  • Pin 38 GND - Black: ground
  • Pin 1 I2C0 SDA - Blue: serial data - SDA
  • Pin 2 I2C0 SCL - Yellow: serial clock - SCK

Image credit

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 67: SparkFun 16x2 SerLCD - RGB Text (Qwiic)

No soldering Qwiic cable between the Sparkfun SerLCD Qwiic connector to the Raspberry Pi Pico breadboard with the Qwiic cable pins.

Sparkfun SerLCD features

  • Support multiple inferfaces: I2C, Qwiic connector, SPI & serial UART.
  • Has a ATmega328P AVR microcontroller
  • Black Liquid Crystal Display
  • Blacklight version available
  • 3.3V device which works well wtih the 3.3V Raspberry Pi Pico.

Sparkfun

Raspberry Pi Pico progarmming the SerLCD

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI
      • Sparkfun SerLCD I2C and SPI code examples

The special pipe character '|' (also called the 'or' character) is used to tell the screen to enter "settings mode". You then follow this command with another special character (usually "ctrl+c", ctrl+d, etc.). Table

SerLCD commands from SerLCD.h

//OpenLCD command characters
#define SPECIAL_COMMAND 254  //Magic number for sending a special command
#define SETTING_COMMAND 0x7C //124, |, the pipe character: The command to change settings: baud, lines, width, backlight, splash, etc

//OpenLCD commands
#define CLEAR_COMMAND 0x2D					//45, -, the dash character: command to clear and home the display
#define CONTRAST_COMMAND 0x18				//Command to change the contrast setting
#define ADDRESS_COMMAND 0x19				//Command to change the i2c address
#define SET_RGB_COMMAND 0x2B				//43, +, the plus character: command to set backlight RGB value
#define ENABLE_SYSTEM_MESSAGE_DISPLAY 0x2E  //46, ., command to enable system messages being displayed
#define DISABLE_SYSTEM_MESSAGE_DISPLAY 0x2F //47, /, command to disable system messages being displayed
#define ENABLE_SPLASH_DISPLAY 0x30			//48, 0, command to enable splash screen at power on
#define DISABLE_SPLASH_DISPLAY 0x31			//49, 1, command to disable splash screen at power on
#define SAVE_CURRENT_DISPLAY_AS_SPLASH 0x0A //10, Ctrl+j, command to save current text on display as splash

// special commands
#define LCD_RETURNHOME 0x02
#define LCD_ENTRYMODESET 0x04
#define LCD_DISPLAYCONTROL 0x08
#define LCD_CURSORSHIFT 0x10
#define LCD_SETDDRAMADDR 0x80

// flags for display entry mode
#define LCD_ENTRYRIGHT 0x00
#define LCD_ENTRYLEFT 0x02
#define LCD_ENTRYSHIFTINCREMENT 0x01
#define LCD_ENTRYSHIFTDECREMENT 0x00

// flags for display on/off control
#define LCD_DISPLAYON 0x04
#define LCD_DISPLAYOFF 0x00
#define LCD_CURSORON 0x02
#define LCD_CURSOROFF 0x00
#define LCD_BLINKON 0x01
#define LCD_BLINKOFF 0x00

// flags for display/cursor shift
#define LCD_DISPLAYMOVE 0x08
#define LCD_CURSORMOVE 0x00
#define LCD_MOVERIGHT 0x04
#define LCD_MOVELEFT 0x00
   


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 68: Raspberry Pi Pico I²C Scan

The above image shows the Raspberry Pi Pico scanning I²C addresses and finding a I²C device at 114 decimal (x72 hex).
The I²C device is the Sparkfun SerLCD. No soldering Qwiic cable between the Sparkfun SerLCD Qwiic connector to the Raspberry Pi Pico breadboard with the Qwiic cable pins.

MicroPython program

import machine
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
print(i2c.scan())     

Program credit

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI
      • I2C scan code examples


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 69: Raspberry Pi Pic to SparkFun 16x2 SerLCD Qwiic "hello"

Qwiic would not run at speeds greater or equal to 300 kHz.
I2C at 200 kHz is working.
No soldering Qwiic cable between the Sparkfun SerLCD Qwiic connector to the Raspberry Pi Pico breadboard with the Qwiic cable pins.

MicroPython program

import machine
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=200000)
i2c.writeto(114, '\x7C')
i2c.writeto(114, '\x2D')
i2c.writeto(114, "hello world     I2C 200kHz")    
    

Notes

  • "/n" does not work to advance to the second textt line.

Program credit

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI
      • I2C hello world code examples


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 70: Raspberry Pi Pic to SparkFun 16x2 SerLCD Qwiic "temp"

Qwiic would not run at speeds greater or equal to 300 kHz.
I2C at 200 kHz is working.
No soldering Qwiic cable between the Sparkfun SerLCD Qwiic connector to the Raspberry Pi Pico breadboard with the Qwiic cable pins.

MicroPython program

import machine
import utime
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=200000)
adc = machine.ADC(4)
conversion_factor = 3.3 / (65535)
while True:
 reading = adc.read_u16() * conversion_factor
 temperature = 25 - (reading - 0.706)/0.001721
 i2c.writeto(114, '\x7C')
 i2c.writeto(114, '\x2D')
 out_string = "Temp: " + str(temperature)
 i2c.writeto(114, out_string)
 utime.sleep(2)    
    

Program credit

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI
      • I2C temperature code examples


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 71: Raspberry Pi Pic to SparkFun 16x2 SerLCD 96 Char Test

Above images are the 96 prinable ASCII characters 32 to 127.
The following four ASCII characters are missing: , |, }, ~

MicroPython program

import machine
import utime
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=100000)
i2c.writeto(114, '\x7C')
i2c.writeto(114, '\x2D')

for i in range( 32, 128) :
    c = chr(i)
    i2c.writeto(114, c)
    utime.sleep(1)
    

Program credit

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI
      • I2C code examples


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 72: Raspberry Pi Pic I²C MicroPython

The above image shows a Raspberry Pi Pico MicroPython I²C program scanning the I²C bus for I²C devices. A I²C device was found at I²C address 114. The IDE is Thonny on a Raspberry Pi 400.

Image credit

  • Get Started with MicroPython on Raspberry Pi Pico, 139 pages PDF
    • Chapter 10 Digital communication protocols: I2C and SPI

The Raspberry Pi Pico has two I²C controllers (0 & 1) which can be assigned to various pairs of pins. The I²C controller used is 0 on pins 1 and 2 (GP0 & GP1).

MicroPython Raspberry Pi Pico functions

I²C MicroPython Hello World

import machine
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=200000)
i2c.writeto(114, '\x7C')
i2c.writeto(114, '\x2D')
i2c.writeto(114, "hello world     I2C 200kHz")
      

I2C MicroPython Temp

import machine
import utime
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0,sda=sda, scl=scl, freq=200000)
adc = machine.ADC(4)
conversion_factor = 3.3 / (65535)
while True:
 reading = adc.read_u16() * conversion_factor
 temperature = 25 - (reading - 0.706)/0.001721
 i2c.writeto(114, '\x7C')
 i2c.writeto(114, '\x2D')
 out_string = "Temp: " + str(temperature)
 i2c.writeto(114, out_string)
 utime.sleep(2)
      

I²C MicroPython Error

The below error message occured when useing I2C frequency of 200000 or greater. I use I2C frequency of 100000.

Traceback (most recent call last):
  File "", line 12, in 
OSError: [Errno 5] EIO
      

Videos

  • Raspberry Pi PICO | Starting With MicroPython + Examples | I2C OLED, ADC, PWM video


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 73: I²C-bus: Adafruit STEMMA & STEMMA QT

STEMMA QT is an easy way to connect micorcontroller development boards to sensor boards, IC boards, motor controller boards, and all kinds of boards without soldering. STEMMA QT can be connected in a dasiy chain with some STEMMA QT boards with two STEMMA QT commectors.
STEMMA QT is a very small 4 pin connector that is popular for I2C communications plus power and ground.

Adafruit STEMMA QT is compatible with the Sparkfun Qwiic I2C connector. Adafruit STEMMA QT is compatible with the Seeed Grove via simple adapter.

Adafruit STEMMA & STEMMA QT products list

Video

  • What is Stemma QT? YouTube short
  • Adafruit STEMMA & STEMMA QT Plug & play connectivity - STEMMA SUNDAY! video
  • Raspberry Pi School - Using STEMMA QT on a Raspberry Pi video

STEMMA QT logo


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 74: I²C Waveforms

In the above image is

  • At the top center is a Tektrinix TDS 784C Oscilloscope to measure the I²C SDA and SCL waveforms.
    • Below the the TDS 784C is a HDMI display showing the TDS 784C display.
  • To the right is a Raspberry Pi P 400 IDE runining Thonny with MicroPython.
  • Lower center on the white bread board is the Raspberry Pi Pico connected to Sparkfun SerLED 16 x 2 disply with Qwiic cable.

Sparkfun QWIIC cable connects the Sparkfun SerLED to the Raspberry Pi Pico. The Qwiix color pinout is

  • Red: 3.3 Vdc to Pico 3V3(out) pin 36
  • Black: ground to Pico GND pin 38
  • Blue: serial data - SDA to Pico I2C0 SDA pin 1, oscilloscope channel 2 green waveform
  • Yellow: serial clock - SCK to Pico I2C0 SCL pin 2, oscilloscope channel 3 yellow waveform

I²C-bus No Activity, Pico & SerLED

  • Both the Raspberry Pi Pico development board and the Sparkfun SerLED are 3.3 V devices.
    • Therefore, the two I2C lines SDA and SCL have pull up resistors to ~3.3 V.
  • Oscilloscope channel 2 (top green trace) is attached to the I²C SDA line.
    • The oscilloscope measures SDA high to be 3.28 V which is close to the 3.3 V.
  • Oscilloscope channel 3 (middel yellow trace) is attached to the I²C SCL line.
    • The oscilloscope measures SCL high to be 3.16 V which is close to the 3.3 V.

I²C-bus Pico controller sending Address 114, write & SerLED slave Nack

The above screen shot shows the Raspberry Pi Pico I2C controller is requesting to write to the Sparkfun SerLED I²C slave at address 114. The Sparkfun SerLED responded with a not acknowledge. If the Sparkfun SerLED I²C slave did not understand the request an automatic not acknowledge is the default response if the slave does nothing.

  • Both the Raspberry Pi Pico development board and the Sparkfun SerLED are 3.3 V devices. Therefore, the two I2C lines SDA and SCL have pull up resistors to ~3.3 V.
  • Oscilloscope channel 2 (green) is attached to the I²C SDA line.
  • Oscilloscope channel 3 (yellow) is attached to the I²C SCL line.
    I²C start is when the SDA goes low when the SCL is high. The oscilloscope first cursor is position at the first vertical division.
  • This I²C packet is composed of nine SCL pulses. SDA changes when SCL is low. SDA is stable and is read when SCL is high.
  • The first seven SCL are for the seven bit I2C address (0 to 127).
  • Sparkfun I²C address is 114, x32, b1110010. MSB (most significant bit) is sent first.
  • The eight SCL after the I²C address is the read/write bit.
  • The ninth SCL bit is for the Sparkfun SerLED to acknowledge the I²C master Raspberry Pi Pico controller. Nak (not acknowledge) is when the SDA is high as shown in the above the screen shot.
  • The end of the I²C packet is at 6.5 division, cursor #2. The end is when the SDA rises when SCL is high.

I²C-bus Pico controller sending Address 114, write & SerLED slave Ack

  • The oscilloscope two vertical cursors (vertical solid and dash lines) bracket the eight data clock pulses and the ninth nack/ack clock pulse.
  • Data is valid when clock is high.
  • Nack/ack is valid when clock is high.
  • Ack is held low by the SerLED indicating it is ready for data from the Pico controller.

I²C-bus Pico Controller Writing x7C hex (b01111100) data to the SerLED slave with Ack

  • The oscilloscope two vertical cursors (vertical solid and dash lines) bracket the eight data clock pulses and the ninth nack/ack clock pulse.
  • Data is valid when clock is high.
  • Nack/ack is valid when ninth clock bit is high. Ack is a low.
  • Ack is held low by the SerLED indicating it received the x7C hex data from the Pico controller.

I²C-bus Pico controller sending Address 114, write & SerLED slave Ack

  • The oscilloscope two vertical cursors (vertical solid and dash lines) bracket the eight data clock pulses and the ninth nack/ack clock pulse.
  • Data is valid when clock is high.
  • Nack/ack is valid when ninth clock bit is high. Ack is a low.

I²C-bus Pico Controller Writing x2D hex (b00101101) data to the SerLED slave with Ack

  • The oscilloscope two vertical cursors (vertical solid and dash lines) bracket the eight data clock pulses and the ninth nack/ack clock pulse.
  • Data is valid when clock is high.
  • Nack/ack is valid when ninth clock bit is high. Ack is a low.
  • Ack is held low by the SerLED indicating it received the x2D hex data from the Pico controller


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 75: Tennsy 4.1 Microcontroller Board

The Teensy® 4.1 microcontroller development board is a high performance small microcontroller.

PJRCD

Other store

Videos

Applications

  • Auto-Return Parachute Comes Back To The Launch Site Every Time URL

URLs

MicroPython functions for the Tennsy 4.1.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 76: I²C-bus: 7-bit Address Table


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 77: Microcontroller Boards Table

Table contains 28 microcontroller boards.

Table notes

  • Mfg: 9 microcontroll development board manufacturer
    • Adafruit, Aideepen, Arduino, Elegoo, Lafvin, PJRCD, Raspberry Pi, Seeed Studio & Waveshare
  • MCU: microcontroller model
  • MCU bus:
    • 8-bits or 32-bits (better)
  • MCU MHz:
    • 16 MHz to 600 MHz (better)
  • SRAM: Static Random Access Memory, memory contents is lost when not power, program run time memory: stacks, variables, arrays, etc.
    • 2KB to 8MB (better)
  • Flash memory: memory containing the program, memory contents is retained with no power, program memory for C object code, Python, assembly code, etc.
    • 2 KB to 8 MB (better)
  • EEPROM: Electrically Erasable Programmable Read-Only Memory, memory contents is retained with no power, non volatile program data memory: program constants, data tables, images, etc.
    • None to 4 KB (better)
  • IDE: Integrated Development Environment: Work station to develop microcontroller software
    • Arduino, CircuitPython, MicroPython & C/C++
  • Price
    • $ 2.99 (better) to $ 120.00
  • Notes:
    • FPU - Floating Point Unit
    • USB interface: A, micro, C & A Plug

Mfg

Model

MCU

MCU bus

MCU MHz

SRAM

Flash Memory

EEPROM

IDE

Price

Notes

PJRCD Tennsy 4.1 ARM Cortex-M7 32 600 1024K 7936K 4K Arduino, CircuitPython, etc. $31.50 FPU, Good high performance/price
Raspberry Pi Pico W Dual ARM Cortex-M0+, RP2040 32 133 264K 2MB None MicroPython, C++, Arduino $6.00 Wifi, great performance/price, good ecosystem
Raspberry Pi Pico Dual ARM Cortex-M0+, RP2040 32 133 264K 2MB None MicroPython, C++, Arduino $4.00 Low price, Best performance/price, good ecosystem
Adafruit Feather RP2040 Dual ARM Cortex-M0+, RP2040 32 125 264K 8MB None CircuitPython, MicroPython, C++, Arduino $11.95 STEMMA QT
Adafruit ItsyBitsy RP2040 Dual ARM Cortex-M0+, RP2040 32 125 264K 8MB None CircuitPython, MicroPython, C++ $9.95
Adafruit QT Py RP2040 Dual ARM Cortex-M0+, RP2040 32 125 264K 8MB None CircuitPython, MicroPython, C++, Arduino $9.95 STEMMA QT, small
Adafruit Trinkey QT2040 Dual ARM Cortex-M0+, RP2040 32 ~125 264K 8MB None CircuitPython, MicroPython, C++ $7.95 STEMMA QT, USB A Plug
Adafruit KB2040 Dual ARM Cortex-M0+, RP2040 32 ~125 264K 8MB None CircuitPython, MicroPython, C++, $8.95 STEMMA QT
Seeed Studio XIAO RP2040 Dual ARM Cortex-M0+, RP2040 32 133 264K 2MB None CircuitPython, MicroPython, C++, $5.40 XIAO series
Waveshare RP2040-Zero Dual ARM Cortex-M0+, RP2040 32 133 264K 2MB None MicroPython, C++ $4.49 Small, USB-C
Waveshare RP2040-One Dual ARM Cortex-M0+, RP2040 32 133 264K 4MB None MicroPython, C++ $4.49 Small, USB-A Plug
Waveshare RP2040-Plus Dual ARM Cortex-M0+, RP2040 32 133 264K 4MB/16MB None MicroPython, C++ $8.89 USB-C, higher current DC-DC chip, Lithium battery recharging
Waveshare RP2040-LCD-0.96 Dual ARM Cortex-M0+, RP2040 32 133 264K 2MB None MicroPython, C++ $11.99 0.96" 160×80 pixels IPS display, USB-C, higher current DC-DC chip, Lithium battery recharging
Arduino Portenta H7 Dual-core STM32H747 32 Cortex® M7 at 480, Cortex® M4 at 240 8MB 16MB None Arduino, MicroPython, JavaScript $120.00 Wifi
Arduino Nano RP2040 Connect Dual ARM Cortex-M0+, RP2040 & Nina W102 uBlox module 32 133 264K 16MB None Arduino $30.60 Wifi, Max RP2040 Flash, good ecosystem
Arduino NANO 33 BLE nRF52840 (ARM® Cortex®-M4) 32 64 256K 1MB None Arduino $26.30 Bluetooth, 9 axis inertial sensor
Arduino MKR1010 WiFi SAMD21 (Cortex®-M0+) 32 48 32 KB 256K None Arduino $38.60 WiFi
Arduino MKR1000 WiFi ATSAMD21 (Cortex®-M0+) 32 48 256K 32KB None Arduino $44.00 WiFi
Arduino Nano 3.x ATmega328 8 16 2K 32KB 1 KB Arduino $24.90
Arduino Micro ATmega32U4 8 16 2.5K 32KB 1 KB Arduino $24.90  
Arduino Mega 2560 Rev3 ATmega2560 8 16 8K 256KB 4 KB Arduino $48.40 Second most popular, good ecosystem
Arduino UNO WiFi REV2 ATmega4809 8 16 6,144 48 KB 256 Arduino $53.80 WiFi
Arduino UNO Rev3 SMD ATmega328P 8 20 2K 32KB 1 KB Arduino $26.30 Most popular, > 10 M sold, best ecosystem, SMD MCU
Arduino UNO R3 ATmega328P 8 20 2K 32KB 1 KB Arduino $27.60 Most popular, > 10 M sold, best ecosystem
Elegoo Mega 2560 Rev3 ATmega2560 8 16 8K 256KB 4 KB Arduino $15.99 Clone
Elegoo UNO R3 ATmega328P 8 20 2K 32KB 1 KB Arduino $12.98 Low cost UNO R3 clone with STEM kits
Lafvin Nano 3.0 ATmega328 8 16 2K 32KB 1 KB Arduino 3 at $10.50 Clone
Aideepen Nano 3.0 ATmega328 8 16 2K 32KB 1 KB Arduino $2.99 Clone


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 78: KiCad Circuit Simulation

KiCad is installed on Linux computer, NUC8i7HVK Ubuntu 22.04.1 LTS.

My focus is to use KiCAD for electronic circuit simulation. KiCAD functions also include PCB laytout.

KiCad version

  • Version: 6.0.10-86aedd382b118ubuntu22.04.1, release build

Videos

  • YouTube KiCad 6 video
  • KiCad 5.0 Changes and New Features video

Books

  • Amazon KiCad 6 list

Groups.io

Above is the RP2040 in KiCAD.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 79: Adafruit 2FA: Two-Factor Authentication

Google Authenticator app on the iPad.

Adafruit has implemented 2FA for some items. After logging into Adafruit 2FA will request a six digits code that is generated by the Google Authenticator app.

The Google Authenticator 2FA code change every ~15 seconds. A timer icon on the above scree shot right side gets smaller as it times out.

If you fail to log in to the 2FA, you cannot login to Adafruit.

Some Adafruit items are available on Amazon.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 80: Qucs: Quite Universal Circuit Simulator

Qucs v 0.0.19 running on NUC8i7HVK Ubuntu 22.04.1 LTS.

Videos

Circuit Simulation Software


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 81: I²C-bus: Seeed Studio Grove System

Seeed Studio Grove system is a four wire connector system with four different interfaces (I2C, digital, analog & UART) to make it easier to connect microcontroller boards to various devices (displays, sesnors, A/D, D/A, etc.). The Grove system was launched in 2010.

Seeed Studio Grove System

Video

Four types of Grove interfaces

  • Grove I2C
  • Grove Digital
  • Grove Analog
  • Grove UART

Grove I²C connector & cable colors

  • Pin 1: I²C-bus SCL, yellow
  • Pin 2: I²C-bus SDA, white
  • Pin 3: Vcc 5V/3.3V, red
  • Pin 4: GND, black


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 82: MicroPython Pico Functions

MicroPython is on of the Raspberry Pi support programming languages for the Pico. The free Get Started with MicroPython on Raspberry Pi Pico 139 pages PDF uses MicroPython.

MicroPython Quick reference for the RP2

MicroPython Pico modules

Books

  • Amazon Raspberry Pi Pico MicroPython in books lsit


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 83: Book: Programming the Pico, Dr.Simon Monk

I enjoy Dr.Simon Monk writting style and I seek out his books.

Programming the Pico

  • MicroPython and IDE Thonny
  • 2022
  • 146 pages
  • 12 chapters
  • Photo are black and white.
  • Contents see Amazon lock inside
  • Book errors
  • Pico book kit

Programming the Pico: Learn Coding and Electronics with the Raspberry Pi Pico Amazon


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 84: I²C-bus: SparkFun Qwiic MultiPort

Qwiic MultiPort is a good way to connect additional I²C-bus devices to the microcontroller.

I²C-bus: Inter-Integrated Circuit Bus is a two wire open collector/drain bus: SDA data and SCL clock.

SparkFun Qwiic MultiPort

Qwiic is a four wire connector system with I²C-bus SDA & SCL and 3.3 V power & GND.

In the top photos the twisted cable is a SparkFun Qwiic cable and the flat cable on the other side of the MultiPort is Adafruit STEMM QT cable. STEMM QT cable works on Qwiic but STEMM QT may have 5V or 3.3V on the Vcc wire. 5V is not compatible with Qwiic. Qwiic is only 3.3V. Therefore, you can mix and match 3.3 V STEMM QT devices with 3.3 v Qwiic devices.

  • Qwiic cable wires are small and have a max current of about 226mA
  • Maximum I²C-bus capacitance is 400 pf.
  • the faster the I²C-bus clock frequency, The lower the pull up resistance.
  • I²C-bus pull up resistors range 1K to 4.7 K.
  • I²C-bus at the Hardware Level

Video

  • SparkFun Qwiic video
  • Adafruit STEMMA & STEMMA QT Plug & play connectivity - STEMMA SUNDAY! video
  • Product Showcase: SparkFun Qwiic MultiStar MultiPort

URLs


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 85: Tinkercad Circuits

Tinkercad Circuits community gallery.

What is great + Anduino microcontrollers is in the library.

Limitations + No transform in the library. + No AC power sources.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 86: Tinkercad Codeblocks

Tinkercad Codeblocks community gallery.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 87: Tinkercad 3D Design

Tinkercad 3D Design community gallery.

Tinkercad main function is 3D Design for [3D printing(https://en.wikipedia.org/wiki/3D_printing)


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 102: List of YouTube Playlists

This a list of playlist and over one hour videos.

Raspberry Pi Pico playlists

MicroPython playlists

CircuitPython playlists


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 137: Thonny

Thonny is an IDE for

Thonny on Ubuntu 20.04.2 LTS

Use the standard Ubuntu software to install Thonney.

  • Open show applications
  • Open Ubuntu Software
  • Search for Thonny
  • Select Thonny-IDE and install
  • The above screenshot shows Thony version and Python version.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 138: CircuitPython


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 139: Groups.IO Microcontrollers

Microcontrollers at Groups.IO: Pico, Arduino, RP2040, ESP32, STM32, Atmega328P, UNO, Feather, etc.

This group is where you can share you experiences with using microcontrollers in your projects. Examples of microcontrollers include Raspberry Pi Pico, Arduino family of microcontrollers and any other microcontrollers that you are using.

Microcontrollers are tiny computers that run a single program usually without an operating system software to control various electrical and mechanical devices.

A hot area today is using microcontrollers in IoT (Internet of Things) devices.

Group owner David Haworth WA9ONY


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 140: Discord

Discord is a VoIP and instant messaging social platform that is used by the ecosystems of Adafruit, Arduino, etc.

Discord on Wikipedia

YouTube

There aer serveral Discord groups on machine learning and TensorFlow.

Adafruit Discord

The Adafruit Discord server is a 24/7/365 makerspace for folks all around the world (>5K Online, >37K Members).

Arduino Discord

  • Discord members >5K Online, >45K Members

Raspberry Pi Discord

  • Discord members >2K Online, >15K Members

Seeed Discord

  • Discord members >500 Online, >5K Members

Python Discord

  • Discord members >41K Online, >375K Members


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 141: RP2040 DVI

The RP2040 can output DVI siganls.

The electrical DVI video signals are the same as HDMI. DVI does not have audio. HDMI has audio.

Elektor

  • DVI on the RP2040 MCU: A Q&A with Raspberry Pi's Luke Wren

Adafruit

  • DVI on the RP2040 MCU: A Q&A with Raspberry Pi's Luke Wren
  • YouTube NOYDA - RP2040 with DVI output first output test
  • YouTube Raspberry Pi Pico, HDMI on a breadboard
  • YouTube Desk of Ladyada - overtime edition! RP2040 DVI Feather from Bones
  • YouTube Desk of Ladyada - First Bones Board Proto Assembled! DVI Output from RP2040

YouTube Raspberry Pi Pico DVI Sock!

Google search

Wikipedia


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 142: RP2040 PIO

RP2040 has PIO (Programmable Input Output)

The PIO is used to output sound, vidoe or other hardware spedific protocols.

PIO is 4 independent state machines.

PIO 4 stata machines can access all GPIOs. PIO notifies the processors with interrupts or polling.
PIO programming language.

Google


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 143: Wire

Nuts and Volts


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 145: Pico Vsys Power Test

Above image is the Raspberry Pi Pico with power supplied to Vsys pin 39 and ground pin 38.

Test conditions

  • No other circuits attached to the Pico.
  • Test program main.py cycles the onboard LED on for 5 seconds and then off for 5 seconds.
  • Test data VsysMw.ods
  • Vsys: 1.8 V to 5.5 V.

Image credit: Raspberry Pi Pico Datasheet Page 18

Vsys pin 39 goes directly to the Pico voltage regulator.

Plot Vsys Current LED On/OFF

Plot Vsys Power LED On/OFF

Best low power is when Vsys is ~2.4 V to ~3.1 V.

Table Vsys Current and Power LED On/OFF

The LED currnet is ~3 mA and LED power is ~10 mW.

Test data VsysMw.ods

YouTube


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 169: MicroSD Cards for SBC

I use 64 GB, 128 GB and 256 GB SanDisk High Endurance Card for SBCs.

SanDisk High Endurance Card

SanDisk Max Endurance Card cost about twice as much at the High Endurance Cards

YouTube

Tom's Hardware

Reverse-engineering and analysis of SanDisk High Endurance microSDXC card URL

ChatGPT: What is a High Endurance Video microSDXC Card?

A High Endurance Video microSDXC (Secure Digital Extended Capacity) card is a type of memory card specifically designed for applications that require continuous and high-quality video recording. It is built to withstand the rigorous demands of constant video recording, making it ideal for use in surveillance cameras, dashcams, body cameras, drones, and other devices that require extended durability.

The key feature of a High Endurance Video microSDXC card is its ability to handle a high number of write cycles without experiencing performance degradation or failure. Regular microSD cards are typically designed for general-purpose use and may not be able to sustain continuous video recording for extended periods.

High Endurance Video microSDXC cards are built with high-quality NAND flash memory and advanced firmware algorithms, which allow them to handle the constant write operations associated with video recording. They have enhanced durability, better temperature resistance, and improved error correction capabilities to ensure data integrity over long periods.

These cards often come with specific endurance ratings, denoting the number of hours or terabytes written (TBW) that the card can endure. The endurance rating helps users estimate the card's lifespan and choose an appropriate card based on their recording needs.

It's important to note that High Endurance Video microSDXC cards may have slower read and write speeds compared to regular microSD cards optimized for other applications, such as fast data transfer or high-resolution photography. Therefore, when choosing a memory card, it's crucial to consider the intended purpose and prioritize endurance and reliability over speed.

ChatGPT: Compare a normal microSD Card with a High Endurance Video microSDXC card when they wear out.

When a normal microSD card and a High Endurance Video microSDXC card reach their maximum write endurance and wear out, there are some key differences in their behavior and performance. Here's a comparison:

  1. Endurance: A normal microSD card typically has a lower endurance rating compared to a High Endurance Video microSDXC card. The high endurance card is specifically designed to withstand continuous and intensive write operations associated with video recording, so it generally has a much higher endurance rating, measured in terms of hours or terabytes written (TBW).

  2. Lifespan: Due to its higher endurance, a High Endurance Video microSDXC card has a longer lifespan than a regular microSD card. It can sustain a significantly larger number of write cycles before reaching its wear-out point. This means that it can be used for longer periods of time without needing replacement.

  3. Performance degradation: When a normal microSD card reaches its wear-out point, it may start experiencing performance degradation. This can manifest as slower write speeds, increased errors, or even data corruption. On the other hand, a High Endurance Video microSDXC card is designed to maintain its performance and data integrity even after extensive use. While it will eventually wear out like any other storage medium, it tends to offer more consistent and reliable performance throughout its lifespan.

  4. Failure modes: When a normal microSD card reaches the end of its life, it is more prone to sudden failures or becoming unreadable. This can result in data loss or the card becoming unusable. In contrast, a High Endurance Video microSDXC card is engineered to have robust error correction capabilities and better reliability, minimizing the risk of sudden failures.

In summary, a High Endurance Video microSDXC card outperforms a regular microSD card in terms of endurance, lifespan, performance consistency, and reliability. It is specifically designed to handle the demands of continuous video recording without experiencing rapid degradation or failure, providing a more reliable storage solution for applications that require extended durability.

ChatGPT: Compare Sandisk max endurance card with Sandisk high endurance card.

SanDisk offers two popular lines of memory cards designed for continuous video recording: the SanDisk Max Endurance card and the SanDisk High Endurance card. Here's a comparison between these two product lines:

  1. Endurance Rating: Both cards are designed for extended durability, but they have different endurance ratings. The SanDisk Max Endurance card typically offers a higher endurance rating compared to the SanDisk High Endurance card. The exact endurance ratings can vary depending on the specific models, but generally, the Max Endurance cards are designed to handle more write cycles and have a longer lifespan.

  2. Usage Scenarios: The SanDisk Max Endurance card is aimed at demanding applications that require long-lasting endurance, such as continuous video surveillance or high-resolution video recording. It is suitable for use in devices like security cameras, dashcams, or drones that require reliable and robust storage. The SanDisk High Endurance card, on the other hand, is also designed for continuous video recording but is typically targeted at more consumer-grade applications, including dashcams and home security cameras.

  3. Capacities: Both card lines offer a range of storage capacities to suit different needs. They are available in capacities ranging from 32GB to 256GB, allowing users to choose the appropriate size based on their storage requirements.

  4. Performance: In terms of performance, both card lines offer similar read and write speeds, ensuring smooth and consistent video recording. The specific speed ratings may vary between different models within each line, but they generally meet the necessary requirements for recording high-quality video.

  5. Warranty: SanDisk typically offers a warranty for both the Max Endurance and High Endurance cards. The warranty duration can vary, so it's important to check the product specifications and terms provided by SanDisk.

Overall, while both the SanDisk Max Endurance and SanDisk High Endurance cards are designed for continuous video recording, the Max Endurance line generally offers a higher endurance rating and is geared towards more demanding professional applications. The High Endurance line, while still reliable, caters to consumer-grade needs and offers a slightly lower endurance rating. It's important to consider your specific requirements and choose the card that best fits your usage scenario and endurance needs.

ChatGPT: What is the lifespan of a normal microSD card?

The lifespan of a normal microSD card can vary depending on several factors, including the quality of the card, usage patterns, and environmental conditions. Generally, microSD cards have a finite lifespan determined by the number of write cycles they can endure before wearing out. Write cycles refer to the process of writing data onto the card.

The lifespan of a microSD card is often specified by its endurance rating, which is an estimation of the total amount of data that can be written to the card before it reaches its wear-out point. Endurance ratings are typically expressed in terms of hours of video recording or terabytes written (TBW).

For regular consumer-grade microSD cards, the endurance ratings can vary widely. Lower-endurance cards may have ratings ranging from a few hundred to a few thousand hours of video recording or a few tens to hundreds of terabytes written. Higher-endurance cards, including those designed for continuous video recording, can have ratings in the range of thousands of hours or several hundred terabytes written.

It's important to note that the lifespan of a microSD card is not solely determined by its endurance rating. Factors such as the frequency and intensity of usage, the type of data being written, and environmental conditions (temperature, humidity, etc.) can also impact its lifespan. Additionally, as the card ages, it may experience gradual performance degradation even before reaching its wear-out point.

To maximize the lifespan of a microSD card, it's recommended to follow best practices such as avoiding frequent and unnecessary data overwrites, using the card within its specified temperature range, and safely ejecting the card before removing it from devices. Regularly backing up important data from the card is also a good practice to prevent data loss.

Overall, while the lifespan of a normal microSD card can vary, it is generally advisable to choose a card with a higher endurance rating if you anticipate extensive or continuous usage to ensure long-term reliability.

ChatGPT: What is the lifespan of a microSD card used in a Raspberry Pi computer?

The lifespan of a microSD card used in a Raspberry Pi computer can vary depending on several factors. Raspberry Pi computers often perform numerous read and write operations on the microSD card, which can impact its lifespan. Here are some factors that can influence the lifespan:

  1. Quality of the microSD card: Higher-quality microSD cards generally tend to have better durability and endurance, meaning they can withstand more write cycles before wearing out. Opting for a reputable brand and choosing a card specifically designed for endurance, such as those labeled as "High Endurance" or "Industrial Grade," can contribute to a longer lifespan.

  2. Operating system optimizations: The choice of operating system and its configuration can affect the number of write operations performed on the microSD card. Some operating systems, like Raspbian (now Raspberry Pi OS), implement measures to minimize unnecessary writes and optimize performance, which can extend the lifespan of the microSD card.

  3. Write-intensive applications: If you're running applications on your Raspberry Pi that involve frequent and intensive writing to the microSD card, such as databases or logging systems, it can accelerate the wear on the card. These types of applications may lead to a shorter lifespan compared to less write-intensive uses.

  4. Power loss and improper shutdowns: Abrupt power losses or improper shutdowns (e.g., pulling the power plug without shutting down the Raspberry Pi properly) can increase the risk of data corruption and potentially shorten the lifespan of the microSD card. It's important to ensure proper power management and shutdown procedures to minimize these risks.

Given these factors, it's challenging to provide an exact lifespan for a microSD card used in a Raspberry Pi. However, with regular usage and assuming a reasonably good quality microSD card, it's generally expected that the card should last for at least several months to a few years, depending on usage patterns and other factors.

To improve the lifespan of the microSD card in a Raspberry Pi, consider implementing the following best practices:

  1. Choose a high-quality microSD card with good endurance ratings.
  2. Optimize the operating system settings to minimize unnecessary writes.
  3. Minimize write-intensive applications or consider utilizing external storage options.
  4. Ensure proper power management and shutdown procedures.
  5. Regularly back up important data to mitigate potential data loss.

By following these guidelines, you can help maximize the lifespan of the microSD card used in your Raspberry Pi and enhance its overall reliability.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 174: YouTube Channel W2AEW

Alan Wolke, Application Engineer at Tektronix, W2AEW has a great electronics and ham radio YouTube videos.

  • 17 page index of >360 videos PDF


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 179: CAN Bus

CAN Bus


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 186: Raspberry Pi Pico GPIO Current

  • Sourcing or sinking up to 25 mA (milliamperes) of current individually,
  • A total limit of 150 mA for all GPIO pins combined.

ChatGPT: What is the maximum digital output current of a Raspberry Pi Pico?

The Raspberry Pi Pico is a microcontroller board that is powered by a RP2040 microcontroller chip. The RP2040 chip itself does not have a specified maximum digital output current. However, the GPIO pins on the Raspberry Pi Pico are capable of sourcing or sinking up to 25 mA (milliamperes) of current individually, with a total limit of 150 mA for all GPIO pins combined.

It's important to note that exceeding these limits can cause damage to the board or connected components. If you require higher current capabilities, you may need to use external components such as buffers, transistors, or dedicated driver circuits to handle the increased current requirements.

ChatGPT: What is is the Mimi resistor value to use from the GPIO pin to ground?

When connecting a resistor from a GPIO pin to ground, it is commonly referred to as a pull-down resistor. The purpose of a pull-down resistor is to ensure that the GPIO pin has a defined logic level (LOW) when it is not being actively driven by the microcontroller.

For the Raspberry Pi Pico, the GPIO pins have an internal pull-down resistor that can be enabled through software configuration. This means that you do not necessarily need to add an external pull-down resistor if you enable the internal pull-down resistor in your code.

To enable the internal pull-down resistor for a GPIO pin on the Raspberry Pi Pico using MicroPython, you can use the following code:

import machine

# Configure GPIO pin 0 with pull-down resistor
pin = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_DOWN)

If you prefer to use an external pull-down resistor, a commonly used value is around 10 kΩ (kiloohms). However, the actual resistor value depends on the specific requirements of your circuit and the devices connected to the GPIO pin. You may need to choose a different value based on factors such as the electrical characteristics of the connected components, desired noise immunity, and power consumption.

ChatGPT: How much current flows in the 10 kΩ external pull-down resistor when the GPIO pin is high?

When the GPIO pin is set to a HIGH logic level (3.3V for the Raspberry Pi Pico), there will be a voltage potential difference across the external pull-down resistor. To determine the current flowing through the resistor, you can use Ohm's Law, which states that current (I) is equal to the voltage (V) divided by the resistance (R):

I = V / R

In this case, the voltage across the resistor is the supply voltage minus the GPIO pin voltage. Assuming a 3.3V supply voltage and a HIGH logic level of 3.3V for the GPIO pin, the voltage across the resistor would be:

V = 3.3V - 3.3V = 0V

Substituting the values into Ohm's Law, we have:

I = 0V / 10 kΩ = 0A

Therefore, when the GPIO pin is set to a HIGH logic level, no current will flow through the 10 kΩ external pull-down resistor.

ChatGPT: How much current flows in the 10 kΩ external pull-down resistor when the GPIO pin is low?

When the GPIO pin is set to a LOW logic level (0V for the Raspberry Pi Pico), there will be a voltage potential difference across the external pull-down resistor. To determine the current flowing through the resistor, you can again use Ohm's Law:

I = V / R

In this case, the voltage across the resistor is the supply voltage (3.3V for the Raspberry Pi Pico) minus the GPIO pin voltage (0V). Thus, the voltage across the resistor is:

V = 3.3V - 0V = 3.3V

Substituting the values into Ohm's Law, we have:

I = 3.3V / 10 kΩ = 0.33 mA

Therefore, when the GPIO pin is set to a LOW logic level, approximately 0.33 mA (milliamperes) of current will flow through the 10 kΩ external pull-down resistor.

ChatGPT: What is the shortest pulse that the GPIO pin can output?

The Raspberry Pi Pico, with its RP2040 microcontroller, has highly flexible and programmable GPIO pins. The actual shortest pulse that a GPIO pin can output depends on various factors such as the programming language used, the specific code implementation, and the system clock frequency.

By default, the RP2040 microcontroller on the Raspberry Pi Pico has a system clock frequency of 125 MHz. This means that the shortest pulse that can be generated is determined by the clock period of 1/125 MHz, which is approximately 8 nanoseconds (ns).

However, achieving such a short pulse width may be challenging in practice due to various factors such as code execution time, interrupt latency, and the limitations of the programming language itself. Additionally, the accuracy and precision of the pulse width may also be influenced by external factors like the connected circuitry and its response time.

Therefore, while the theoretical shortest pulse width can be as short as 8 ns based on the system clock frequency, achieving and accurately measuring such short pulses may be difficult in practical scenarios.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 187: Raspberry Pi Pico GPIO Square Wave

ChatGPT: Create a MicroPython program to generate a square wave 1 Hz on a GPIO pin.

Certainly! Here's an example MicroPython program to generate a square wave with a frequency of 1 Hz on a GPIO pin of the Raspberry Pi Pico:

import machine
import utime

# Define the GPIO pin number
gpio_pin = 2

# Configure the GPIO pin for output
pin = machine.Pin(gpio_pin, machine.Pin.OUT)

# Generate a square wave
while True:
    pin.value(1)  # Set the pin to HIGH
    utime.sleep(0.5)  # Delay for half a second
    
    pin.value(0)  # Set the pin to LOW
    utime.sleep(0.5)  # Delay for half a second

In this program, we first import the necessary modules machine for GPIO control and utime for time-related functions. Then, we define the GPIO pin number (gpio_pin) to which the square wave will be output.

We configure the GPIO pin as an output pin using machine.Pin(gpio_pin, machine.Pin.OUT). The pin object represents the GPIO pin and allows us to set its value.

Inside the while True loop, we alternate between setting the pin value to 1 (HIGH) and 0 (LOW) using pin.value(1) and pin.value(0), respectively. We then use utime.sleep(0.5) to introduce a delay of half a second, resulting in a square wave with a frequency of 1 Hz (one cycle per second).

You can modify the gpio_pin variable to match the GPIO pin number you intend to use for generating the square wave.

ChatGPT: Change the program by adding a variable to set the square wave frequency.

Certainly! Here's an updated version of the MicroPython program that includes a variable to set the square wave frequency:

import machine
import utime

# Define the GPIO pin number
gpio_pin = 2

# Define the square wave frequency in Hz
frequency = 1

# Calculate the time period based on the frequency
period = 1 / frequency

# Configure the GPIO pin for output
pin = machine.Pin(gpio_pin, machine.Pin.OUT)

# Generate a square wave
while True:
    pin.value(1)  # Set the pin to HIGH
    utime.sleep(period / 2)  # Delay for half of the time period
    
    pin.value(0)  # Set the pin to LOW
    utime.sleep(period / 2)  # Delay for half of the time period

In this updated program, we added a new variable frequency that represents the desired square wave frequency in Hz. You can modify this variable to set the desired frequency.

Based on the specified frequency, we calculate the time period of each cycle using the formula period = 1 / frequency.

Inside the while True loop, we use pin.value(1) to set the GPIO pin to HIGH and pin.value(0) to set it to LOW. The utime.sleep() function is used to introduce a delay of half of the time period (period / 2). This ensures that the total time for each cycle (HIGH + LOW) is equal to the specified time period.

By adjusting the frequency variable, you can set the square wave to your desired frequency.

ChatGPT: What is the highest frequency that can be used?

The highest frequency that can be generated by a GPIO pin on the Raspberry Pi Pico is influenced by various factors, including the capabilities of the RP2040 microcontroller, the programming language used, and the specific code implementation.

In general, the RP2040 microcontroller used in the Raspberry Pi Pico has a maximum clock frequency of 133 MHz. This clock frequency determines the execution speed of the code and, consequently, the fastest achievable square wave frequency.

However, it's important to note that generating very high-frequency square waves using general-purpose GPIO pins might be challenging due to factors such as the execution time of the code, interrupt latency, and the limitations of the programming language itself. Additionally, other factors, such as the electrical characteristics of the connected circuitry and the response time of the components, can also affect the achievable frequency.

Therefore, while the theoretical maximum frequency could be quite high, practical limitations make it difficult to provide a specific value. It's best to consider the specific requirements of your application and perform testing to determine the highest achievable frequency within the given constraints.

ChatGPT: What is the lowest frequency that can be used in the program?

The lowest frequency that can be used in the program depends on several factors, including the capabilities of the RP2040 microcontroller, the programming language used, and the specific code implementation.

In general, the RP2040 microcontroller used in the Raspberry Pi Pico is capable of generating square waves with very low frequencies. The utime.sleep() function is commonly used to introduce delays in MicroPython code. However, the accuracy and precision of the delay introduced by utime.sleep() can vary based on the specific implementation and system clock frequency.

The utime.sleep() function typically operates with a resolution of milliseconds or microseconds, depending on the platform and the specific version of MicroPython. Achieving delays in the range of seconds or longer can be challenging with utime.sleep() alone.

To generate lower frequencies, you may need to use alternative approaches, such as using timers or hardware-specific features. By utilizing timer interrupts and advanced features of the RP2040 microcontroller, you can achieve lower frequencies with greater accuracy and precision.

In summary, the lowest frequency that can be used in the program is subject to various factors, including the specific implementation and the techniques employed. However, with appropriate utilization of timer interrupts and other advanced features, you can achieve lower frequencies with improved accuracy and precision.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 188: Raspberry Pi Pico GPIO PIO

Raspberry Pi Pico GPIO PIO

ChatGPT: What is Raspberry Pi Pico GPIO PIO?

The Raspberry Pi Pico is a microcontroller board developed by the Raspberry Pi Foundation. It features the RP2040 microcontroller chip, which is specifically designed for low-cost microcontrollers and is the first microcontroller product from the Raspberry Pi Foundation.

GPIO (General-Purpose Input/Output) refers to the pins on the Raspberry Pi Pico that can be programmed to either read digital inputs or control digital outputs. These pins can be used to interface with various electronic components, such as sensors, buttons, LEDs, and more.

PIO (Programmable Input/Output) is a unique feature of the RP2040 microcontroller on the Raspberry Pi Pico. It is a versatile state machine system that allows you to implement custom digital interfaces and protocols with precise timing and control. The PIO subsystem provides a way to offload time-critical tasks from the CPU, allowing for more efficient and deterministic operation.

The PIO feature enables you to program the GPIO pins to perform specific tasks in real-time, such as generating precise timing signals, implementing custom communication protocols, or driving addressable LED strips. It provides a flexible and powerful way to extend the capabilities of the Raspberry Pi Pico beyond basic GPIO functionality.

You can write programs for the PIO subsystem using the PIO assembler language or by using the PIO API provided by the official Raspberry Pi Pico SDK. The SDK includes examples and documentation to help you get started with using the PIO feature on the Raspberry Pi Pico.

ChatGPT: Please provide more details on the PIO state machine.

Certainly! The PIO (Programmable Input/Output) state machine on the Raspberry Pi Pico is a powerful feature that allows you to implement custom digital interfaces and protocols with precise timing and control. It is a versatile subsystem designed to offload time-critical tasks from the CPU, enabling more efficient and deterministic operation.

Here are some key details about the PIO state machine:

  1. Architecture: The PIO subsystem on the Raspberry Pi Pico consists of two programmable state machines (PIO0 and PIO1) that can operate independently. Each state machine has four instruction memory slots and 32 general-purpose registers.

  2. Instruction Execution: The state machine executes instructions in a loop, with each instruction corresponding to a single clock cycle. Instructions can perform operations such as reading/writing GPIO pins, shifting data, conditional branching, and more.

  3. Instruction Set: The PIO instruction set is designed to efficiently handle various I/O operations. It includes instructions for pin input/output, bitwise operations, shift and delay operations, and conditional branching. The instruction set provides flexibility for implementing a wide range of digital interfaces.

  4. FIFOs: Each state machine has two FIFOs (First-In, First-Out) that can hold up to 32 bits of data each. These FIFOs enable efficient data transfer between the state machine and the CPU or other peripherals.

  5. Programmability: You can program the PIO state machine using the PIO assembler language or the PIO API provided by the Raspberry Pi Pico SDK. The PIO assembler language is a low-level language specifically designed for programming the state machine. The SDK also provides higher-level abstractions and libraries to simplify PIO programming.

  6. Synchronization: Multiple PIO state machines on different pins can be synchronized to work together, enabling complex and synchronized digital protocols. This feature is particularly useful for applications involving precise timing requirements or multi-channel communication.

  7. Versatility: The PIO subsystem is highly versatile and can be used for various applications. It can be employed for tasks such as generating precise timing signals, implementing communication protocols (UART, SPI, I2C, etc.), driving addressable LED strips, and more.

The PIO feature on the Raspberry Pi Pico provides a unique level of control and flexibility, allowing you to implement complex digital interfaces and protocols efficiently. It is a powerful tool for expanding the capabilities of the Raspberry Pi Pico and exploring advanced microcontroller projects.

ChatGPT: Create a study outline for a beginner on how to use the PIO.

Sure! Here's a study outline for a beginner to learn how to use the PIO (Programmable Input/Output) on the Raspberry Pi Pico:

  1. Introduction to PIO:

    • Understand the concept of PIO and its benefits.
    • Learn about the PIO subsystem on the Raspberry Pi Pico and its capabilities.
  2. Getting Started:

    • Set up the development environment for Raspberry Pi Pico programming.
    • Install the necessary software, such as the Raspberry Pi Pico SDK and development tools.
  3. PIO Architecture:

    • Explore the architecture of the PIO subsystem.
    • Understand the role of state machines, instruction memory, registers, and FIFOs.
  4. PIO Programming Basics:

    • Learn about the PIO assembler language and its syntax.
    • Understand the basic instructions for pin I/O, shifting data, and conditional branching.
  5. Simple GPIO Control:

    • Start with simple GPIO control using the PIO state machines.
    • Write programs to control GPIO pins for input and output operations.
  6. Understanding Timing:

    • Explore the concept of timing in PIO programs.
    • Learn how to generate precise timing signals using delay instructions.
  7. Data Transfer with FIFOs:

    • Understand the FIFOs in the PIO state machines.
    • Learn how to use FIFOs for efficient data transfer between the state machine and the CPU.
  8. Advanced GPIO Techniques:

    • Dive deeper into GPIO operations using PIO.
    • Explore advanced techniques such as edge detection, debouncing, and precise I/O control.
  9. Implementing Digital Interfaces:

    • Learn how to implement common digital interfaces using PIO.
    • Examples include UART, SPI, I2C, and other protocols.
  10. Synchronization and Multi-Channel Communication:

    • Understand the synchronization capabilities of multiple PIO state machines.
    • Learn how to synchronize multiple state machines for multi-channel communication.
  11. Real-World Applications:

    • Explore real-world applications of PIO on Raspberry Pi Pico.
    • Examples may include driving addressable LED strips, motor control, sensor interfacing, etc.
  12. Project Development:

    • Apply the knowledge gained to develop your own PIO-based projects.
    • Start with simple projects and gradually increase complexity.
  13. Resources and Documentation:

    • Explore additional resources, documentation, and examples provided by the Raspberry Pi Pico community.
    • Participate in online forums and communities to seek help and share experiences.

Remember to practice regularly, experiment with different examples, and gradually build your understanding and skills with PIO programming on the Raspberry Pi Pico. Good luck with your studies!

ChatGPT: List the study resource such as videos, books, articles, labs, sample programs, etc.

Certainly! Here's a list of study resources that can help you learn how to use the PIO on the Raspberry Pi Pico:

  1. Official Raspberry Pi Pico Documentation:

    • Raspberry Pi Pico Datasheet: Provides detailed technical information about the Raspberry Pi Pico and its RP2040 microcontroller chip.
    • Raspberry Pi Pico C/C++ SDK Documentation: Includes information on the PIO subsystem, PIO programming, and related APIs.
    • Raspberry Pi Pico Python SDK Documentation: Offers guidance on PIO programming using Python.
  2. Raspberry Pi Foundation's Learning Resources:

    • Raspberry Pi Pico Getting Started Guide: A step-by-step guide to setting up the Raspberry Pi Pico and getting started with programming.
    • Raspberry Pi Pico and PIO YouTube Playlist: Features official tutorial videos on various aspects of Raspberry Pi Pico and PIO programming.
  3. Online Tutorials and Articles:

    • Raspberry Pi Pico PIO Examples on GitHub: Provides a collection of PIO example programs and projects to explore and learn from.
    • Hackster.io Raspberry Pi Pico Projects: Offers a range of projects, including PIO-based projects, with step-by-step instructions and code examples.
    • Official Raspberry Pi Forums: Join the active community forums to seek guidance, share experiences, and learn from fellow enthusiasts.
  4. Video Tutorials:

    • "Introduction to Raspberry Pi Pico" by The Raspberry Pi Guy: A beginner-friendly introduction to the Raspberry Pi Pico, including an overview of PIO programming.
    • "Raspberry Pi Pico - PIO" by ExplainingComputers: Provides an in-depth explanation of the PIO subsystem and programming on the Raspberry Pi Pico.
  5. Books:

    • "Programming Raspberry Pi Pico with MicroPython" by Simon Monk: Offers a comprehensive guide to programming the Raspberry Pi Pico, including a section on PIO programming.
  6. Online Courses and Labs:

    • Coursera: Raspberry Pi Pico - Beginner's Guide: A comprehensive online course covering various aspects of Raspberry Pi Pico programming, including PIO.
    • Pi Hut's Pico-Projects: Provides a collection of guided projects with detailed instructions and code examples, including PIO-based projects.

Remember, the Raspberry Pi Pico and PIO are relatively new, and the available resources are continuously expanding. Exploring the official documentation, community forums, and online platforms will help you stay up to date with the latest resources, sample programs, and project ideas.

Happy learning and experimenting with the Raspberry Pi Pico and PIO!

ChatGPT: Create a MicroPython program that uses the PIO to output a squarewave 10 kHz on a GPIO pin.

To generate a square wave of 10 kHz using the Programmable I/O (PIO) on the Raspberry Pi Pico with MicroPython, you can utilize the PIO's state machines and programmable waveform generator. Here's an example program to accomplish this:

import rp2pio
from machine import Pin

# Define the frequency and pin configuration
frequency = 10000  # 10 kHz
gpio_pin = 2

# Define the PIO program
pio_program = rp2pio.StateMachine(0, 
    freq=4 * frequency, 
    sideset_base=Pin(gpio_pin))

pio_program.init(
    rp2pio.asm_pio(
        """
        mov x, osr
        mov y, osr
        jmp loop
        
        wrap_target:
        nop
        wrap
        
        loop:
        jmp x-- wrap_target
        jmp y-- loop
        """
    ),
    freq=4 * frequency,
)

# Run the PIO program
pio_program.active(1)

# Wait indefinitely
while True:
    pass

In this program, we first import the necessary modules, including rp2pio for PIO functionality and machine.Pin for GPIO pin configuration. We define the desired frequency (frequency) as 10 kHz and specify the GPIO pin to be used (gpio_pin).

Next, we define the PIO program using the rp2pio.StateMachine class. We set the frequency of the PIO program to be four times the desired frequency (4 * frequency). The sideset_base parameter is set to the specified GPIO pin.

The PIO program itself is written in assembly language using rp2pio.asm_pio. It consists of a loop that toggles the state of the GPIO pin. The wrap instructions ensure that the program continuously loops.

We initialize the PIO program with pio_program.init() and set the frequency to match the desired frequency.

Finally, we activate the PIO program with pio_program.active(1) to start generating the square wave. The program then enters an infinite loop with while True to keep it running indefinitely.

This program utilizes the PIO to generate a square wave of approximately 10 kHz on the specified GPIO pin.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 189: CircuitPython

Adafruit CircuitPython is based on Python and is a fork of MicroPython that support the Adafruit RP2040 boards, Raspberry Pi Pico boards (Adafruit sells them) and the large selection of Adafriut sensors boards. CircuitPython works great with the Mu IDE. CircuitPython has RP2040 functions like deep sleep that are not in CircuitPython.

ChatGPT: What is CircuitPython?

CircuitPython is an open-source programming language and platform designed for microcontrollers and small computing devices. It is based on the Python programming language, which makes it accessible to beginners and experienced developers alike. CircuitPython provides a simplified and beginner-friendly interface for interacting with hardware components, such as sensors, actuators, and other electronic devices.

Unlike traditional programming languages for microcontrollers, CircuitPython does not require compiling code before running it on the target device. Instead, it uses an interactive interpreter that allows you to write and execute code directly on the microcontroller. This makes the development process more efficient and beginner-friendly.

CircuitPython is specifically tailored for hardware prototyping and projects involving electronics. It provides a high-level abstraction layer that simplifies the process of working with microcontrollers, allowing developers to focus on the functionality and interactions with sensors and other devices rather than low-level hardware details.

The CircuitPython platform supports a wide range of microcontrollers, including popular boards like Adafruit's Feather, Trinket, and Circuit Playground. It offers a unified API (Application Programming Interface) across different devices, making it easier to transfer projects between supported hardware platforms.

One of the key advantages of CircuitPython is its extensive library support. There are numerous pre-built libraries available for various sensors, actuators, displays, and communication protocols. These libraries provide ready-to-use code snippets and functions that simplify the process of integrating hardware components into your projects.

CircuitPython also has an active and supportive community, which provides tutorials, documentation, and examples to help users get started and troubleshoot any issues they may encounter. This makes it a great choice for beginners and hobbyists who want to explore the world of electronics and physical computing using an easy-to-learn programming language.

ChatGPT: Create a study outline for a beginner on how to use CircuitPython.

Sure! Here's a study outline for a beginner to learn how to use CircuitPython:

  1. Introduction to CircuitPython

    • What is CircuitPython?
    • Advantages and features of CircuitPython
    • Supported microcontrollers and hardware platforms
  2. Setting Up the Development Environment

    • Installing CircuitPython on a microcontroller board
    • Connecting the microcontroller to your computer
    • Basic overview of the code editor and file structure
  3. Hello, CircuitPython!

    • Writing and running your first CircuitPython script
    • Understanding the structure of a CircuitPython program
    • Interacting with the REPL (Read-Eval-Print Loop) prompt
  4. Working with Digital Inputs and Outputs

    • Controlling LEDs and digital pins
    • Reading button inputs and switches
    • Using digital inputs and outputs to create simple circuits
  5. Analog Inputs and Outputs

    • Understanding analog-to-digital conversion
    • Reading values from analog sensors (e.g., light sensor, temperature sensor)
    • Controlling analog outputs (e.g., PWM, analog voltage)
  6. Working with External Libraries

    • Introduction to CircuitPython libraries
    • Installing and managing libraries
    • Exploring popular libraries for sensors, displays, and communication protocols
  7. Serial Communication and Interfacing

    • Sending and receiving data using UART, I2C, and SPI protocols
    • Interfacing with external devices (e.g., sensors, displays)
    • Communicating with a computer via USB serial
  8. Creating Projects and Prototypes

    • Planning and designing your CircuitPython project
    • Integrating various hardware components
    • Building interactive and responsive applications
  9. Troubleshooting and Debugging

    • Common issues and how to solve them
    • Using debugging techniques and tools
    • Reading error messages and troubleshooting tips
  10. Community and Resources

    • Joining the CircuitPython community
    • Exploring online forums, tutorials, and projects
    • Sharing and collaborating with other CircuitPython enthusiasts

Remember, this outline is just a starting point, and you can adjust it based on your learning pace and interests. As you progress through the outline, it's important to practice what you learn by working on small projects and experimenting with different hardware components to deepen your understanding of CircuitPython.

ChatGPT: List the study resource such as videos, books, articles, labs, sample programs, etc.

Certainly! Here's a list of study resources including videos, books, articles, labs, and sample programs that can be helpful for learning CircuitPython:

Videos:

  1. CircuitPython YouTube Playlist
  2. Getting Started with CircuitPython Playlist
  3. CircuitPython search

Books:

  1. "Getting Started with Adafruit Circuit Playground Express" by Mike Barela on Amazon
  2. "Python for Microcontrollers: Getting Started with MicroPython" by Donald Norrison on Amazon

Articles and Guides:

  1. Adafruit Learning System: https://learn.adafruit.com/category/circuitpython
  2. CircuitPython Documentation: https://circuitpython.readthedocs.io/
  3. "CircuitPython Essentials" Guide: https://learn.adafruit.com/circuitpython-essentials

Labs and Hands-on Activities:

  1. Adafruit CircuitPython Guides: https://learn.adafruit.com/category/circuitpython-guides
  2. Adafruit Learn CircuitPython Projects: https://learn.adafruit.com/category/circuitpython-projects
  3. CircuitPython Weekly Newsletter (includes projects and community highlights): https://www.adafruitdaily.com/category/circuitpython/

Sample Programs and Code Snippets:

  1. Adafruit CircuitPython GitHub Repository: https://github.com/adafruit/circuitpython
  2. Adafruit CircuitPython Library Bundle: https://github.com/adafruit/Adafruit_CircuitPython_Bundle

These resources cover a wide range of topics and provide hands-on learning experiences to help you understand and explore CircuitPython effectively. Remember to combine theoretical knowledge with practical application by working on projects and experimenting with different hardware components to gain proficiency in CircuitPython.


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 190: Prof. John Gallaugher

YouTube


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 191: Circuit Playground CircuitPython<

Adafruit Circuit Playground Express Learn

  • Update boot loader.
  • Update CircuitPython.
  • Install the latest version of Mu the IDE for CircuitPython.

Circuit Playground

  • Rest double click enters bootloarder directory CPYAYBOOT, all LEDs are green.
  • Rest once enters Python directory, code.py file is the CircuitPython code, lib directory is the CircuitPython, boot_out.txt is the CircuitPython version.

Mu is the recommended IDE for CircuitPython.

YouTube tutorials

URLs

Learn CircuitPython with Circuit Playground

CPLAYBOOT INDO_UF2.TXT

UF2 Bootloader v3.15.0 SFHWRO
Model: CPlay Express
Board-ID: SAMD21G18A-CPlay-v0
 
PRE>

CIRCUITPY boot_out.txt

Adafruit CircuitPython 8.2.0 on 2023-07-05; Adafruit CircuitPlayground Express with samd21g18
Board ID:circuitplayground_express
UID:D542BEA85851555020312E372F1F0DFF
 
PRE>

Mu V1.2.0 on Ubuntu 20.04.2 LTS

  • Serial button
  • CircuitPython REPL
Visit circuitpython.org for more information.

To list built-in modules type `help("modules")`.
>>> 
>>> help("modules")
__future__        adafruit_hid/keycode                collections       pwmio
__main__          adafruit_hid/mouse                  countio           rainbowio
adafruit_bus_device                 adafruit_lis3dh   digitalio         random
adafruit_bus_device.i2c_device      adafruit_pixelbuf errno             rotaryio
adafruit_bus_device.spi_device      adafruit_thermistor                 gc                rtc
adafruit_circuitplayground/__init__ analogio          math              storage
adafruit_circuitplayground/circuit_playground_base    array             microcontroller   struct
adafruit_circuitplayground/express  audiobusio        micropython       supervisor
adafruit_hid/__init__               audiocore         neopixel          sys
adafruit_hid/consumer_control       audioio           neopixel_write    time
adafruit_hid/consumer_control_code  bitbangio         nvm               touchio
adafruit_hid/keyboard               board             onewireio         usb_cdc
adafruit_hid/keyboard_layout_base   builtins          os                usb_hid
adafruit_hid/keyboard_layout_us     busio             pulseio           usb_midi
Plus any modules on the filesystem
>>> 
 


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 192: Pico CircuitPython

YouTube


<-- WA9ONY - YouTube - Index - RPi - Website -->

Project 193: MicroPython benchmark programs

ChatGPT: List benchmark programs for MicroPython.

As of my last update in September 2021, the availability of benchmark programs for MicroPython might have changed. However, I can provide you with some benchmark programs that were commonly used for MicroPython at that time:

  1. pystone: Pystone is a popular benchmark used to measure the speed of Python interpreters. It is widely used in the Python community, including MicroPython.
  1. pybench: Pybench is another benchmark suite used for Python, including MicroPython. It measures various aspects of Python performance, such as computation and memory usage.
  1. coremark: Coremark is a widely-used benchmark for evaluating the performance of CPUs and compilers. It includes a version specifically for MicroPython.

  2. dhrystone: Dhrystone is a synthetic computing benchmark that has been used for many years to measure CPU performance.

  3. uPyBench: uPyBench is a MicroPython-specific benchmark that aims to measure the performance of MicroPython on embedded systems.

  4. timeit: Although not a benchmark suite, Python's built-in timeit module can be used to measure the execution time of small code snippets, which can help you compare different approaches and optimizations in MicroPython.

It's essential to note that MicroPython's performance heavily depends on the hardware it runs on, as it's often used on resource-constrained embedded systems. For accurate benchmarking, you should run these programs on the specific hardware and version of MicroPython you are interested in.

To find the latest and most up-to-date benchmark programs for MicroPython, I recommend checking the MicroPython community forums, GitHub repositories, or official websites for the MicroPython project. Also, keep in mind that new benchmarking tools and suites might have emerged since my last update.

CircuitPython-Pi-Calculation-Benchmark

import board, busio, os, time, terminalio, displayio, microcontroller

def calculate_pi(n):
    """
    Calculate the value of pi using the Bailey–Borwein–Plouffe formula.
    """
    pi = 0
    k = 0
    for k in range(n):
        pi += (1 / 16.**k) * ((4 / (8 * k + 1)) - (2 / (8 * k + 4)) - (1 / (8 * k + 5)) - (1 / (8 * k + 6)))
        k += 1
        if k%50 == 0:
            drawPercent(k/n)
    return pi

start_time = time.monotonic()
pi = calculate_pi(60000)
end_time = time.monotonic()
execution_time = round(end_time - start_time,4)

About

Raspberry Pi Pico & RP2040 microcontrollers notes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages