First version of a wifi pipe organ controller! ...but bugs I need to fix: if you choose columns to be > 8 the UI crashes, and it seems that the msg on the receiver needs to be emptied when receiving a new one (?). Soon I'll upload a new version :)
This project allows users to control the opening and closing of a solenoid valve which manages the airflow into pipes. The system is comprised of a Python-based user interface (UI), an ESP32 connected via serial communication (sender), and additional ESP32 devices (receivers) that receive data through ESP-NOW (WiFi).
psssst... ---DETECT SERIAL PORT--- was a solution implemented by: tfeldmann on StackOverflow. Thanks!!!
The Python script provides a UI for the user to create a grid representing the solenoid valve states (open/close). Users can input the number of rows (pipes) and columns (beats) for the grid, as well as a tempo value that affects the timing of solenoid valve actions.
Once the user has configured the grid and tempo, the Python script constructs an Open Sound Control (OSC) message containing the grid and tempo data. This message is sent over a serial connection to the first ESP32 device when the user presses "SAVE". The first ESP32 parses the incoming OSC message and forwards the parsed data to the other ESP32 devices using the ESP-NOW protocol.
Each receiving ESP32 device processes the incoming data and controls the solenoid valve's state based on the received data. The valve states are managed according to the user-defined grid and tempo values.
- Python UI receives user input (grid configuration and tempo).
- Python script constructs an OSC message with grid and tempo data.
- OSC message is sent over a serial connection to the first ESP32.
- First ESP32 parses the OSC message and forwards data to other ESP32 devices using ESP-NOW.
- Receiving ESP32 devices control the solenoid valve based on received data (grid configuration and tempo).
Through the UI, users can change with a grid, the solenoid valve states (open/close) and input a tempo value. The grid consists of black and white cells, where black represents an open state and white represents a closed state. Users can toggle cell states by clicking on them. Once the desired grid configuration and tempo are set, the user can click the "Save" button to send the data to the ESP32 devices and control the solenoid valve accordingly.
To build the pipe organ controller system, you will need the following components:
- Python installed (preferably version 3.6 or later)
- Two or more ESP32 microcontrollers
- Step-up converter
- Relay Module
- Solenoid valves for controlling airflow into the pipe organ
- USB cable for connecting the sending ESP32 to the computer (for serial communication)
- Jumper wires
- A 5v power supply for the ESP32 connected to the solenoid
- Set up the Python environment: Install the required Python libraries for the project.
- Flash the ESP32 devices: Upload the provided ESP32 code to each of your ESP32 microcontrollers using the Arduino IDE or a similar tool. Make sure to update the MAC addresses in the "ESP32 connected via Serial" code to match the addresses of your receiving ESP32 devices. Also, update the peerMacA, peerMacB, etc., in the "ESP32 receivers" code to match the addresses of your receiving ESP32 devices.
- Connect the ESP32 devices: Connect the first ESP32 to your computer using a USB cable. This will allow serial communication between the Python script and the ESP32. Connect the receiving ESP32 devices -make sure to connect the appropriate GPIO pin (as specified in the "ESP32 receivers" code) to the control pin of the solenoid valve (follow the diagram on the PDF)
- Run the Python script: Execute the provided Python script on your computer. This will open the user interface, allowing you to create a grid, set a tempo, and control the solenoid valve.
- Configure and control the system: Use the UI to set the desired grid configuration and tempo. Click the "Save" button to send the data to the ESP32 devices and control the solenoid valve accordingly.
- Python Script: The Python script runs on a computer and provides a user interface for creating a grid, setting a tempo, and controlling the solenoid valve.
- Serial Communication: The Python script communicates with the first ESP32 (ESP32 #1) connected via USB using serial communication. The script sends OSC messages containing grid data and tempo information to the ESP32.
- ESP32 #1 (Connected): This ESP32 receives the OSC messages from the Python script via serial communication. It then sends the received data to the receiving ESP32 devices (ESP32 #2) using ESP-NOW communication.
- ESP-NOW Communication: The first ESP32 communicates with the receiving ESP32 devices (ESP32 #2) wirelessly using the ESP-NOW protocol. It sends the grid data and tempo information to the receivers.
- ESP32 #2 (Receiver): The receiving ESP32 devices receive the data sent by ESP32 #1 and control the solenoid valve accordingly.
- Solenoid Valve: The solenoid valve controls the airflow into the pipe organ based on the signals received from the receiving ESP32 devices.
- Power Supply: The ESP32 #2 is powered with a 5V USB cable.
- ESP32 #2 (Receiver): This ESP32 receives data wirelessly from the first ESP32 (Connected to the computer via serial). It is connected to a relay module and a step-up converter.
- Relay Module: The relay module is connected to the ESP32 using GND, VCC, and IO22 pins. It controls the opening and closing of the solenoid valve. One output is connected to the step-up converter and the other to the solenoid.
- Step-Up Converter: The step-up converter is connected to the 3.3V and GND pins of the ESP32. It transforms the 3.3V coming from the ESP32 to 12V+. The positive output (Out+) is connected to the relay, and the negative output (Out-) is connected to the solenoid valve.
- Solenoid Valve: The solenoid valve is connected to the relay module and the step-up converter. One output from the relay is connected to the Out+ of the step-up converter, and the other output is connected to the solenoid valve. The Out- from the step-up converter is connected to the solenoid valve.
Hope it is clear enough! write me if you want some pictures to see how everything is connected or help to assemble it :)