ItKindaWorks Forum

A forum for everything that Kinda Works YouTube.com/ItKindaWorks

You are not logged in.

Announcement

Welcome to the ItKindaWorks Forum

#1 2018-01-29 20:29:33

codymccomber
Member
Registered: 2018-01-29
Posts: 4

ESP OTA, Web config, with MQTT not working

Good afternoon, I hope you are well.

I was following your tutorial "New ESP Mini-Project (Web Config!!!) & Announcement" and it is really awesome. However, I am having an issue when I try to use your example sketch with MQTT.

I added two lines to the loadConfig function and added MQTTcallback function just to print out for debugging. And of course, configured the MQTT IP address and wifi settings. I am not getting any errors, but the MQTTcallback function never runs.

When I use your example OTA sketch and just set up the basic config and add some print lines to the MQTTcallback function then everything works great. So I know my MQTT server is good.

What am I doing wrong to get MQTT working with the example provided in the video?

void loadConfig(){
  //check for a good config file and start ESPHelper with the file stored on the ESP
  if(ESPHelperFS::begin()){
    Serial.println("Filesystem loaded - Loading Config");
    if(ESPHelperFS::validateConfig("/netConfig.json") == GOOD_CONFIG){
      Serial.println("Config loaded");
      delay(10);
      myESP.addSubscription("/deskLEDs");         //Code I added
      myESP.setMQTTCallback(MQTTcallback);      //Code I added
      myESP.begin("/netConfig.json");
    }
void MQTTcallback(char* topic, uint8_t* payload, unsigned int length) {
  //put mqtt callback code here
   //put mqtt callback code here
  char newPayload[50];
  memcpy(newPayload, payload, length);
  newPayload[length] = '\0';
  Serial.print("MQTT payload: ");
  Serial.println(newPayload);
}

Thanks so much for your help and creating this forum!!

Offline

#2 2018-01-29 20:38:40

codymccomber
Member
Registered: 2018-01-29
Posts: 4

Re: ESP OTA, Web config, with MQTT not working

Also, I tried just adding these three lines to the void setup function. No luck either.

  myESP.addSubscription("/deskLEDs");
  myESP.setMQTTCallback(MQTTcallback);
  myESP.begin();

Offline

#3 2018-01-29 22:00:05

cromer
Administrator
From: internet land
Registered: 2017-12-26
Posts: 89
Website

Re: ESP OTA, Web config, with MQTT not working

One thing that you could try is to uncomment the line in ESPHelperFS.h "// #define DEBUG". This will enable debug mode and allow the device to print out all of the values when it loads the config file. See if those values match up with your network/mqtt setup. If it prints out what you would expect then we can take a further look into things and see if there might be an issue in the library. But so far as I can tell in my own testing the FS stuff should work correctly.


Creator of ItKindaWorks

Offline

#4 2018-01-29 22:27:33

codymccomber
Member
Registered: 2018-01-29
Posts: 4

Re: ESP OTA, Web config, with MQTT not working

Good stuff, I uncommented the DEBUG line and it turns out when I configured the MQTT IP in homeNet it is possibly getting overridden. The debug printed out "YOUR MQTT-IP" even though I had set it.

netInfo homeNet = { .mqttHost = "192.168.1.174",     //can be blank if not using MQTT
...

Still prints out "QTT Server: YOUR MQTT-IP."

When I went back to the web configure page and set the MQTT IP in there it properly updated and now works great!

Thanks for the help, you rock!

Last edited by codymccomber (2018-01-29 22:28:20)

Offline

#5 2018-01-29 22:44:30

cromer
Administrator
From: internet land
Registered: 2017-12-26
Posts: 89
Website

Re: ESP OTA, Web config, with MQTT not working

Glad you got it all sorted. I'll have to take a look at why it was getting overridden. Did you upload the original (default values) before uploading the sketch with your network values? Because that might have done it - the info in homeNet will only be used if there isn't any config file to load but if you previously uploaded this sketch with the default values then it would use those.


Creator of ItKindaWorks

Offline

#6 2018-01-29 23:17:14

codymccomber
Member
Registered: 2018-01-29
Posts: 4

Re: ESP OTA, Web config, with MQTT not working

I think that may have happened.

I went ahead and dumped an empty sketch to the board, then tried again and it worked without issue!

Offline

#7 2018-01-29 23:24:39

cromer
Administrator
From: internet land
Registered: 2017-12-26
Posts: 89
Website

Re: ESP OTA, Web config, with MQTT not working

Well theres that problem solved then.

Happy hacking!


Creator of ItKindaWorks

Offline

#8 2018-02-28 22:16:47

Sparky056
Member
Registered: 2018-02-28
Posts: 12

Re: ESP OTA, Web config, with MQTT not working

I also have tried to load an empty sketch to my esp8266 but I does not work.
I did set up the data to my home network

I did a command prompt to python. it working with v2.7

Offline

#9 2018-03-23 03:22:56

cromer
Administrator
From: internet land
Registered: 2017-12-26
Posts: 89
Website

Re: ESP OTA, Web config, with MQTT not working

If you are still having issues after loading an empty sketch you might try completely clearing the flash all together. Try following this tutorial and see if that helps.

http://www.pratikpanda.com/completely-f … sh-memory/


Creator of ItKindaWorks

Offline

Board footer

Powered by FluxBB