Switch to desktop version  
Getting Started with MQTT on your Flexy using BASIC - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html)
+--- Thread: Getting Started with MQTT on your Flexy using BASIC (/thread-473.html)

Pages: 1 2


Getting Started with MQTT on your Flexy using BASIC - simon - 20-12-2017

Hi Guys,

If you want to test the MQTT client feature (through BASIC or JAVA) with your Flexy (running the firmware 12.2or above), I suggest you first read the Programming Reference Guide (https://developer.ewon.biz/system/files_force/rg-0006-01-en-programming-reference-guide.pdf?download=1), page 58 and then you try to connect your Flexy to the MQTT broker of our test server : https://ewonsupport.biz/mqtt.  There is an example available that you just need to copy/paste to your Flexy.

Another easy platform to test, but here a real IOT plateform, is https://thingspeak.com/.
You can find the MQTT API tutorial here : https://nl.mathworks.com/help/thingspeak/mqtt-api.html
Here is an example of BASIC script :

Code:
Mqtt "Open","MDILHycQNddsdsgdHhEGDhg","mqtt3.thingspeak.com"
Mqtt "SetParam","port","1883"
Mqtt "SetParam","username","MDILHycQNddsdsgdHhEGDhg"
Mqtt "SetParam","password","3yWQSlLdDdfA4bDsnUKD"
Mqtt "SetParam","cleansession","1"
Mqtt "SetParam","log","1"
Mqtt "Connect" Tset 1,5
Ontimer 1,"goto MqttPublish"
End
MqttPublish:
Mqtt "Publish","channels/2087776/publish/fields/field1",STR$ MyTag@,0,0
End



Bye!

Simon


RE: Getting Started with MQTT on your Flexy. - rcerveto - 20-02-2018

(20-12-2017, 05:44 PM)Simon Wrote: Hi Guys,

If you want to test the MQTT client feature (through BASIC or JAVA) with your Flexy (running the firmware 12.2or above), I suggest you first read the Programming Reference Guide (https://developer.ewon.biz/system/files_force/rg-0006-01-en-programming-reference-guide.pdf?download=1), page 58 and then you try to connect your Flexy to the MQTT broker of our test server : https://ewonsupport.biz/mqtt.  There is an example available that you just need to copy/paste to your Flexy.

Another easy platform to test, but here a real IOT plateform, is https://thingspeak.com/.
You can find the MQTT API tutorial here : https://nl.mathworks.com/help/thingspeak/mqtt-api.html
Here is an example of BASIC script :

Code:
Mqtt "Open","ewon","mqtt.thingspeak.com"
Mqtt "SetParam","Port","1883"
Mqtt "Connect"

Tset 1,5
Ontimer 1,"goto MqttPublish"
End
MqttPublish:
  Mqtt "Publish","channels/126155/publish/DWT0GL25GCMVQQ","field1=12&Status=MQTTPUBLISH",0,0
  TSET 1,0
  Mqtt "Close"
  HALT
End



Bye!

Simon

Hi Simon,

Great BASIC example!!.

Is there an example in the documentation in java language?.

Thanks.


RE: Getting Started with MQTT on your Flexy. - simon - 21-02-2018

See https://techforum.ewon.biz/thread-527.html


RE: Getting Started with MQTT on your Flexy. - rcerveto - 23-02-2018

(21-02-2018, 11:24 PM)Simon Wrote: See https://techforum.ewon.biz/thread-527.html

Thanks Simon.


RE: Getting Started with MQTT on your Flexy. - acs-sup - 20-03-2018

(20-12-2017, 05:44 PM)Simon Wrote: Hi Guys,

If you want to test the MQTT client feature (through BASIC or JAVA) with your Flexy (running the firmware 12.2or above), I suggest you first read the Programming Reference Guide (https://developer.ewon.biz/system/files_force/rg-0006-01-en-programming-reference-guide.pdf?download=1), page 58 and then you try to connect your Flexy to the MQTT broker of our test server : https://ewonsupport.biz/mqtt.  There is an example available that you just need to copy/paste to your Flexy.

Another easy platform to test, but here a real IOT plateform, is https://thingspeak.com/.
You can find the MQTT API tutorial here : https://nl.mathworks.com/help/thingspeak/mqtt-api.html
Here is an example of BASIC script :

Code:
Mqtt "Open","ewon","mqtt.thingspeak.com"
Mqtt "SetParam","Port","1883"
Mqtt "Connect"

Tset 1,5
Ontimer 1,"goto MqttPublish"
End
MqttPublish:
  Mqtt "Publish","channels/126155/publish/DWT0GL25GCMVQQ","field1=12&Status=MQTTPUBLISH",0,0
  TSET 1,0
  Mqtt "Close"
  HALT
End



Bye!

Simon

Great Job Simon.
And thank you for sharing.

I have an application using MQTT for exchanging Data.
However, my MQTT payloads (from IoT LoRa devices) are quite complicated.
For example :

RxMode=Broadcast, QoS=-89Dbm, Congestion=0x08, RTC=18-03-20 15:12:31, NMac=01:38:70:E1, Rep1 NONE, Rep2 NONE, ServiceType=0x00, ProductType=0x0006, payload=400F73E9DE08020002380B8101000001DC01DC750400010001013881C1

As you see, it is ASCII formatted text. (with RTC, signal information, addresses, and a structured payload)
Do you have any solution to parse such ASCII text with BASIC ?

Thank you for your ideas.

Karim


RE: Getting Started with MQTT on your Flexy. - simon - 23-03-2018

Karim,

Check that https://techforum.ewon.biz/thread-418.html, it may be helpful.

Simon


RE: Getting Started with MQTT on your Flexy. - acs-sup - 23-03-2018

(23-03-2018, 07:02 PM)Simon Wrote: Karim,

Check that https://techforum.ewon.biz/thread-418.html, it may be helpful.

Simon

Thank you Simon.

Should make the stuff.

Thank you.

Karim


RE: Getting Started with MQTT on your Flexy using BASIC - kema - 02-05-2018

Hi Simon

Thank you for your BASIC examples.
I successfully uploaded text messages from my Flexy to the MQTT test server.
Looking forward seeing you next week.

Ken


RE: Getting Started with MQTT on your Flexy using BASIC - Chee Ho - 10-01-2019

Hello, may I know is the MQTT Test Server currently under maintenance?
I can't connect to it, and the website also failed to "Start Monitoring".


  mqtt broker down.PNG (Size: 42,56 KB / Downloads: 71)


RE: Getting Started with MQTT on your Flexy using BASIC - simon - 11-01-2019

Hi,

Indeed, we had an issue with the MQTT broker.
Now it is back online.

Thanks for your feedback.

Simon


RE: Getting Started with MQTT on your Flexy using BASIC - cidadmin - 08-02-2019

...........................................................................


RE: Getting Started with MQTT on your Flexy using BASIC - cidadmin - 08-02-2019

(20-12-2017, 05:44 PM)simon Wrote: Hi Guys,

If you want to test the MQTT client feature (through BASIC or JAVA) with your Flexy (running the firmware 12.2or above), I suggest you first read the Programming Reference Guide (https://developer.ewon.biz/system/files_force/rg-0006-01-en-programming-reference-guide.pdf?download=1), page 58 and then you try to connect your Flexy to the MQTT broker of our test server : https://ewonsupport.biz/mqtt.  There is an example available that you just need to copy/paste to your Flexy.

Another easy platform to test, but here a real IOT plateform, is https://thingspeak.com/.
You can find the MQTT API tutorial here : https://nl.mathworks.com/help/thingspeak/mqtt-api.html
Here is an example of BASIC script :

Code:
Mqtt "Open","ewon","mqtt.thingspeak.com"
Mqtt "SetParam","Port","1883"
Mqtt "Connect"

Tset 1,5
Ontimer 1,"goto MqttPublish"
End
MqttPublish:
  Mqtt "Publish","channels/126155/publish/DWT0GL25GCMVQQ","field1=12&Status=MQTTPUBLISH",0,0
  TSET 1,0
  Mqtt "Close"
  HALT
End

Bye!

Simon


Hi simon,
Unable to access the MQTT broker url. It shows 

 Not Found


The requested URL /mqtt/ was not found on this server.

Apache/2.4.37 (Win64) OpenSSL/1.1.1a PHP/7.2.14 Server at ewonsupport.biz Port 80

Could you please help us with any alternative to test MQTT.



RE: Getting Started with MQTT on your Flexy using BASIC - simon - 12-02-2019

Yes, we are having an issue with the ewonsupport.biz test server.
I will fix that asap.
An alternative is https://www.cloudmqtt.com/. You need to register and you can use the same example, just by modifying the MQTT broker URL in the script.

Sorry for the inconvenience

Simon


RE: Getting Started with MQTT on your Flexy using BASIC - Jaisantosh - 12-01-2021

This thread has been marked as solved. If you have a similar issue, it would be better to post your own thread rather than bump this one, to help keep everybody's different issues separate.

Hi,
Thank you for the code,
I'm facing this issue which says Operation Failed(28): MQTT "connect"
I guess its a connectivity issue but unable to figure it out what exactly.
Looking forward for your response
Thanks,
Jai


RE: Getting Started with MQTT on your Flexy using BASIC - simon - 12-01-2021

Are you sure the TCP port 1883 (MQTT) or 8883 (MQTT over TLS) is opened on your network ?