/Motor-and-Sensor-Control-on-Arduino-Raspberry-Pi-and-ESP

This repository provides a comprehensive guide for controlling motors and sensors using Arduino, Raspberry Pi, and ESP boards. Step-by-step instructions, code samples, and detailed reports are included for each activity. Topics covered encompass serial communication, Python integration, GUI development, data storage, web accessibility, radio module

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Motor and Sensor Control on Arduino Raspberry Pi and ESP

GitHub contributors GitHub all releases GitHub GitHub deployments GitHub repo size GitHub Repo stars

Python C++ HTML5 CSS3 Arduino Raspberry Pi Matplotlib Flask Mosquitto Zigbee Amazon Alexa

README.it 🇮🇹


tps_GiorgioCitterio_UmbertoColombo_2022_2023

Table of Contents

For library installation on Linux systems.


Activity 1:

Activity Report 1: Serial Communication on Arduino.

Exploration of serial communication on Arduino.


Activity 2:

Activity Report 2: Serial Communication with Python and Arduino.

Communication between a Python application running on Windows and a sensor (potentiometer) and an actuator (L293D motor) connected to an Arduino.

To communicate with the serial port using Python, the serial library is used, which can be installed on Windows with the following command:

py -m pip install pyserial

Official documentation for the serial library.


Activity 3:

Activity Report 3: Communication with ISO/OSI Model Packet.

Reorganizing the message format exchanged between sensors/actuators and the Python application to work with an RF24 module, which has a payload of 32 bytes.

The struct library in Python is used to create these packets.

Official documentation for the [struct library

](https://docs.python.org/3/library/struct.html).


Activity 4:

Activity Report 4: Sensor/Actuator Control via GUI (Python).

Controlling a sensor and actuator through a GUI using Python. Three different programs for the actuator and three for the sensor.

The GUI (Graphical User Interface) is created using the tkinter library, which can be installed for most users with the following command:

py -m pip install tkinter

Official documentation for the tkinter library.

In the latest version of the sensor program, the matplotlib library is used to create a graph. It can be installed (on Windows) with the following command:

py -m pip install matplotlib

Official documentation for the matplotlib library.


Activity 5:

Activity Report 5: Storing Sensor Data in a JSON File.

Storing sensor data received in a JSON file for later use in client/server data exchange.

To write to a JSON file from Python, the json library, which is already available in Python, is used.

Official documentation for the json library.


Activity 7:

Activity Report 7: Making Sensor Data Available on the Web.

Making sensor data stored in a JSON file available on the web using Flask and tunneling.

To create the web server, the Flask library is used, which can be installed (on Windows) with the following command:

py -m pip install Flask

Official documentation for the Flask library.


Activity 8:

Activity Report 8: Motor Control via Web Browser.

Sending data from a web browser to a Flask application to control the motor.


Activity 9

Installation and program importation on Raspberry Pi.


Activity 10

Activity Report 10: Sending Packets via RF24 Radio Module.

How to send packets created in the "Layer 3 Packet - Serial" phase using the nRF24L01+ radio module.

To use the nRF24L01+ radio module, you need to import the RF24 library on Arduino.

Official documentation for the RF24 library. RF24 GitHub.


Activity 11

Activity Report 11: Motor and Sensor Control from Raspberry Pi.

How to display sensor data and control the motor through a Flask server running on Raspberry Pi, which communicates with the two Arduinos using the nRF24L01+ radio module.

To control the GPIO pins on Raspberry Pi, you need to install the pigpiod library using the following command:

sudo apt-get install pigpiod

To interface with the RF24 radio module from Python, you need to import the nrf24 library using the following command:

python3 -m pip install nrf24

Activity 12

Activity Report 12: Using MQTT for IoT Device Communication.

How to use the MQTT protocol to communicate between IoT devices, including through apps.

To use MQTT with Python, you need to import the paho-mqtt library using the following command:

python3 -m pip install paho-mqtt

Activity 13

Activity Report 13: Using MQTT with ESP8266.

How to use MQTT for message exchange between IoT devices directly connected to ESP8266 with WiFi connectivity.

You will need to add the board manager to the Arduino IDE to manage the ESP8266.

Tutorial for installation.


Activity 14

TODO: How to control the sensor and actuator using Alexa.


Activity 15

Activity Report 15: Using BLE for Environment Control.

How to use ESP32 to create devices that utilize the Bluetooth Low Energy (BLE) protocol for communication.

To control the ESP32 from the Arduino IDE, you will need to add the board manager as previously done for the ESP8266.