Scenario: Existing project: read soft serial then do http post

New project: MQTT player from other (MrDIY / MrDIY Audio Notifier · GitLab)

Objective: Combine together (Result: successful )

Issue: When read serial do http post, after http.end(). MQTT client disconnect. It taks above 10 secs to reconnect.

The only way I found is just a workaround to add ESP.restart(); after each http post.

But that's stupid. I have spend more than 10 hours to fix this issue. Any one can help?

Eg code:

void loop() {
  if (!mqttClient.connected()) {

  if (mySerial.available() > 0)  //Checks is there any data in buffer
    receive_data = String(receive_data) + String(char(mySerial.read()));

    if (String(receive_data).indexOf("lighton") >= 0) {
      receive_data = "";
      http.begin(client, switchon);
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Authorization", auth);
      int httpCode = http.POST("{\"entity_id\": \"switch.sonoff_guest_room\"}");
      Serial.printf("[http] GET... code: %d\n", httpCode);
  • Please add URL to things you refers to!
    – MatsK
    Oct 22 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.