Back to Browse

Connect ESP32/ESP8266 & C# .NET Core Using MQTT - Easy Tutorial

7.9K views
Jan 27, 2024
10:07

Here's how to quickly connect a Windows PC C# application to an ESP32, ESP32 CAM or ESP8266 microcontroller over wifi. The two connected devices will communicate with each other using the MQTT protocol. This is a lightweight Internet of Things (IoT) protocol and it's supported by both C# and the ESP32 and ESP8266 controllers. Because it uses a standard wifi connection there doesn't need to be a physical cable connection between the PC and the microcontroller device. This video largely demonstrates how to get the two devices communicating successfully. In particular I cover what libraries to use, as well as troubleshooting the major issues I had in getting MQTT working on my own home wifi network (including which IP address to connect to and Windows Defender Firewall issues). If you want to send and receive anything useful then watch my other MQTT videos. 00:00 - Introduction 01:08 - Server Code for C# .NET Core 04:20 - Client Code for ESP32/ESP8266 07:18 - Troubleshooting Connectivity Issues 08:47 - MQTT Test Apps Server code (C# .NET Core): https://github.com/dotnet/MQTTnet (watch video for more info) Client code: https://www.brettb.com/coding-tutorials/esp32-mqtt-tutorial/ MQTT test application: https://mqttx.app/downloads MyMQTT for Android devices: find it in the Play Store MQTT (MQ Telemetry Transport) is a client-server model. The server is called a broker and multiple clients may connect to it. In this example I've set the PC up as the server, and an ESP32 CAM device as the client using the PubSubClient library. You might think it would be better the other way round. However, it's much easier to get microcontrollers running as the client.

Download

1 formats

Video Formats

360pmp417.2 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Connect ESP32/ESP8266 & C# .NET Core Using MQTT - Easy Tutorial | NatokHD