Page 1 of 1

ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Thu Dec 08, 2016 8:57 am
by torntrousers
Here's a quick guide and sample code to have an ESP32 talking to the Watson IoT Platform - https://developer.ibm.com/recipes/tutor ... t-platform

Re: ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Thu Dec 08, 2016 7:56 pm
by ccfoo242
Thanks! Exactly what I came here looking for. My adafruit dev board arrived today and wanted to get it running with something.

esp32 espressif code for an mqtt client

Posted: Thu Jan 05, 2017 7:45 pm
by JanJansen47
Mongoose and Arduino publish code for an mqtt client.
Is there "working"or prototype code for a "native" espressif mqtt client?

Re: ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Thu Jan 05, 2017 10:45 pm
by ESP_Angus
Hi Jan,

Check out espmqtt: https://github.com/tuanpmt/espmqtt

Angus

Re: ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Fri Jan 06, 2017 4:21 pm
by JanJansen47
Hi torntrousers,

Yes, tested the esp32 " arduino" and the mongoose solutions. These solutions both work but I want to use the espressif / eclipse IDE.
(Both also work on the cheap esp8266)

I hoped someone has already done the groundwork for "Writing non ESP32 MQTT clients" as described on page 259 of Kolban's book on the esp32

Re: ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Fri Jan 06, 2017 5:29 pm
by kolban
Howdy Jan,
I'm not sure I'm following you ... as you realize, MQTT is a protocol for publish and subscribe. Are you asking about the ESP32 being an MQTT client, being an MQTT broker or the partners to which the ESP32 (using MQTT) might be interacting with?

Re: ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Sat Jan 07, 2017 8:05 am
by JanJansen47
Hello Kolban,

Started the thread with the topic "MQTT client". I investigate whether I can replace an existing MQTT client ( Raspberry / java / pi4j / PaHo /display) and whether the esp32 RTOS helps me to develop time critical applications at end nodes. ( I tested the Mongoose MQTT client and the "new" arduino MQTT client for the esp32. And indeed it works. )

ESP32 with native MQTT client

Posted: Sat Jan 07, 2017 8:12 am
by JanJansen47
Hello Angus,

Yes I looked into your code and I will give it a try to translate to the espressif ide-idf approach.
I appreciate your efforts!

Re: ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Posted: Sat Jan 07, 2017 6:54 pm
by JanJansen47
Hello Angus,

In mqtt.h void mqtt_stop() is missing. After adding I can build and flash and see the /test topic in my MQTTfx client.

Thanks, this is great!

esp32 RTOS Paho code for an mqtt client

Posted: Mon Jan 09, 2017 9:52 pm
by JanJansen47
The Paho MQTT client was ported to the RTOS esp8266 platform.

Is this the same code as the MQTT client from Angus / Tuan?

See the link below:
http://www.ba0sh1.com/2015/08/30/esp8266-mqtt-rtos/

In the recent Maker Faire I demonstrated an ESP8266 MQTT VFD clock. Some readers had wrote to ask for the soure code. Because the project was builtup within only 2 days, the actual source code is more or less of spaghette type. However the underlying MQTT client may be useful to someone who likes the RTOS SDK.

If you search MQTT and ESP8266 on the intraweb, most likely all hits can be traced back to the great work done by TuanPM. However Tuan’s code is based on Espressif’s NON-OS SDK. There has been some great debates about embedded programming with-or-without an OS. To me programming with OS vs NON-OS is like programming with C vs Assembly. I like programming in C, so I wrote a new MQTT client for Espressif’s RTOS SDK.

The source code is published at https://github.com/baoshi/ESP-RTOS-Paho

Here are some notes:

The code is based on the Eclipse Paho project, specifically the embedded C client.
Socket-level APIs used, the code is thread-safe.
Many error handlings were added to the original Paho client, including time-out for most of the network functions. These are designed to work with an RTOS to support automatic error correction at various abused conditions.
I’m compiling using the “Unofficial ESP8266 DevKit“. Other toolchain such as esp-open-sdk can be used as well (adjust pathes in Makefile).