Page 1 of 1

MQTT send control issues

Posted: Mon Apr 20, 2026 10:51 am
by RGV250
Hi,
I have modified the Environmental monitoring and control example and it is working fine sending the data from the ESP32 to the web app. Unfortunately I cannot figure out what is going wrong in the other direction, when i try the original example it seems worse as every message seems to reboot the ESP32.
In my attempt it does not reboot the ESP32 but the data is always zero. The debug messages output on the web app shows what I think it the correct message. The issue seems to be in the ESP32 code, I have put lots of debug messages in to see where it is failing and that seems to be the Index has a value of -1 so it never gets to the decode macro.

This is what I see in the serial monitor, all seems to be what I would expect until the -1 as the "Decision" is looking for Index >= 0
These are for each click on the radio buttons.
mtx_demo_switchdata
Success
{"AvgCfg":66}
-1
IndexFailed

mtx_demo_switchdata
Success
{"AvgCfg":67}
-1
IndexFailed

mtx_demo_switchdata
Success
{"AvgCfg":19}
-1
IndexFailed

mtx_demo_switchdata
Success
{"AvgCfg":67}
-1
IndexFailed

This is where I think the issue is.
FC.jpg
FC.jpg (63.75 KiB) Viewed 57 times
WebApp_MQTT_Client_EcoEye5C.fcweb
(78.9 KiB) Downloaded 8 times
ESP_MQTT_Client_EcoEye3D.fcfx
(60.86 KiB) Downloaded 9 times
Any help would help with hair loss :lol:

Regards,
Bob

Re: MQTT send control issues

Posted: Mon Apr 20, 2026 11:04 am
by BenR
Hi Bob,

I think this is your problem. Its being passed a variable which is empty but this should be the string of the data tag your looking for.

Img1.jpg
Img1.jpg (14.45 KiB) Viewed 50 times

Should instead look like this with quotation marks around the tag.

Img2.jpg
Img2.jpg (21.21 KiB) Viewed 50 times

Re: MQTT send control issues

Posted: Mon Apr 20, 2026 11:25 am
by RGV250
Hi Ben,
First off, thanks for the incredibly quick reply and even better that it worked.

I must have looked at all the code around there hundreds of time yesterday and I did not see it.

I do have an issue with this though (hopefully I don't sound ungrateful), I think FC should have picked this up as an error.
When I selected the variable it was from the dropdown list so FC knew it was a string being selected (and the type it was expecting should be a string) so it would be nice if the quote marks are added or an error shown if the quote marks are missing.

Regards,
Bob

Re: MQTT send control issues

Posted: Mon Apr 20, 2026 1:10 pm
by Steve-Matrix
Hi Bob,

Flowcode cannot pick this up as an error. Passing a literal string "abc" will search for that name. Passing a variable will search for the *value* of that variable. There are legitimate times when you might want to pass a variable (for example, there may be multiple "Name0", Name1" , etc values you are trying to find and you can use a variable to create the string each time).

You passed a string variable, and so Flowcode (quite rightly) assumed you wanted to search for the value of that string variable (which, because you have not set it, is actually blank).