Switching an output with ESP8266

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

Moderator: Benj

Post Reply
keejay
Flowcode v5 User
Posts: 115
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 15 times
Contact:

Switching an output with ESP8266

Post by keejay »

Hi,

I was reading the following blog as I have very little knowledge of web servers etc:

https://www.matrixtsl.com/blog/internet ... led-relay/

and decided to have a go at it. I seem to be quite close, but the web page isn't quite behaving as expected. I have included a screenshot of the web page as well a copy of the FC8 file. The web page is also not responsive, and seems to behaving more like a data entry field rather than a "button". Any suggestions? I tried using Google Chrome on my PC and Safari on my iPhone. Both gave the same results.
Attachments
Screenshot (2).png
(88.56 KiB) Downloaded 1400 times
FlowCodeV8_NewPCB_Test.fcfx
(26.32 KiB) Downloaded 193 times

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: Switching an output with ESP8266

Post by Benj »

Hello,

Did you write the HTML code in Word by any chance?

I'm seeing this.
<body class=’%2′>Output is %2<p><form action=’process.htm’
And not sure if you can tell but the quotes for example ’%2′ seem to be unicode quotes and so won't work as expected.

They should instead look like this '%2' which for me is pressing the @ key without pressing shift (UK keyboard). Either directly into Flowcode or into a text editor (not Word).

Mentally shakes fist angrily at Word :wink:

Hopefully this is the root cause of the problems you're having.

Edit: I see the code is from our Wordpress blog, so it looks like this does the same Unicode conversion that Word does.

Mentally shakes fist angrily at Wordpress :wink:

keejay
Flowcode v5 User
Posts: 115
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 15 times
Contact:

Re: Switching an output with ESP8266

Post by keejay »

Hi Benj,

Thanks for the reply. I've made the changes that you suggested, but the output is still the same. I've attached the FC8 file. Any more suggestions?

Thanks
Attachments
FlowCodeV8_NewPCB_Test.fcfx
(26.39 KiB) Downloaded 195 times

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: Switching an output with ESP8266

Post by LeighM »

Hi,
Looks OK apart from the extra characters before process.htm

Code: Select all

action='process.htm'

keejay
Flowcode v5 User
Posts: 115
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 15 times
Contact:

Re: Switching an output with ESP8266

Post by keejay »

Hi,

The issue seems to be that the %1, %2, %3 variables (index.html) are not functioning. For example, when I click on the "submit", the "get" request is generated, but without the value for 's'...

192.168.4.1/process.html?s=

is being sent, so the '0' or the '1' is not being attached to the URL. If I manually force s="1", then it works.
i.e. <input type="hidden" name="s" value="1"> ....this works

Any ideas?

I've attached the slightly modified FC file as well as the index.html here for easy reading....

<!DOCTYPE html>
<html><head><title>IoT Remote Control</title>
<style>
.On {
font-family: Arial;
font-size: 72px;
font-weight: bold;
background-color: lightgreen;
text-align:center;
}
.Off {
font-family: Arial;
font-size: 72px;
font-weight: bold;
background-color: red;
text-align:center;
}
</style>
</head>
<body class=%2>Output is %2
<p>
<form action="process.html"
method="get">
<input type="submit" value="Switch %3">
<input type="hidden" name="s" value=%1>
</form>
</p>
</body>
</html>
Attachments
FlowCodeV8_NewPCB_Test.fcfx
(27.12 KiB) Downloaded 220 times

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: Switching an output with ESP8266

Post by Benj »

Hello,

Looking at your program and the ESP8266 properties don't look quite right.

The incoming and outgoing substitution counts are both set to 1, yet your html code references at least 4 outgoing values (0-3). This is likely the cause of the problem.

keejay
Flowcode v5 User
Posts: 115
Joined: Tue Jul 23, 2013 10:02 am
Been thanked: 15 times
Contact:

Re: Switching an output with ESP8266

Post by keejay »

Thanks Benj,

I've made some progress. It seems like it is looking for an initial state for %1, %2, %3, so if I manually type the following into the address bar (which clicking on the submit button should do):

192.168.4.1/process.html?s=1

then it responds correctly and thereafter everything works 100%.

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: Switching an output with ESP8266

Post by Benj »

Hello,

Glad it's working well for you now.

You can set the initial state of the substitution by calling the SetOutValue component macro after the ESP initialise macro but before the while 1 loop.

Post Reply