PIR-motion sensor with mongoose example


#1

Hello, I’m unable to publish my activity to losant. I’m getting an error- "Publish Error - Not allowed to publish to /losant/esp8266"esp8266 is my device name. There are frequent connections and disconnections happening. I’m following the tutorial of “https://www.losant.com/blog/detecting-motion-using-a-pir-sensor-esp8266-and-mongoose-os”. Can you please help me with this issue?


#2

Topics under ‘/losant’ are restricted to topics that are named in very specific ways - they have meaning for the Losant platform. In your case, it sounds like what you actually want to be publishing to is ‘/losant/your_losant_device_id/state’, but instead you are using your device name. You can also freely publish on any topic that does not start with ‘/losant’. You can read more about how Losant uses MQTT topics here.

Because MQTT has very little in the way of returning errors to clients, when a client publishes to a topic that is not permitted, the only thing the MQTT broker can do is disconnect the client - which, since you are publishing to an invalid topic, is the source of your frequent connections and disconnections. Once you start publishing to the correct topics, you connection should become more stable.

Hope that helps!