Welcome! Log In Create A New Profile

Advanced

IoT (Internet of Things)

Posted by ElFont 
IoT (Internet of Things)
November 13, 2014 02:23PM
Hey,

The IoT kit is a great thing to learn/play with, but I'm getting stuck. Pretty sure I've got everything connected correctly and serial communication is working because I can get toggle Access Point / Station, get Google time and connect to the ESP8266 via 192.168.4.1 my phone.

What I can't do is view the web page (to do the LED/DHT11 stuff) - the page can't be displayed; and when I run option 9 (run as server) I get the message 'Problem cant start server'. I've looked at http://byvac.com/mBlib/flb/Library/wifi/http_server.bas and it appears to be an issue with either the cPORT value or something happening in the server() function (presumably called in here?: http://www.byvac.com/mBlib/flb/Library/wifi/ESP8266.bas)

Has anyone got any ideas please?
Re: IoT (Internet of Things)
November 13, 2014 05:40PM
Try the following
1) make sure everything is okay by selecting option 3 (info), you should get some information about the ESP8266
2) use option 5 to set the ESP8266 as a station
3) Use option 6 to join your wi-fi, you will need to provide the SSID and password of your wi-fi network
4) Use info again and you should get a different IP address from 192.168.4.1 - if it says ERROR where the IP address should be then wait a few seconds and try again. If it still says ERROR then you have not connected to your wi-fi network. This could be due to typing an incorrect SSDI and password or you could be out of range - very unlikely but possible is the DHCP is switched off on your router and so it is not giving out IP addresses.
5) If the IP is okay you will be able to get the time and date from Google

That is the IP address that is used to contact the ESP8266 in this mode.
Re: IoT (Internet of Things)
November 16, 2014 03:21PM
Thanks Jimeer,

I can connect the ESP8266 to my home router and get an IP for it, I can also get Google time but can't get it to display the IoT Server Example webpage on 192.168.1.7 (the IP it's currently been assigned). In terms of connections, only pin C9 is connected to ground (as doing anything with C7 and C8 causes ByPic not load the wi-fi menu when connected to serial).

I'm powering the ESP8266 from a separate 3v3 supply, and the PIC via the USB serial module (4v5).
Re: IoT (Internet of Things)
November 16, 2014 05:24PM
break out of the menu system (0) an type server(80), the response should be a '1', this puts the ESP8266 in server mode and sets MUX to 1. This will test if everything is okay

If you now put 192.168.1.7 in a browser, press return and then go back to BvSerial and type see1(), you will see the contents of the HTTP head from the browser, the browser will time out of course because there was not reply.

You can do some further diagnosis by sending the individual commands to the ESP8266. so to get the server mode working:
comclear(CPORT) // clear the input buffer
mux(1) // server will only work when this is a 1
cmd("CIPSERVER=1,80") // assume port 80 to be used
see1() // this will tell you what the command returned, could be ERROR, no change or OK


Does that help?
Re: IoT (Internet of Things)
November 16, 2014 05:42PM
It seems like it's so close! I've ran through the commands you sent, here's the output:


Request=    GET [www.google.com] HTTP/1.0

 Sun, 16 Nov 2014 17:31:00 GMT // Proof I'm getting the time!


======================================
0  Exit to ByPic
1  Start wi-fi wf_start()
2  Reset wi-fi rst()
3  Run info()
4  Set as an Access point
5  Set as a station

 ------ One time settings ------------
6  Join existing access point
7  Set access point information

 ------ Testing ----------------------
   <<Make sure correct mode is set before using>>
8  Test by connecting to google - (Station mode)
9  Run as Server - (Access Point)
10 Run as Client - (Station mode)
11 Get date and time from google - (Station mode)

Select? 0

ok server(80)
server(80)

1 ok see1()
see1()
Link

+IPD,0,330:GET / HTTP/1.1
Host: 192.168.1.7
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0
.8
User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/38.0.2125.111 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8


OK
Link


ok server(80)
server(80)

1 ok see1()
see1()


ok comclear(CPORT)
comclear(CPORT)

