Using the ESP8266 examples

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

Moderator: Benj

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Using the ESP8266 examples

Postby chipfryer27 » Mon May 09, 2016 1:11 pm

Hi

I'm very interested in playing with the ESP8266 modules but despite seeing pictures and reading of an ESP Eblock, there doesn't seem to be a board to buy on the Matrix website.

Never mind, I constructed my own and set about learning how to use one within Flowcode V6 and downloaded all the examples. My first issue was that in some examples the target is a 16F1937 but when you try and compile to such it informs that there isn't enough memory. Never mind, I have a few other chips kicking around and changed the target to an 18F4523 for all examples. Now able to compile to chip I ran some examples such as setting my ESP as an Access Point and I could also connect to my SSID. So far so good.

However when I try to run the TCPclient example (using my SSID/password) I don't get the file returned. I get what appears to be an echo before what appears to be a lot of "random" characters with "busy" sandwiched inbetween, then "Done" appears. If I use a browser I can retrieve the file from the website so I'm guessing something is wrong in either the "Client Connect" macro or the "ClientSendRequest" macro. I have not altered the parameters in either macro from that which was downloaded.

When I try to control a relay, another example, I can "surf" to the ESP module and can "click" on the button. However I then jut get a yellow page on my browser before everything times out requiring a reset on the uC to bring things back to life. Any ideas?

I admit to having very little HTML / PHP experience (now reading a beginners guide) so examples are an excellent way to learn what is going on, well when they work, so can someone point me in the direction of where to GET help? Ideally I would like to know how / why the GET/POST strings are to be structured for sending in Flowcode with the hope of eventually connecting with pushingbox or such like and sending a device id. I've read all ESP related posts and the Wiki but nothing really explains to a novice how, the string in the example was structured.

Any pointers appreciated.

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

Re: Using the ESP8266 examples

Postby Benj » Mon May 09, 2016 2:53 pm

Hello,

What version of firmware do you have loaded on the ESP8266 module?

The firmware versions tend to react in different ways and could be why you are getting the problems for the client and the server examples. Apparently the cloud update has issues with newer firmware so I wouldn't advise you do this but there are ways to change the firmware without using the cloud update.

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Mon May 09, 2016 5:17 pm

Hi

I created an initialisation Flowchart and then sent a GetFirmware command to a number of ESP8266s. I have five of them.

One replied with 00170901 (the one I was using)
One replied with some garbage about a BTHub suggesting that that particular little gem has been in use before somewhere (I have TalkTalk and my SSIDs are all custom)
the remaining ones didn't want to talk at all, but the blue activity light was flashing suggesting perhaps a baud problem.

I will connect them up to a terminal later and issue "ATs" and let you know the results.

Thanks for the suggestion of what to check. Is their a version number I should be looking for?

Regards

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Mon May 09, 2016 7:35 pm

Hi Benj

I think it best if I try and put the latest firmware from Espresif on one of these modules and try things again. Too many strange things happening. Guess I was overly optimistic in hoping that I could talk to the modules "out of the box". Do you have a recommended firmware version or at least ones to avoid?

I'll let you know how I get on.

Thanks again for pointing me in this direction, a good start methinks.

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Tue May 10, 2016 1:05 pm

Hi

I connected up a serial interface and using a Terminal interrogated each ESP with AT+GMR.

ESP 1
AT 0.40.0.0
SDK 1.3.0
Build 1.3.0.2

ESP 2 and 3
AT 0.25.0.0
SDK 1.1.1

ESP 4 (which I was using)
only returned a value of 00170901

ESP 5
garbage

I think it clear that ESPs 4 and 5 require an upgrade but first I will retry the examples using the first three and if I run into problems with them then all will get upgraded.

Regards

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Tue May 10, 2016 7:33 pm

Hi Benj

I upgraded one of the ESPs to the latest version and AT+GMR returned:-

AT = 1.0.0.0
SDK = 1.5.3

Running the Flowcode Firmware Test returned 00170901.

Running TCPclient didn't work. After connecting to my AP it would display "Connecting" then nothing for perhaps three minutes, screen cleared for a few seconds before "Done" was displayed. I'm guessing same problem as before.

I added an extra couple of lines at certain points in the flowchart to see "progress".

