ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

torntrousers
Posts: 4
Joined: Mon Dec 21, 2015 9:30 am

ESP32 with Arduino and MQTT publishing to the Watson IoT Platform

Postby torntrousers » Thu Dec 08, 2016 8:57 am

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

ccfoo242
Posts: 1
Joined: Thu Dec 08, 2016 7:55 pm

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

Postby ccfoo242 » Thu Dec 08, 2016 7:56 pm

Thanks! Exactly what I came here looking for. My adafruit dev board arrived today and wanted to get it running with something.

JanJansen47
Posts: 8
Joined: Sun Jan 01, 2017 9:21 pm

esp32 espressif code for an mqtt client

Postby JanJansen47 » Thu Jan 05, 2017 7:45 pm

Mongoose and Arduino publish code for an mqtt client.
Is there "working"or prototype code for a "native" espressif mqtt client?
Jan Jansen
Eindhoven The Netherlands

ESP_Angus
Posts: 218
Joined: Sun May 08, 2016 4:11 am

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

Postby ESP_Angus » Thu Jan 05, 2017 10:45 pm

Hi Jan,

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

Angus

JanJansen47
Posts: 8
Joined: Sun Jan 01, 2017 9:21 pm

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

Postby JanJansen47 » Fri Jan 06, 2017 4:21 pm

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
Jan Jansen
Eindhoven The Netherlands

User avatar
kolban
Posts: 504
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

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

Postby kolban » Fri Jan 06, 2017 5:29 pm

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?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

JanJansen47
Posts: 8
Joined: Sun Jan 01, 2017 9:21 pm

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

Postby JanJansen47 » Sat Jan 07, 2017 8:05 am

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. )
Jan Jansen
Eindhoven The Netherlands

JanJansen47
Posts: 8
Joined: Sun Jan 01, 2017 9:21 pm

ESP32 with native MQTT client

Postby JanJansen47 » Sat Jan 07, 2017 8:12 am

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!
Jan Jansen
Eindhoven The Netherlands

JanJansen47
Posts: 8
Joined: Sun Jan 01, 2017 9:21 pm

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

Postby JanJansen47 » Sat Jan 07, 2017 6:54 pm

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!
Jan Jansen
Eindhoven The Netherlands

JanJansen47
Posts: 8
Joined: Sun Jan 01, 2017 9:21 pm

esp32 RTOS Paho code for an mqtt client

Postby JanJansen47 » Mon Jan 09, 2017 9:52 pm

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).
Jan Jansen
Eindhoven The Netherlands

Who is online

Users browsing this forum: No registered users and 1 guest