ok see1()
see1()


ok mux(1)
mux(1)

1 ok see1()
see1()


ok cmd("CIPSERVER=1,80")
cmd("CIPSERVER=1,80")

ok see1()
see1()
AT+CIPSERVER=1,80
no change


ok
Re: IoT (Internet of Things)
November 17, 2014 08:54AM
yes - it is now running in server mode, the 'no change' result means that it was in server mode already.
Re: IoT (Internet of Things)
November 17, 2014 01:16PM
So I can see that ByPic gets the request - but it never serves up the webpage, I.E. accessing 192.168.1.7 (or 192.168.4.1 depending on the mode) never loads the webpage that enables toggling the LED/getting the temperature; in Chrome I think the error is something like "sent request, no data returned"?
Re: IoT (Internet of Things)
November 17, 2014 04:51PM
I see, from the menu:
4 - set as an access point
3 - check that the IP address is 192.168.4.1
9 - run the server

On the android tablet, scan for wireless networks and select the name of the access point, something like ESP_984C26, connect to this access point, it is by default unsecured. Wait until the tablet acquires an IP address, this may have several unsuccessful attempts. My Archos took a full 3 minutes.

In the tablet browser type for the address 192.168.4.1

** Is this where you are getting stuck? Nothing is returned? If so I think you have already determined above that the ESp8266 is receiving the head from the browser, you can verify this by breaking out of the menu and typing see1() << If you can do this then it is confirmation that C9 is not grounded.

To explain the server needs to run in a continuous loop and so when you hit menu option 9, it should stay in that loop, if it comes back to the menu then it is not running the loop and so not listening. The mechanism used is to see if pin C9 is grounded. If there is a problem there then you can alter the loop in the code.
        while io_read(pSERVER,SERVER) = 0

Above is the line that looks at C9, you can change it to
while 1=1
but you will need to reset to get out of the loop.

*** If it still does not work then check that the tablet is still connected to the ESP8266, wifi has a nasty habit of referring back to its original connection particularly if it takes a long time to get an IP address. If the ESP8266 refuses to give out an IP address then reset it using menu 2.
Re: IoT (Internet of Things)
November 17, 2014 11:19PM
That's exactly where it gets stuck, after entering the IP on a connected device. It looks like it's resetting every time a device tries to access it on 192.168.4.1:

Select? 9

For this mode to work this needs to be set as an access
point and the wf-fi should already be initialised.
C9 needs to be grounded, to get out of this mode remove the link

Set your laptop or phone/tablet wifi to connect to the SSID
you have given it and wait for the device to give your
lapsop phone/tablet an IP address, this can take a few
seconds or a few minutes!!


In the browser put 192.168.4.1 and press return
To stop the server remove the link between C9 and ground

wait...
ready.. //sits here waiting
Characters recieved    6 //upon trying to load the page this is returned
peek:
318:GET / H ch=    0
Page recieved is [ / ]
Text input Buffer 254 allocated Baud 115200
//looks like a reset here
System cold start
******************************************
Wi-Fi Demonstatrion firmware
Details at www.bypic.co.uk
******************************************
wait...


======================================
0  Exit to ByPic
1  Start wi-fi wf_start()
2  Reset wi-fi rst()
3  Run info()
4  Set as an Access point
5  Set as a station

 ------ One time settings ------------
6  Join existing access point
7  Set access point information

 ------ Testing ----------------------
   <<Make sure correct mode is set before using>>
8  Test by connecting to google - (Station mode)
9  Run as Server - (Access Point)
10 Run as Client - (Station mode)
11 Get date and time from google - (Station mode)

Select?

So I tried the following:
1) flclear(0)
2) made a local copy of http://www.byvac.com/mBlib/flb/Library/wifi/ESP8266_DHT.script
3) made local copies of 'ESP8266.bas' 'main.bas' 'http_client.bas' 'http_server.bas'
4) in the 'http_client.bas' and 'http_server.bas' files changed 'while io_read(pSERVER,SERVER) = 0' to 'while 1 = 1'
5) edited 'ESP8266_DHT.script' to call these local files instead
6) uploaded via PSPad