After the ClientConnect macro that connects to Matrixtsl there is a decision box. If ret = 1 it branches off. In the branch I have the LCD displaying "GETing" before the ClientSendResquest Macro.

Running this indicates that we reach the ClientConnect macro, then wait for around three minutes (guessing it then times out) before continuing down the ClientSendRequest branch.

I am unsure why there is a decision box / branch after the ClientConnect macro as according to documentation it doesn't return a value and therefore the decision is made based on the previous ret value (1 because it connected to the SSID). Therefore it will always route this path.

From my router I can see the ESP module and it can be pinged so it does join my network. However I don't think it is connecting to your server.

Any ideas?

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Thu May 12, 2016 12:07 pm

Benj

Do all the Flowcode component macros work with the latest ESP Firmware (AT = 1.0.0.0 / SDK = 1.5.3)?

I didn't upgrade all modules to latest, so I still had the "original" ESP mentioned initially.

With the initial module (which might be running the latest, jury out on that one), I can see it connect to my router and it can be ping'd, but I cannot seem to connect etc. It works relatively OK in any "Server" example though.

With the upgraded modules I found that they too worked well in any "Server" examples, and the "Relay" example worked a treat, so progress there. However they refused to connect with the router. Router could see attempt on SSID but would it would always fail. As logs always had no IP associated with the attempt, that got me thinking.

I put the module back into my serial device and started issuing "ATs" with a copy of the latest AT Command Set to hand. Module was configured as an AP with DHCP. I then, again referencing the latest AT Command Set (downloaded with the latest AT file for flashing), attempted to set it to Station / DHCP. This failed. The AT Command Set informed that AT+CWDHCP_CUR is the command to issue, replacing the old AT+CWDHCP command. I found that the modules, despite supposedly having the latest AT installed (1.0.0.0) refused to accept the "new" command. Issuing the old command worked, and using further ATs I could get the module to connect to my router and I could see it and the associated IP address too. This could also be ping'd.

After flashing this change to Station / DHCP I could see it on my router when Flowcode issued ConnectToSSID and again can be ping'd. However I still cannot seem to get it to connect to your website example.

Just wondering in the light of above there may be an issue with the Macro sending a ClientConnect command?

Any thoughts anyone?

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Sun May 15, 2016 6:40 pm

I think there is an issue with the macro components.

I monitored activity on the uC Tx and Rx pins whilst running the TCP Client Example. Direct connections on the actual pins, not on a breakout box or anything to ensure that I saw exactly what the chip saw.

I saw the commands being sent to connect with my router and the received replies to the chip. All good there.

Flowcode then performs the ClientConnect Macro which does appear to connect to the MatrixTSL website and returns "CONNECT" and "OK", however the program "hangs" here. After approximately a minute or so it appears to disconnect from the website returning "CLOSED". After another minute or so the program proceeds to the next stage "ClientSendRequest" but as the connection is now closed it is hardly surprising that it fails. Attached is a screenshot of such.

As I'm far from a "C programmer" looking at the compiled code is a bit beyond me, but perhaps someone could advise what is going wrong? What is the ClientConnect Macro waiting for and is there any change I can make?

All help appreciated.
Attachments
Screenshot.jpg
Screenshot.jpg (143.15 KiB) Viewed 12240 times

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Mon May 16, 2016 7:20 am

Hi

It appears that the component Macro ClientConnect is looking for a response of "linked", as a line in the generated "C" is

FCL_DONE = FCD_08181_WLAN_ESP8266__CheckForData("Linked", 7);

As the ESP is returning "Connect" that is very probably why I am experiencing difficulties in using the component. Most likely the changes in the ESP firmware are responsible.

Not being an expert in "C", does anyone know of a way to change this from "Linked" to "Connect"? Alternatively, is there a firmware / AT version that is compatible?

Thanks in advance.

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Tue May 17, 2016 5:09 pm

In another ESP related post, Benj posted the code for the component.

I opened this and in the ClientConnect macro, I changed the CheckForData macro to look for a response of "CONNECT" rather than "Linked". I then saved the file and Exported it as a Component. I renamed the existing component (old_WLAN_ESP8266) and placed the new version in the directory (flowcode6/components).

In the TCPclient Example I deleted the existing ClientConnect macro and added in a new ClientConnect macro. I expected this new version to look for a "CONNECT" rather than "Linked".

