Skip to content

Jakub6/RPI_ESP32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPI_ESP32

Sensors control with Raspberry Pi 4 and ESP-32 with Micropython

RAPBERRY PI: (setting username and password)

sudo apt install -y mosquitto mosquitto-clients

sudo systemctl enable mosquitto.service

To subscribe to an MQTT topic

mosquitto_sub -d -t testTopic

To publish

mosquitto_pub -d -t testTopic -m "Hello world!"

ESP32

from umqtt.robust import MQTTClient

client = MQTTClient("esp32-01", "192.168.1.171")

client.connect()

client.publish(b"testTopic", "msg")

def sub_cb(topic, msg):

print((topic, msg))

if topic == b'testTopic' and msg == b'on':

print('ESP received command ON')

client = MQTTClient("esp32-01", "192.168.1.171")

client.connect()

About

Sensors control with Raspberry Pi 4 and ESP-32 with Micropython

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published