...but on running; still get the same thing - it appears to reset itself
Re: IoT (Internet of Things)
November 18, 2014 08:51AM
Everything is working up to receiving a page and then it resets is that correct?
Re: IoT (Internet of Things)
November 18, 2014 01:19PM
Correct - the device (laptop, phone, etc.) connects to ESP8266, but the board resets when the device tries to access 192.168.4.1; I'm assuming it's a reset - in the serial window I get this when accessing 192.168.4.1:
ready..
Characters recieved    6
peek:
318:GET / H ch=    0
Page recieved is [ / ]
Text input Buffer 254 allocated Baud 115200

then

System cold start
Re: IoT (Internet of Things)
November 18, 2014 03:18PM
The only thing I can think of that would cause this is the power supply. The ESP8266 consumes a hefty current but only for very short periods. If the voltage drops below a certain value then that will cause the ByPic to reset. That is the reason for the separate power supply and large 1000uF capacitor on the ESP8266.

Check the wiring that it really is using the separate power supply and not being supplied form the ByPic device

Also sometimes the USB power is not up to it, particularly on long leads or a none powered hub, it should be rated at 500mA but I have found that some USB struggle to give out 300mA. Suggestions here are to try another device, port, lead or hub. If you have a volt meter then you can verify that the voltage should be at least 4.9V
Re: IoT (Internet of Things)
November 18, 2014 11:34PM
I had a play around with the power supply, and the blue LED on the ESP8266 was brighter with a 700ma power supply...but that didn't solve the problem - but might improve Wi-Fi range, etc.

I went through each function in 'http_server.bas' and printed a line out to bvserial when a function was called, and also what any variables in that function contained...then I found out what the problem was - 'pageBuf$' in HTTPsend_page() wasn't declared, so constructing the HTML page wasn't happening!

I haven't fully tested it, but when I access 192.168.4.1...the page is returned a long with the ability to toggle the LED and get the temperature/humidity!
Re: IoT (Internet of Things)
November 19, 2014 08:36AM
Strange, pageBuff$ is declared at the top of http://byvac.com/mBlib/flb/Library/wifi/http_server.bas?
Re: IoT (Internet of Things)
November 19, 2014 10:58PM
Ahh, so it is! I tried assigning an empty string straight after the declaration but it still didn't work; so I commented that out and continued with declaring it in the function as it seems to do the job. It's been very useful in the long run though, learning about uploading scripts, getting a feel for how ByPic operates, etc.

Thanks for all your help Jim,