However once running, the code again fails at the same place and when I view the "C" code, it appears that it is still looking for "Linked". Can anyone explain what I've done wrong in my attempt to change the expected response?

Alternatively is there a way to compile to Hex using an existing "C" file? I could edit the response in the generated "C" in Notepad++ or similar, but how could I then compile? As you have probably guessed, I'm not a programmer, which is one of the main reasons I use Flowcode.

Thanks in advance.

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

Re: Using the ESP8266 examples

Postby Benj » Tue May 17, 2016 5:51 pm

Hello,

Components are based on GUID's rather then the component file name. If the old component is still in the same directory even though it is renamed it may still be the one that is being used. You can either move the old component to a different directory or you can increase the version number of your new component and this should then take over as the master component.

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Tue May 17, 2016 7:57 pm

Hi Benj

Thanks for that. I will try it later and let you know how I get on.

Regards

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Wed May 18, 2016 9:17 am

Hi Benj

Moving the "old" component out of the directory worked fine. I can now see the "new" one looking for the "CONNECT" response when I check the "C code". Many thanks.

Whilst I was doing all this I checked the responses to ConnectToSSID as well as ClientConnect.

With the ESP running latest firmware they were ConnectToSSID = WIFI CONNECTED / WIFI GOT IP / OK (I have used the "/" to indicate a separate line)
and for ClientConnect = CONNECT / OK

The response to ConnectToSSID explains why the example program usually returns "Fail" at this stage despite the router seeing its presence.

Rather than change the parameters that Flowcode looks for just now, as my main issue is in getting it to communicate with servers, I will push on with the original ESP that gives the responses that Flowcode is currently looking for. I will change the component later, but hopefully the above will help others having difficulties.

Regards

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Thu May 19, 2016 11:18 am

Hi Benj

I still couldn't get the ESP Client Example to work using the original ESP. Although I could monitor what the uC was sending to the ESP I couldn't see what it was sending to a server (if anything).

I moved everything over to the upgraded module and after modifying the Flowcode component to look for the responses given by the latest ESP firmware, success, I can retrieve files! So there is definitely an issue with the firmware in the original ESP (and possibly communicating with Flowcode).

I also successfully triggered PushingBox.

Many thanks for all your help, quite fun figuring things out, and I learned a lot during such.

However the raw component files I'm using are from a post you made way back in September 2014 so are very probably a bit out of date. I was wondering if you could post the latest component file so I could modify that for my needs?

Regards

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Thu May 19, 2016 8:26 pm

Hi Benj

Modifying those files you posted back in 2014 is a beast of a job, as I'm sure you realise. The difference between then and now is immense. So many things to change to try and make it compatible with latest ESP Firmware.

Would it be possible to post the latest ESP Component so that I can modify it, or failing that could you modify the component so that instead of looking for a fixed response (e.g. "Linked") it perhaps looks for a User defined variable?

Either would be a huge, huge help.

Thanks in advance.

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: Using the ESP8266 examples

Postby LeighM » Fri May 20, 2016 11:33 am

Hi
Ben’s the author of this component, but he’s not in the office at the moment, so to help you I’ve exported the ClientConnect() macro.
You can use this to create your own version, for which you will just need to import it into your project and then change the calls to SendString() and CheckForData() to call the ESP component macros instead. Hope that moves you forward, until we can arrange a better long term solution.
Regards,
Leigh
Attachments
ClientConnect.fcm
(2.71 KiB) Downloaded 247 times
These users thanked the author LeighM for the post (total 2):
Rudi (Fri May 20, 2016 12:34 pm) • chipfryer27 (Fri May 20, 2016 2:19 pm)
Rating: 10.53%
 

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Fri May 20, 2016 2:26 pm

Leigh

Many, many thanks. This is a huge help indeed as to modify the 2014 component would be a lot of work, as you without doubt know.

Really appreciate the help you both provided and will keep you updated.

Regards

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Sat May 21, 2016 11:58 am

Leigh

I downloaded and imported the "new" ClientConnect macro into a worksheet, however unless I'm doing something very wrong I can't find a way to change the response as it appears that the macro calls another two from within, SendString and CheckForData, and these don't appear to be included. The response to be edited is within the CheckForData macro.

Regards

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: Using the ESP8266 examples

Postby LeighM » Mon May 23, 2016 8:49 am

