Mosquitto working but won't load devices

It doesn’t matter which MQTT broker you use as long as all devices on your net use the same one.
Besides, you already demonstrated that your broker is working:

I am really suspecting your client.publish.
Try adding this to your loop after the test client.publish I described before:

Serial.println(temperature_topic_small, String(temp1).c_str())

All you need for client.publish is topic and data, both strings. Delete the retained flag.

ok I edit the sketch and I hope I’ll get there tomorrow to reset the esp to upload the sketch.

Thank you so much for the time and the help!

Are you sure you’re using the correct PubSubClient library in the ArdionoIDE?

There are two of them - one by Nick O’Leary and other by Imroy - and they use two different formats in the publish command:

imroy uses this format:

mqttClient.publish(MQTT::Publish(temperature_fahrenheit_topic, String(f).c_str()).set_retain().set_qos(1));

O’Leary uses this format:

client.publish(distance_CM_topic, String(distance_CM).c_str(), true);

I don’t know if they are interchangeable but I think read somewhere a long time ago that they weren’t.

If all else fails at least it’s something to look into.

I’m not sure about anything at this point.
I’m trying anything and everything you guys suggest.

Maybe soon I’ll be able to get there and upload the sketch so we’ll know if it’s the pulish call or we’ll continue looking.

it used to work with what you guys see in my sketch post. now it doesn’t.

anyways thank you for the pointer

Ok so I managed to update the sketch but it still work, I see nothing coming on the bus, and of course I don’t see it on the HASS page.

The interesting thing is that I’ve put the serial print after the publish and I can see the print on the monitor. so it passed the publish line with no visible problem.

what should I do now?

I even restarted the broker and I saw that the node disconnected and after a minute it connected again.

I won’t be able to upload any sketches until after the weekend since I won’t be near the esp.

Again thank you everybody for trying to help me.

So, show us what it printed.

I copied it from the monitor:

Temperature : 21.81 | Temprature 2 : 22.44
sensor/fats_temperature_small21.81
Temperature : 21.87 | Temprature 2 : 22.44
sensor/fats_temperature_small21.87
Temperature : 21.87 | Temprature 2 : 22.50
sensor/fats_temperature_small21.87
Temperature : 21.81 | Temprature 2 : 22.44
sensor/fats_temperature_small21.81
Temperature : 21.87 | Temprature 2 : 22.50
sensor/fats_temperature_small21.87

I made a mistake and put the small instead of the big but it doesn’t matter.

Why did you blank this out? This is important info to have… Is it the IP address of your BROKER? The IP of the HASSIO machine?

o.O Is your device client id actually ESP8266Client? You set it to something else earlier in the sketch…

In the SERIAL do you actually see the MQTT Connection messages? “Attempting MQTT connection…” and “connected”?

they are the same one, both the broker and the hassio sit on the same raspberry pi.
and for now since it’s the only one yeah this is the ID I gave it, I’ll change it once everything will work again.
I have few more changes I need to do in the code there but I wanted to make it to work again before finalizing the sketch.

at the start when the esp boots up yeah.
when I restart the broker I can see it as well.

I agree that knowing what he is using for the broker IP is important to diagnose, but the OP verified “yes” earlier to this question and he also said he was seeing test data in Home Assistant that was published from an MQTT tool. So I am not worried that his MQTT broker is connecting and working.

OP- your local IP addresses are meaningless to a hacker; there’s no reason to hide them. (If a hacker got this far past your router, NAT and firewall, your entire local network is already compromised.) The only reason that passwords should remain secret is because people tend to use the same password or a variant of it- making it easier to hack other parts of your system.

None of that has anything to do with the sketch actually connecting to the broker.

Thanks for jumping in to help. This is a real head-scratcher.
Earlier, I had him do this:

So this verified that Client.publish() is connecting to the broker and working in the sketch. I then asked to show what was being given to client.publish():

And this is the result:

Which is what I would expect (the println has no delimiter between the parameters- no problem)

One more test,
please verify that when you send discrete data like this, you do see it in Home Assistant?
client.publish("sensor/fats_temperature_big", "99");

Let’s break down the client.publish line.
client.publish("sensor/fats_temperature_big", String(temp1).c_str());

Compile and test this as before.

Then change it around:
client.publish(temperature_topic_big, "99");

What this does is test each parameter separately.

If this also works, then I am really puzzled.
Is there a reason that you can’t just flash Tasmota and stop worrying how the gears inside the machine work?

I’m wondering if the String is the problem, just saw this post from Steve a little over a year ago

cyn, Good catch:

SagiRo, Try changing:
#define temperature_topic_big “sensor/fats_temperature_big”

to:
const char *temperature_topic_big = “sensor/fats_temperature_big”;

But, shouldn’t he be getting compile errors (like I was in that year old post) from the former if this were his problem?

(BTW- Because I am not a seasoned C programmer is precisely the reason that I switched my ESP-based nodes to Tasmota. Life with Home Assistant has been so much easier.)

BTW, SagiRo.

Here’s a trick to not have to put “if ( debug )” around your conditional Serial.print statements:

#define DEBUG true  //set to true for debug output, false for no debug ouput
#define Serial if(DEBUG)Serial

I’ll try the later suggestion tomorrow, I’ll change it now but I’ll upload the sketch tomorrow.

I’m doing it this way cause that is what I know. I just started getting deep into this and then the hassbian broke on me.

Also thanks for the tip I’ll use that!
And again thank you everybody for helping me with this.

ok so it doesn’t work, I tried doing all the options @stevemann suggested. :frowning:

I’m pretty sure now that the publish call isn’t good. not sure why tho.

Any other suggestions? :frowning:

Have you tried a different version of the pubsub library?

no I haven’t.
I’m not so sure it’s the code anymore…

I uploaded a simple sketch from the examples and it looks like that doesn’t work either… so I looked over the broker side…
does anyone have something they can post on the setting on the hassio broker side? just to understand that I’m working on the right settings?