Category Archives: MicroPython

RFID Lock and Unlock Demonstration Project Raspberry Pi Pico W

In this video lesson we explore using an RFID-RC522 and an RFID tag to lock and unlock our raspberry pi project. This demonstration will include an RGB LED which remains red while the system is locked, and then turns green when the system is unlocked by the RFID tag. Absence of user input, the system will lock again after 5 seconds. The following is the circuit diagram for the project:

RFID
Schematic for Raspberry Pi Pico W and RFID module, with LED and Push Buttons

For your convenience, the code for the project is included below:

 

Connecting and Using the RFID-RC522 RFID Tag in a Raspberry Pi Pico Project

This lesson is a brief introduction to incorporating an RFID tag into your Raspberry Pi Pico W project. We will be using the RFID-RC522 module, and will show to how to both read and write RFID tags.

The schematic shows how to connect the RFID module to your Pi Pico project.

RFID
Connecting the RFID Module to the Raspberry Pi Pico W

The schematic above includes the breadvolt power supply, which we will use later as the project advances in future lessons. Notice carefully the top jumpers on the breadvolt set to 5 Volts, and the lower jumpers are set as 3.3 volts.

This is an alternative view of the same schematic, showing the pin labels on the RFID module. Both these schematics are the same, you can use the one you find easiest.

As the project progresses, we will also add two pushbuttons and an RGB LED to the circuit. This is the schematic, which we will use in lesson 121.

RFID
Schematic for Raspberry Pi Pico W and RFID module, with LED and Push Buttons

Storing Mission Critical Data in Flash Memory on the Raspberry Pi Pico W

In this video lesson we show how mission critical data can be saved in Flash Memory on the Raspberry Pi Pico W. There is just 2 MB of flash memory available, and the flash memory is only specified for 100,000 write cycles. This means we must be careful and deliberate in when to use flash memory, and it should not be used as a general purpose data logger. For example, if you wrote a memory location once a second, you could reach cycle limit in a few days. However, storing things like calibration data, user preferences and so forth are excellent uses of the memory.

In order to demonstrate this capability, we will show a program where the position of the servo is saved in a .json file in flash memory. If power is lost, the program goes and reloads the last position of the servo from the .json file, and then proceeds from there. We use the following circuit:

servo control
This demonstration circuit controls servo position by two push buttons

We also include the code developed in this lesson below for your convenience:

 

PyQt Generates a HSV Color Wheel on Raspberry Pi Pico Over Wifi Project

 In this video lesson we create an interesting project. We create a PyQt Window which  used 3 Sine Waves offset from each other by (2*Pi/). By offsetting the Sine Waves each by this amount creates 3 waves perfectly spaced across the domain. We then use the values from these sine waves to create the Red, Green and Blue values for the HSV color wheel. The x axis represents angle, in radians. Then the values of the sine wave represent the corresponding Red, Green, and Blue values. The program graphs the three waves on the PyQt widget, then passes the data via UDP over WiFi to the Pi Pico. The Pico then applies the values to the RGB LED.  We save the server side program on the Pi Pico as main.py, and power the project with the Breadboard Power Bank, meaning the Pi operates remote and untethered, and the LED is controlled by the desktop client software. This is a schematic of the Pi Pico circuit for the project.

RGB LED
Circuit Schematic for Connecting the RGB LED

This project has a server running on the Raspberry Pi Pico, and a Client running on your desktop PC. Here is the code for the server side for the Pi Pico.

Remember you must set up your ‘secrets.py’ file for your WiFi name and password. Create this file, put in your WiFi name and password, and then save the file on your Raspberry Pi Pico in the lib folder.

Then the code below is the program we developed for the client side. This will run on your PC.

 

Control Raspberry Pi Pico PIO State Machines in a Micropython Class

In this video lesson we show how you can control a PIO State Machine on the Raspberry Pi Pico W inside of a micropython class. We demonstrate with the practical example of controlling servos with a servo Class which we create. The objective is to ‘hide’ all the complex code in the class, allowing less adept users to interact with the servo with simple python commands. For your convenience the code developed in this video is included below. Enjoy!