/* SimpleMQTTClient.ino The purpose of this exemple is to illustrate a simple handling of MQTT and Wifi connection. Once it connects successfully to a Wifi network and a MQTT broker, it subscribe to a topic and send a message to it. It will also send a message delayed 5 seconds later. */ #include "EspMQTTClient.h" EspMQTTClient client( "SpeedPanda98", "12345678", "192.168.43.23", // MQTT Broker server ip "omniwheel-controller", // Client name that uniquely identify your device 1883 // The MQTT port, default to 1883. this line can be omitted ); void setup() { Serial.begin(115200); } // This function is called once everything is connected (Wifi and MQTT) // WARNING : YOU MUST IMPLEMENT IT IF YOU USE EspMQTTClient void onConnectionEstablished() { // Serial.println("OK"); client.subscribe("omniwheel_controller/location", [](const String & payload) { Serial.println(payload); // send to microcontroller }); } void loop() { client.loop(); if (Serial.available()){ while (Serial.available()) { Serial.read(); // clear buffer client.publish("attiny1614/button", "PRESSED"); } } }