Page 1 of 1

MQTT Basics and FC

Posted: Thu Oct 15, 2020 1:10 pm
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

Re: MQTT Basics and FC

Posted: Thu Oct 15, 2020 5:02 pm
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 154 times
Does the MQTT componet handle the ESP8266 (UART) etc automatically.
Yes it should do.

Re: MQTT Basics and FC

Posted: Thu Oct 15, 2020 5:27 pm
by QMESAR
Ben

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

Re: MQTT Basics and FC

Posted: Fri Oct 16, 2020 11:14 am
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.

Re: MQTT Basics and FC

Posted: Fri Oct 16, 2020 2:18 pm
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

Re: MQTT Basics and FC

Posted: Mon Oct 19, 2020 11:03 am
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

Re: MQTT Basics and FC

Posted: Mon Oct 19, 2020 11:10 am
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.

Re: MQTT Basics and FC

Posted: Mon Oct 19, 2020 11:16 am
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

Re: MQTT Basics and FC

Posted: Tue Oct 20, 2020 6:30 am
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 4588 times

Re: MQTT Basics and FC

Posted: Tue Oct 20, 2020 9:53 am
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

Re: MQTT Basics and FC

Posted: Thu Oct 22, 2020 9:00 am
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

Re: MQTT Basics and FC

Posted: Thu Oct 22, 2020 9:06 am
by LeighM

Re: MQTT Basics and FC

Posted: Thu Oct 22, 2020 9:40 am
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 4547 times

Re: MQTT Basics and FC

Posted: Thu Oct 22, 2020 10:03 am
by QMESAR
Thanks Ben and leigh

Much appreciated !