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.

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.

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

Parsing Comma Delimited Data Strings in Arduino

In this lesson we are working on a client server connection. The Arduino is the server, and a python program on a desktop PC is the client. The objective is to control the color of an RGB LED from the client. The client will send data to the server as comma delimited string, like 255,0,255 for RGB. The challenge on the server side is to parse this data so we get integer values of:

R=255

G=0

B=255

In this video lesson we start by simply controlling two LED, a red and green one, from the python client. We then show how we can control an RGB LED by sending the data string from the client, and parsing it on the server side. For your convenience, we include the code here:

Server Side code for the Arduino:

The code above needs a ‘secrets.h’ file which includes your WiFi name and password. This is created in the IDE by choosing ‘Add Tab’. Call the new tab ‘secrets.h’, and edit the code below to include your WiFi name and passwords inside the quotes:

Now, on the client side, this is our standard Python client:

With this code for creating a client and server, and then parsing comma delimited text, you can easily add the code needed to control the RGB LED color to the arduino program.

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:

This demonstration circuit controls servo position by two push buttons

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

 

Create a Simple Client Server Connection Over WiFi to Connect Arduino to Python on the PC

In this video lesson, we show how to create a simple Client/Server connection over WiFi. We connect the Arduino Uno R4 WiFi to Python running on the PC. The arduino is the server, and the PC Python program is the client. We show how to pass data from the PC to the Arduino, and then how to pass data from the Arduino back to the PC. With this simple framework, we can control Arduino projects from our desktop PC, and we can use the PC to display data being taken from the Arduino.

In this lesson we develop code for Arduino, and the code in Python. For your convenience, we present the code below.

On the Arduino Side, this is the code to create the ‘Server’.

You also need to add a tab to your program using the ‘Add Tab’ feature of the IDE. The program in the tab should be named secrets.h

Your secrets.h file should look like this:

You can run the program above, and it should connect to your WiFi, and should print out the Arduino’s IP address. Make note of the IP address as it will be needed in the Client program below. On the PC side, this is the python code to create the client:

 

Remotely Control a DC Motor Over WiFi With Raspberry Pi Pico W

In this video lesson I will show you how you can control a remote DC motor using your Raspberry Pi Pico W. The Pi Pico is set up as a server, and is connected to a DC motor, and TA6586 Motor Controller. The motor is controlled by a client Python program running on your desktop PC. On the client side we create a Graphical Widget, which will allow you to control both the speed and direction of the motor. the schematic for the Raspberry Pi Pico W side is shown below:

Schematic for TA6586 and Raspberry Pi Pico DC Motor Control

Then in the video, we developed the following software for the server side on the Pi Pico

Then for the client side, the following program runs on Python on your PC:

 

 

Making The World a Better Place One High Tech Project at a Time. Enjoy!

Exit mobile version