Sorry, I missed the fact that CheckForData is a hidden macro and not exposed by the API.
Unfortunately CheckForData has other dependencies.

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Mon May 23, 2016 9:50 am

Hi Leigh

Thanks for the update.

I hope that we can soon find a solution without having to modify the 2014 component.

Regards

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: Using the ESP8266 examples

Postby Rudi » Mon May 23, 2016 4:08 pm

chipfryer27 wrote:Hi

I connected up a serial interface and using a Terminal interrogated each ESP with AT+GMR.

ESP 1
AT 0.40.0.0
SDK 1.3.0
Build 1.3.0.2

ESP 2 and 3
AT 0.25.0.0
SDK 1.1.1

ESP 4 (which I was using)
only returned a value of 00170901

ESP 5
garbage

I think it clear that ESPs 4 and 5 require an upgrade but first I will retry the examples using the first three and if I run into problems with them then all will get upgraded.

Regards


hi
have you check the send string, there was an update with

Code: Select all

\r\n
\n

so benj did an option in the properties that you can choice the end send char like you need by self

garbage means, that the right baudrate is not set 115200 / 9600
you can change the baudrate too in the properties of the component

hope this helps
best wishes
rudi ;-)

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Mon May 23, 2016 4:45 pm

Hi Rudy

Yes, I did remember to change the send string in Flowcode, I saw that in one of your earlier posts, of which are very helpful and informative.

My problem is that the latest ESP firmware, when it connects, doesn't give the response that the Flowcode component is looking for meaning Flowcode halts or waits for a timeout. I am of the opinion that earlier firmware may work without issue, but the modules I have are either now at latest, or give some very funky results meaning I need to upgrade them too.

I seem to have issue with the ConnectToSSID and ClientConnect responses. Flowcode looks for "OK" and "Linked" respectively, but the latest ESP firmware doesn't provide those. If you monitor the Tx / Rx ports of the ESP / uC as the example file progresses you can quite clearly see the send strings and replies.

This isn't any criticism of Flowcode, rather a third party module of which Flowcode has no control over has changed how their module interacts.

Regards

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: Using the ESP8266 examples

Postby Rudi » Mon May 23, 2016 5:36 pm

chipfryer27 wrote:
I seem to have issue with the ConnectToSSID and ClientConnect responses. Flowcode looks for "OK" and "Linked" respectively, but the latest ESP firmware doesn't provide those. If you monitor the Tx / Rx ports of the ESP / uC as the example file progresses you can quite clearly see the send strings and replies.


hi

(*)
with other words, ( because my bad english ) simply says:
if we can patch the firmware "Linked" to "OK"
or the component changes the wait for string from
"OK" to "linked"
then is it gone?
---

btw
i remember me too, that benj has make this possible too in the component and do an update in this too like the \r\n and \n
but it can be, that in a hidden makro the old strings "OK" is fix ( I can not imagine static doings but..) ..
can you short answere (*) that i have the problem understand, then i have a base for searching.

best wishes
rudi ;-)

chipfryer27
Posts: 174
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 108 times
Been thanked: 73 times
Contact:

Re: Using the ESP8266 examples

Postby chipfryer27 » Mon May 23, 2016 6:35 pm

Hi Rudi

That is pretty much it.

When ConnectToSSID is issued, old ESP Firmware returns:-
OK
Flowcode looks for this "OK".

However new ESP Firmware returns:-
WIFI CONNECTED
WE GOT IP

OK
Flowcode doesn't know to look for this.

Similarly

When ClientConnect is issued, old ESP firmware returns:-
Linked
Flowcode looks for this "Linked".

However new ESP Firmware returns:-
CONNECT
Flowcode doesn't know to look for this

I have read your posts on ESP with great interest. Keep up the good work as they are most helpful.

Regards

User avatar
Rudi
Posts: 666
Joined: Mon Feb 10, 2014 4:59 am
Has thanked: 494 times
Been thanked: 188 times

Re: Using the ESP8266 examples

Postby Rudi » Mon May 23, 2016 7:23 pm

Hi

ok. thank you for description.
now is clear.

in first think, try to send AT Command

Code: Select all


Execute    ATE0    OK    Disable echo (Doesn’t send back received command)
Execute    ATE1    OK    Enable echo (Sends back received command before response)



i can not test just in time
does it help for mute the to much receive message or still here?

best wishes
rudi ;-)