How to push to ESP8266?

230 views
Skip to first unread message

Jannis Weber

unread,
Jun 13, 2021, 9:45:43 AM6/13/21
to pubsub-discuss
Hello there!

I'm quite new to MQTT/Pub/Sub and Core IoT. So please forgive me my limited skills.

I managed to connect my ESP8266 to Core IoT by using this repository on GitHub. After the first telemetry was publish I wanted to do a little bit more - just tiny steps to learn. My Goal was to switch the In-built LED off and on - depending on the message-content which is published to the corresponding topic. But none of the, via the Core-IoT website published, messages arrived. I guess it's because my subscriber is set to "pull" - but I want Pub/Sub to automatically push all new messages to the subscriber. So I switched to push but now I need an endpoint-URL. I'm a bit confused because I thought this whole system is based on MQTT but a endpoint-URL sounds more like HTTP. Do I really have to set up a endpoint-URL, and if yes, how can I do that for my ESP8266?

Long story short: I want to execute some actions, based on the message-content which should pushed by Pub/Sub to my device. How can I do that?

Thanks for reading and have a nice Weekend!

Kir Titievsky

unread,
Jun 14, 2021, 10:48:12 AM6/14/21
to Jannis Weber, pubsub-discuss
Jannis, Thanks for the question./ This looks like an IoT core question.  You'll probably get higher quality answers using either the stack overflow google-cloud-io tag or asking on the Cloud IoT channel. More here:  https://cloud.google.com/iot/docs/support/getting-support

--
You received this message because you are subscribed to the Google Groups "pubsub-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/3b0434fe-8429-47d1-9dae-9c1917a5a817n%40googlegroups.com.


--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub 

Samar Amara

unread,
Jun 15, 2021, 10:20:30 AM6/15/21
to pubsub-discuss

Hi,

First I want to clarify one thing here, this is  statement is misleading :

“But none of the, via the Core-IoT website published, messages arrived. I guess it's because my subscriber is set to "pull" - but I want Pub/Sub to automatically push all new messages to the subscriber. “

You are assuming that you need to switch to push in order for the esp8266 to get the messages from PubSub topic which is not right. One may use push or pull subscription to consume the message the difference between the two methods is who initiates the connection.

  • Push subscription --> PubSub initiate the connection to  send the message to the esp8622 (The  endpoint that you need to set)

  • Pull subscription --> The Esp8266 initial the connection to fetch the messages from PubSub (from a Pubsub endpoint)

So you better troubleshoot why the message was not pulled by the Esp8266 instead of changing  from pull to push.

Now for the this question:

" I'm a bit confused because I thought this whole system is based on MQTT but a endpoint-URL sounds more like HTTP. Do I really have to set up an endpoint-URL, and if yes, how can I do that for my ESP8266?"

The answer is yes, if you choose to use the  Push method then  PusSub needs to know where to send the messages ,  the endpoint is just an HTTP destination on the internet.

I think this git example does what you want  to achieve, you may get inspired by it [1] 

Finally as kir said you'll  get  more help and answers using the stack overflow google-cloud-io tag .

Jannis Weber

unread,
Jun 20, 2021, 9:11:56 AM6/20/21
to pubsub-discuss
Thank you guys!

Okay, I think I got this whole topic a bit wrong.. My ESP is fetching every command which is send via Google Core IoT. And it is publishing to the correct topics in pub/sub. My thought was that I can fetch the messages directly from Pub/Sub but the whole repository on GitHub is more about Core IoT instead of Pub/Sub.
Thank you!

Jannis Weber

unread,
Jun 20, 2021, 9:11:56 AM6/20/21
to pubsub-discuss
Sorry, I wanted to edit my post but its not published yet.
Is there a library for pubsub like the one for google iot? I tried to use the link above but I'm not able to connect to google pub/sub. I think the connection is refused because of the missing authentification. I found the github page for google pubsub but it's not for the ESP8266 (Arduino C++).
samar...@google.com schrieb am Dienstag, 15. Juni 2021 um 16:20:30 UTC+2:

Samar Amara

unread,
Jun 20, 2021, 3:24:08 PM6/20/21
to pubsub-discuss
Hi

You are right,   IOT core uses  Pubsub as explained here [1] but you  need to access your messages from the IOT core API where all your devices are managed (registration , authentication...ect )

Kir Titievsky

unread,
Jun 21, 2021, 9:36:06 AM6/21/21
to Jannis Weber, pubsub-discuss
Jannis, Check out the samples and documentation here for a Pub/Sub client library. Is that what you are looking for?

Jannis Weber

unread,
Jun 24, 2021, 4:43:58 AM6/24/21
to pubsub-discuss
Hi,
Thanks for your link!
Mostly yes, but the library is written in pure C++. As far as I know the NodeMCU can only run the Arduino-C++.
Can I connect Pub/Sub to Core IoT ? At the moment, Core IoT pushes published messages from the NodeMCU to Pub/Sub - but can I somehow do it the other way around?

Patricio Serrano Exposito

unread,
Aug 2, 2021, 7:42:08 PM8/2/21
to pubsub-discuss
Hello,
I'm not sure I fully understand your question. Pub/Sub should be already connected to Core IoT as it receives the messages it's generating from the NodeMCU you mentioned. If you mean sending messages from Pub/Sub to Core IoT, I don't think that is possible.
Reply all
Reply to author
Forward
0 new messages