Ewon TechForum
Providing technical solutions to technical requests


Getting Started with MQTT on your Flexy using BASIC
simon Offline
eWON Support
#1
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_...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
Reply

rcerveto Offline
Junior Member
#2
(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_...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.
Reply

simon Offline
eWON Support
#3
See https://techforum.ewon.biz/thread-527.html
Reply

rcerveto Offline
Junior Member
#4
(21-02-2018, 11:24 PM)Simon Wrote: See https://techforum.ewon.biz/thread-527.html

Thanks Simon.
Reply

acs-sup Offline
Junior Member
#5
(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_...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
Reply

simon Offline
eWON Support
#6
Karim,

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

Simon
Reply

acs-sup Offline
Junior Member
#7
(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
Reply

kema Offline
Junior Member
#8
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
Reply

Chee Ho Offline
Junior Member
#9
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".


.png   mqtt broker down.PNG (Size: 42,56 KB / Downloads: 21)
Reply

simon Offline
eWON Support
#10
Hi,

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

Thanks for your feedback.

Simon
Reply

cidadmin Offline
Junior Member
#11
...........................................................................
Reply

cidadmin Offline
Junior Member
#12
(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_...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.
Reply

simon Offline
eWON Support
#13
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
Reply



Possibly Related Threads…
9 hours ago
Last Post: simon
09-03-2020, 02:29 PM
Last Post: simon
09-03-2020, 01:48 PM
Last Post: simon
06-03-2020, 06:39 PM
Last Post: simon
24-01-2020, 09:45 PM
Last Post: tedsch
07-01-2020, 03:34 PM
Last Post: simon
  Flexy and Microsoft Power BI Started by simon
19 Replies - 8.689 Views
10-12-2019, 11:25 AM
Last Post: simon
02-12-2019, 11:25 PM
Last Post: simon
27-11-2019, 10:30 PM
Last Post: simon
03-09-2019, 02:08 PM
Last Post: simon



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy