Tag Archives: WiFi

Improved Client Server Framework for Arduino

In this lesson, we show an improved framework for creating a Client/Server connection between your Arduino and your desktop PC over WiFi. This will serve as the basis for our WiFi projects moving forward.  On the arduino side, we have the following code to create the Server:

Remember, you must create a new tab, and include the following as your ‘secrets.h’ file

And then, on the Desktop side, this will be your python ‘Client’ code:

 

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.

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:

Motor Controller
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:

 

 

Improved PyQt Color Wheel Project

In this video lesson we improve last weeks project by making the PyQt widget more virtual. The PyQt widget generates 3 sine waves, one for the Red color channel, one for the Green color channel, and one for the Blue color channel. The three sine waves are displayed on the widget. You are then given the opportunity in the widget to scale any of the three color channels. This allows you to calibrate your RGB LED in case any color channel is dominating. The widget also features a “Chase” mode where you can introduce phase injection into any of the color channels. This causes one or more of the color channels to “chase” the other ones. In this version, we preserve the phase as we turn the chase mode on or off. We also add buttons at the bottom of the widget to show the composite color being generated, as well as the individual R, G, and B color channels. This is the circuit schematic we are using on the Pi Pico side.

RGB LED
Circuit Schematic for Connecting the RGB LED

This is the code we developed to run on the Pi Pico side. It is the server side.

You need to create this file, and save it as “secrets.py” in the lib folder of your raspberry pi Pico.

And finally, this is the client side program which will run on your PC.