Relay espbased project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
balhau 4632fe9883 Update 'src/main.cpp' 8 months ago
docker Initial Commit 9 months ago
include Initial Commit 9 months ago
lib Initial Commit 9 months ago
src Update 'src/main.cpp' 8 months ago
test Initial Commit 9 months ago
.gitignore Initial Commit 9 months ago
README.md More on doc 9 months ago
history.txt Initial Commit 9 months ago
platformio.ini Initial Commit 9 months ago

README.md

ESP Relay

What

This repo holds the code needed to program an relay controlled by an esp microcontroller.

The code is developed using the PlatformIO framework.

Architecture

Arquitecture

To run

To be able to run you must fill the file consts.h with the following contents


#ifndef _CONSTS_H
#define _CONSTS_H

#define MQTT_PORT <mqtt_port>
#define MQTT_SERVER "<mqtt_hostname>"
#define WIFI_SSID "<wifi_ssid>"
#define WIFI_PASSWORD "<wifi_password>"
#define MQTT_TOPIC_COMMANDS "<mqtt_topic_commands>"
#define MQTT_TOPIC_RESPONSES "<mqtt_topic_responses>"

#define DELAY_STEP 1000
#define RECONNECT_DELAY 2000
#define SERIAL_FREQ 115200

#endif

After the custom configuration entries are setup you must install platformIO to be able to compile the code and upload into the esp32


# Download libraries defined in platformio.ini
pio lib install

# Check the libraries were installed

pio lib list

# Compile the code
pio run

# Upload the code 
pio run -t upload

# Monitor via serial port
pio run -t monitor

You need to follow the documentation and connect the FTDI Controller (I personally use this one) to the onboard esp.

If all went ok you should be able to see logs via dmesg


[  +0,003234] ftdi_sio 2-2:1.0: FTDI USB Serial Device converter detected
[  +0,000068] usb 2-2: Detected FT232RL
[  +0,001370] usb 2-2: FTDI USB Serial Device converter now attached to ttyUSB0

Before upload the code into the microcontroller we need to ensure that we have a mqtt broker running. For this we run the command docker/start-mosquitto.sh.