Tim.
Re: IoT (Internet of Things)
November 20, 2014 08:46AM
Tim,
this thread may also be useful to others so thank you.
Jim
Re: IoT (Internet of Things)
January 23, 2015 05:02PM
I have just received my kit and am running into the same problem that a few others seem to have i.e. I can't get the web page (LED and DHT11 items) to respond in either of the two modes detailed in the instructions.
Other functions (8 and 11) do work OK.
It would seem that the fix in this thread is the cure so I'd like to ask if the firmware has subsequently been modified as per ELFont's fix. (Sorry but I've not got far enough into the operation of things to be able to check this for myself yet).
Dave

PS Really impressed with the postal packaging, much better than the Jiffy Bag that most use.
Re: IoT (Internet of Things)
January 23, 2015 07:36PM
Thanks for the reminder.

The ESP8266.bas has been updated to ESP8266_b.bas and is now incorporated into the script:

[http://www.byvac.com/mBlib/flb/Library/wifi/ESP8266_DHT.script]

which is on the tutorial page. It effects the way the client mode works with the public server and now it works a bit more reliably being able to switch the LED on and off via [http://www.pin1.org/wifi/wfdemo.php.] I can't always guarantee this method though as it is open to all.

To update, copy the above script URL using CTRL+C, in PSPas use scripts>Open URL is script and that will place a copy of the script in PSPAD.

Make sure that the ESP8266 is version b in the script about half way down thus:

[http://byvac.com/mBlib/flb/Library/wifi/ESP8266_b.bas]

Sometimes files are cached and the older version is used, if so juts add a _b to the end of ESP8266 as shown.
In the black screen type flclear(0), go back to PSPad and CTRL+SHIFT+R
This will send the script to the BV508. It will need a couple or .r (dot r) to reset after sending the script.
Re: IoT (Internet of Things)
January 23, 2015 09:17PM
Thanks for your prompt reply, much appreciated.
I followed the instructions but no joy I'm afraid. A bit tired now so I'll have another go tomorrow and let you know what happens.

Just one thing, for other total newbies (much like myself) who might try this, it might be better if the line :-
In the black screen type flclear(0), go back to PSPad and CTRL+SHIFT+R
Read :-
In the black screen exit the menu by entering 99 then type flclear(0), go back to PSPad and CTRL+SHIFT+R

Regards
Dave
Re: IoT (Internet of Things)
January 23, 2015 10:56PM
Well, I had a rest then had to have another go!!!!

I put my sensible head on and got my DVM out. Lo and behold it wasn't a firmware fault but hardware!

I found that the "X" and "Y" strips on the breadboard supplied with the kit are not contiguous (as they are on all my existing breadboards) and break between holes 15/16 and 35/36. I'd been using them as if they were contiguous for the 3V3 and 0V rails. As a consequence C9 was never at 0V, hence the problem.

After changing to one of my trusty breadboards everything worked OK.

Regards
Dave
Re: IoT (Internet of Things)
January 24, 2015 09:52AM
Dave,
most kits are supplied with a 400 hole breadboard, much smaller, yours had a 700 hole breadboard which does have several short strips in the power rows.
The menu item for exit is 0 (possibly 99):

There are two sets of firmware one for when the BV508 comes without a kit and the exit is 99 and one for when the BV509 comes with a kit and the exit is 0, it also has extra menu items for driving the DHT and LED. In fact pressing any key on this menu will exit. You must have had the menu that is intended for the BV509 without a kit, sorry my fault.

Doing the flcear(0) and installing the firmware from the above URL will correct this. The same URL can also be found at the top of the tutorial file here.

Just for information, the script is made up of several firmware .bas files as you can see by looking at it. Using flclear(0) clears all of those files from the Flash on the processor but you can use flclear(1) which (most of the time) will clear just the last file loaded and saved(with flsave("")). In the case of this particular script it will be the .bas file that does the menu functionality so by clearing it you will be able to create your own functionality.

Documentation for these and other commands is on the documentation page The language guide is a general description of how things work and the key words contains details of each command, such as fclear.
Jim



Edited 1 time(s). Last edit at 01/24/2015 04:03PM by jimeer.
Re: IoT (Internet of Things)
January 24, 2015 11:13AM
Jim,

Thanks for the clarification. I did notice that once I'd loaded the "new" firmware that the exit was a "0". My board is a BV508 by the way.

Possibly it is worth a note in future kits with the 700 hole breadboard that the "X" and "Y" strips are made up of three isolated sections.

Having got things working I shall now do a bit of reading of the documentation as you suggest and experiment a bit - it should be fun.

Dave
Re: IoT (Internet of Things)
January 24, 2015 04:09PM
I have just discovered https://www.pushingbox.com and so updated the IoT tutorial, under Client(2) heading so that the client can now send an email every so often. You will need a google account though but the email scenario looks like just a small part of what can be achieved.
Jim
Re: IoT (Internet of Things)
January 25, 2015 12:15PM
Once again thaks for the update Jim. It does look an interesting option to try.
I'll give it a go in the week - I have a football match to go to this afternoon!
Regards
Dave
Re: IoT (Internet of Things)
January 25, 2015 08:10PM
hello first for Elfont thanks.
I use IoT kit
I have to re-update to ESP8266_b.bas
still the problem e.g. mobile out of time
nothing more
all the others work fine
has anyone a solution
sorry for the english writing
it can read and, if necessary, google !!



Edited 1 time(s). Last edit at 01/25/2015 08:15PM by gulik154.
Sorry, you do not have permission to post/reply in this forum.