MQTT Basics and FC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

MQTT Basics and FC

Post by QMESAR »

Dear Ben/Leigh and Guys,

This is my first attempt with IOT and MQTT I will be glad if you will share some light on my confusion,
I have a EB006V9 with EB083 Combo board and an ESP8266 WiFi module as my sensor Node and I have a Broker(Mosquitto) Running on my RPI3
from the flowchart of scada example it seems that I need to use a MQTT component with a Network component this correct
my confusion is How to connect to the RPI3 Broker is this in the setup of the MQTT Componet? Does the MQTT componet handle the ESP8266 (UART) etc automatically.
If someone would help me with a basic setup Flowchart I will much obliged ,I really do not see the trees from the woods at the moment

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MQTT Basics and FC

Post by Benj »

Hello,

Here is an example for you.

The MQTT broker address is set in the MQTT Client component properties unser the Porperty "Host" just set this to the IP of your broker.

If your using Authentication then you also need to turn this on using the MQTT component properties.
PublishESP8266.fcfx
(16.23 KiB) Downloaded 147 times
Does the MQTT componet handle the ESP8266 (UART) etc automatically.
Yes it should do.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Ben

Thank you very much I appreciate your help with the example :D

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MQTT Basics and FC

Post by Benj »

I've been working on this page, which might be useful for you?

https://www.flowcode.co.uk/wiki/index.p ... QTT_Broker

Let me know if there is anything missing.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Hi Ben,

Thank you this is very helpful lot of stuff I still did not do or even know about thank you so much :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Hi Guys,

The ESP8266 module is 3.3V so my question do I need to use level shifter for the UART RX and TX pins and the Enable and reset Pins as I am hooking up to a 5V mcu ,I am not sure if the ESP pins are 5V tolerant and any help is appreciated
Secondly the enable pin is not included in the ESP Component, I suppose I just need to pull it up to VDD by a IO pin or Hardwired

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MQTT Basics and FC

Post by Benj »

Hello Peter,

Officially the ESP8266 datasheet states the pins are 3V3 however unofficially yes they are 5V tolerant. I have used at 5V with no problems.

https://hackaday.com/2016/07/28/ask-hac ... -tolerant/

https://www.facebook.com/groups/1499045 ... cation=ufi

I think we generally always just hardwire the enable pin, but yes it could be driven from an I/O pin instead.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Hallo Ben,

Thank you this helps a lot ,I will try it with the 5V at the Pins Vdd I hooked up to 3v3 . :D

Have good time

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Hallo Ben.

Just an interesting thing I notice when using the MOTT components with ESP Component
your example FC Chart compiles perfectly for all the bigger RAM values like the PIC182585,16F18877,16F18857 etc these chips has 2096 and 4096 RAM
the chips such as PIC16F1938,16F18855 with 1024 RAM the compiler reports some space errors

This is no problem for me at the moment as I am just learning but in future it would be good to know on what chip(memory /RAM size )this should be used

p1.jpg
p1.jpg (24.27 KiB) Viewed 4178 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Hi Ben,

Thank a million for the example once again ,I have it now running on HW my sensor node is connecting to the RPI successfully :D and I publish the sensor data to the Broker on the RPI and see the real data in the terminal window. With that said there is a long way still ,I am still confused with this IOT stuff once the sensor data is in the RPI(Broker) what is the standard procedure does the Broker publish it to a cloud or can the Broker data in the RPI be retrieved from some application for example mathPlot and plot the data on a graph in the RPI,

There is such a huge amount of different information regarding IoT and RPI I am lost looking at it :( :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Hi Guys,

Adding a password to the broker in the RPI (as per your document Ben) publishing to the topic by the commnad window in the RPI works
However How do I add the password as a parameter to the publish component in FC

Code: Select all

 mosquitto_pub -h localhost -t "test" -m "Sensor/Pot" -u "Fred" -P "password"
So the Topic in the RPI is now set for Sensor/pot and the client (in FC)publish to this topic with the following parameters

Topic set as "Sensor/Pot"
Payload as data(data contains the string of sensor info)
:(
where do I add the example password "Fred" in this publish component parameters?

All help appreciated

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MQTT Basics and FC

Post by LeighM »


User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MQTT Basics and FC

Post by Benj »

I've added the following image to the wiki page to help clarify how it's done in Flowcode.
MQTTProps.jpg
MQTTProps.jpg (26.31 KiB) Viewed 4137 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: MQTT Basics and FC

Post by QMESAR »

Thanks Ben and leigh

Much appreciated !

Post Reply