Tag Archives: WiFi

Controlling Brightness of Arduino LED Remotely Using PyQt and WiFi

In this lesson we will use PyQt5, UDP and WiFi to control the brightness of an Arduino LED circuit remotely. The PyQt generates a constantly updating sin wave, which it plots on a PyQt graph, and then transfers the brightness in real time to the arduino project. This lesson teaches many important skills including UDP, WiFi, PyQt5, Python, Arduino and LEDs.

When using the breadvolt, or any battery power supply on a breadboard project, do not turn the power supply on while the Arduino is connected to USB, as you could generate voltage conflicts. It is an either or. If the USB is connected, the power supply should be OFF. The schematic for the arduino circuit is shown below:

Schematic of our Arduino Uno R4 Wifi connected to an RGB LED

In the video, we develop code for the server, on the arduino, and the client, running in Python on the desktop. We present the code below for your convenience.

This is the Server code for the Arduino:

You will need to open a new tab, and save the following code as “secrets.h” with the program above.

On the Python side, this is the Client code:

 

PyQt5 Project to Control Arduino RGB LED Over WiFi

In this video lesson we add slider bars to our PyQt Widget allowing us to control the color of an RGB LED over WiFi. When using the breadvolt, or any battery power supply on a breadboard project, do not turn the power supply on while the Arduino is connected to USB, as you could generate voltage conflicts. It is an either or. If the USB is connected, the power supply should be OFF. Or if you are going to connect the USB, first turn off the power supply. The schematic for the project circuit is shown below:

Schematic of our Arduino Uno R4 Wifi connected to an RGB LED

The server side code developed in the video is presented below:

Remember to add the secrets.h file by adding a tab to the project, as explained in the video.

And then on the client side, we have the following code:

 

PyQt5 Graphical User Interface for Control of Arduino Project Over WiFi

In this video lesson we create a client server connection between Python running on your desktop computer, and your Arduino project. We show how to make the connection over WiFi, and how to pass data and commands back and forth between your Arduino and your desktop computer. We then show how to build an attractive Graphical User Interface in PyQt5 to control your arduino project from your desktop wirelessly. For this simple example, we will control an RBG LED from the GUI.

This is the circuit schematic of the Arduino;

Schematic of our Arduino Uno R4 Wifi connected to an RGB LED

When using the breadvolt, or any battery power supply on a breadboard project, do not turn the power supply on while the Raspberry Pi Pico is connected to USB, as you could generate voltage conflicts. It is an either or. If the USB is connected, the power supply should be OFF. Or if you are going to connect the USB, first turn off the power supply.

For your convenience we include the code developed in the video below. This first program is the server side program, for the arduino:

You will need to save your WiFi name and password in your ‘secrets.h’ file, which you create in a new tab, as explained in the video.

Now, for the client side, this is the Python code for creating the Graphical User Interface using PyQt5.

 

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.