Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 19:09 04 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : http://garden.geoffg.net/

     Page 1 of 2    
Author Message
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 11:31pm 01 Dec 2014
Copy link to clipboard 
Print this post

Hi
Has any body tried Geoff's code yet.
http://garden.geoffg.net/
I have not seen the SC article so maybe these points are addressed
Looks like a few exit sub should have been exit function
With all my ESP8266 modules AT+RST returns

AT+RST

load 0x40100000, len 25020, room 16
chksum 0x55
load 0x3ffe8000, len 3280, room 12
chksum 0x1d
tail 0
csum 0xe1
[System Ready, Vendor:www.ai-thinker.com]

In the code the following line does a sanity check
[code]
SendCmd "AT+RST", "ready"
[/code]
with the response expected to be "ready" from the above this is never
going happen so I changed it to "[System Ready, Vendor:www.ai-thinker.com]"
and now we are past this point

I cannot get past the next bit. The module has an IP address and is pingable

' Log into the network and setup the server function
PRINT "Found the ESP8266. Firmware version " + GetVer$()
SendCmd "AT+CWJAP=" + CHR$(34) + SSID$ + CHR$(34) + "," + CHR$(34) + Passwd$ + CHR$(34), "OK"
PRINT "Connected to " + SSID$ + ". IP Address " + GetAddr$()
SendCmd "AT+CIPMUX=1", "OK"
SendCmd "AT+CIPSERVER=1,80", "OK"
IF error GOTO ReTryWEB


To get the above work the following is required

[code]
' The following four constants should be edited to reflect your requirements
SSID$ = "SSID" ' Replace SSID with the name of your WiFi network
Passwd$ = "passwd" ' Replace passwd with the password to your network
Timeout = 20000 ' Error timeout in milliseconds
echo = 0 ' Set this to non zero to see all communications


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''
' This will get the version number of the firmware running on the module
FUNCTION GetVer$()
LOCAL s$, i
IF error THEN EXIT SUB This should be Function
ClearBuffer
PRINT #1, "AT+GMR"
FOR i = 1 TO 3
s$ = GetLine$()
IF error THEN EXIT FOR
IF echo THEN PRINT s$
NEXT i
GetVer$ = s$
END FUNCTION


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''
' This will get the IP address of the module
' After connecting to the access point it can take several seconds for the
' command to complete. This sub will keep trying to get the address and will
' only return when it has it (this signifies that the connection is made).
FUNCTION GetAddr$()
LOCAL s$, i, j
IF error THEN EXIT SUB This should be Function
FOR i = 1 TO 20
ClearBuffer
PRINT #1, "AT+CIFSR"
FOR j = 1 TO 3
s$ = GetLine$()
IF error THEN EXIT FOR
IF echo THEN PRINT s$
NEXT j
IF LEN(s$) > 5 OR error THEN EXIT FOR
PAUSE 1000
NEXT i
GetAddr$ = s$
END FUNCTION

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''
' This is a general purpose sub which will send a command and check
' for the correct response
SUB SendCmd cmd$, response$
LOCAL InputStr$
IF error THEN EXIT SUB
ClearBuffer
PRINT #1, cmd$
DO
InputStr$ = GetLine$()
LOOP UNTIL INSTR(InputStr$, response$) > 0 OR error
END SUB

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''
' Get a line of text from the module
' This function can work with lines that are longer than the Micromite's
' maximum string length of 255 characters (unlike LINE INPUT)
FUNCTION GetLine$()
LOCAL s$, c$
TIMER = 0
DO
c$ = INPUT$(1, #1)
IF echo THEN PRINT c$;
IF ASC(c$) = 13 OR LEN(s$) >= 254 THEN
GetLine$ = s$
ELSE
IF ASC(c$) >= 32 THEN s$ = s$ + c$
ENDIF
IF TIMER > Timeout THEN error = 1
LOOP UNTIL ASC(c$) = 13 OR LEN(s$) >= 254 OR error
END FUNCTION


[/code]

Maybe Geoff can point me in the right direction could be a blond moment on my side :)

Regards
Jman


 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 02:22am 02 Dec 2014
Copy link to clipboard 
Print this post

When I browse to Geoff's http://garden.geoffg.net server I get:

Welcome to the Micromite Garden Webserver

You are visitor number: 1053

The Micromite time is 19:51:21 and the date is 02-12-2014

The temperature in the garden is 22.5°C and the humidity is 45%

The MMBasic program running the server can be downloaded from here.


And also browsing to http://garden.geoffg.net/stats I get:

Number of connections: 1058

02-12-2014 16:14:00 - Restarting the server
02-12-2014 16:15:03 - Connection number 1026 from 124.195.210.230
02-12-2014 16:19:11 - Connection number 1027 from 212.175.171.2
02-12-2014 16:19:21 - Restarting the server
02-12-2014 16:49:51 - Connection number 1028 from 125.236.241.58
02-12-2014 16:50:33 - Connection number 1029 from 125.236.241.58
02-12-2014 16:51:28 - Connection number 1030 from 125.236.241.58
02-12-2014 17:30:04 - Connection number 1031 from 62.210.136.206
02-12-2014 17:30:09 - Restarting the server
02-12-2014 17:41:02 - Connection number 1032 from 86.186.111.175 etc.


If I run Geoff's program on my Micromite/ESP8266 system using my SSID and password and an included PCF8563 RTC I get:

>RUN
Starting the server at 02-12-2014 23:02:45 'there's a minute or so delay here, then

[260] If ERROR Then Exit Sub
Error: Nothing to return to


Haven't gotten past here yet.

Greg

Edit: I should have mentioned - at this stage I don't have a DHT-22 connected.Edited by paceman 2014-12-03
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 08:16am 02 Dec 2014
Copy link to clipboard 
Print this post

Hi

To get past the bit were the program stop change the exit sub to exit function I think there is 3 of those that need changes

What version of the ESP8266 firmware are you using ?

Jman
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 10:24am 02 Dec 2014
Copy link to clipboard 
Print this post

At the top of Geoff's code he says
' This server will run on all versions of the Micromite firmware however
' support for the DHT22 temperature/humidity sensor is only present in
' version 4.6 of MMBasic for the Micromite MkII.

Perhaps due to the article lead time and all the changes with the BETA versions this has caused the problems noted.

cliff
Cliff
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 01:51pm 02 Dec 2014
Copy link to clipboard 
Print this post

Unfortunately I am off camping in the great outdoors so I will not be able to look at it for 5 to 6 days. This is a bad habit of mine (going camping when an article hits the streets).

The "server" is running an early beta of 4.6 (I cannot remember what beta number). When I get back I will reflash it with the latest and see if I can track down the problem.

The issue that Jman encountered could be due to a different version number of the firmware running on the ESP8266. The ESP8266 is a great little device but it is frustrating to use because of issues like this.

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 07:58pm 02 Dec 2014
Copy link to clipboard 
Print this post


I'm on V0.9.2.2 of the ESP8266 and B25 of MMBasic. I changed those three EXIT Functions and also put the "www.ai-thinker.com" response in but found I didn't need the latter because it does actually come back with "OK" from the AT+RST command - but it's quick - and the it follows with the strange gumpth that ends with the "...ai-thinker" line.

I now get to the point where it says "Found the ESP8266..." etc but it doesn't read the version or the address correctly. I think there's some issue in the GetLine$() function or timing there because I get two AT+GMR commands sent, one behind the other. I assume that means it is getting an ERROR.

Greg
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 10:27pm 02 Dec 2014
Copy link to clipboard 
Print this post

@ Greg

Try the attached code and report back if it works for you
The RTC and DHT22 are commented out as I don't have them connected at present

Regards
Jman

2014-12-03_082731_WebServerJman.zip Edited by jman 2014-12-04
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 02:56am 03 Dec 2014
Copy link to clipboard 
Print this post


@Jim,

Yes, that did the job - but only temporarily! When I first fired it up with your code it returned both the Version number and the it's assigned IP address. At that point I could also talk to it via the browser and get both webpages back. After halting it and re-starting it though, it didn't want to get past the Version number, i.e. it returned the Version number but not the IP address.

I then cut the power and started again and up it came properly again with both Version and IP address. I halted the program and re-started. Same problem - no IP address. This time I changed the PAUSE in line 236 to 200 (from the 100 you had changed it to) and ran it and lo, it worked properly again but not after halting and starting again. I didn't try fiddling with the AT+CWMODE, I left it at 1 where you had changed it to (from 3).

It all seems a bit random - there are obviously a few bugs still in their firmware.

Greg

 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 08:25am 03 Dec 2014
Copy link to clipboard 
Print this post

@Greg

Ok I see that issue if you add the line below all should be well
should be around line 71
[Code]
SendCmd "AT+RST", "chksum 0xe1"
ClearBuffer <<<<<<< Add this
[/Code]


The AT+CWMODE=1 sets the module in client mode only and AT+CWMODE=3
set it to Client and Access Point mode I don't need this module to act as an
access point so I changed it client mode only

Regards
Jman
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 08:42pm 03 Dec 2014
Copy link to clipboard 
Print this post


Same problem Jim, it gets the Version number but not the address. BTW the address has changed since the other day, I guess the router did a DHCP re-assignment. I could put a fixed IP in there but I'm not sure what the modules MAC is. Geoff mentions that in his SC article but doesn't say how he got the MAC.

Can you re-post the file that you have now please - I'm not sure I haven't changed things I shouldn't have here.

Greg
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:22pm 03 Dec 2014
Copy link to clipboard 
Print this post

Sure this code works for me

2014-12-04_072148_WebServerJman.zip


BTW it's John :)

Regards
Jman
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 03:24am 04 Dec 2014
Copy link to clipboard 
Print this post

HI John - sorry about that ,

Still having trouble with that latest file. My system returns two IP addresses when AT+CIFSR is sent, as below, and 192.168.1.2 pings OK, the .4.1 one doesn't.

AT+CIFSR

192.168.4.1
192.168.1.2

OK

The first address shouldn't exist on my system, the second is the correct DHCP assigned address for the module. In any case it won't pick the address up until I change the response for the line "SendCmd "AT+CWJAP=...." from "OK" to "csum 0xe1" because that rubbish keeps flowing through.
Here's what the output looks like:

RUN

Starting the server at 04-12-2014 23:40:23
AT


OK
AT+RST


OK

ets Jan 8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 25020, room 16
tail 12
chksum 0x55
ho 0 tail 12 room 4
load 0x3ffe8000, len 3280, room 12
tail 4
chksum 0x1d
load 0x3ffe8cd0, len 6468, room 4
tail 0
chksum 0xe1
AT+GMR
AT+GMR


0018000902
0018000902
Found the ESP8266. Firmware version 0018000902
AT+CWJAP="YSAWNET","My_PWD"


ets Jan 8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 25020, room 16
tail 12
chksum 0x55
ho 0 tail 12 room 4
load 0x3ffe8000, len 3280, room 12
tail 4
chksum 0x1d
load 0x3ffe8cd0, len 6468, room 4
tail 0
chksum 0xe1
csum 0xe1
AT+CIFSR
AT+CIFSR


192.168.4.1
192.168.4.1
Connected to YSAWNET. IP Address 192.168.4.1
AT+CIPMUX=1


OK
AT+CIPSERVER=1,80


OK
WEB server started

ets Jan 8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 25020, room 16
tail 12
chksum 0x55
ho 0 tail 12 room 4
load 0x3ffe8000, len 3280, room 12
tail 4
chksum 0x1d
load 0x3ffe8cd0, len 6468, room 4
tail 0
chksum 0xe1
csum 0xe1

[System Ready, Vendor:www.ai-thinker.com]


Those two identical IP addresses, 192.168.4.1 usually show up as the two addresses as per the box at the top of the post.

This is frustrating - I might give it a miss for a few days!

Greg
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 04:52pm 04 Dec 2014
Copy link to clipboard 
Print this post

All,

Two points that may prove useful to 'beginners' - observed while I have been playing with the ESP8266 unit (along with Geoff's article in December's SC Magazine).

1> In Geoff's article: Fig 4 on Page 32 shows connection between the ESP8266 and a 28-pin MicroMite. The two MicroMite Pins used should be 22 and 21 - and not 22 and 23 as indicated. Simply read Pin 23 (from the Fig 4) as Pin 21.

2> If using TeraTerm then make sure that under the 'Setup' tab (then 'Terminal' menu option): that New-Line Transmit option is set to CR+LF. If it is only set to CR then you won't get the 'OK' responses from the ESP module (took me a while to track this one down!!)

I also get two IPs returned in response to the AT+CIFSR command (the first one is 'invalid', the second one is on my network and works just fine)

Loving the capabilities at the moment - but unit does run warm!

Hope the above information helps at least some of you out there . . . .

WW


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 05:43pm 04 Dec 2014
Copy link to clipboard 
Print this post

Hi

The reason you get 2 IP address's is that you have the module in AP and Client mode
"Print #1, "AT+CWMODE=1"
Will put the module in client mode and you get only one IP

Print #1, "AT+CWMODE=3"
will put the module in AP and Client mode and you will get two IP's
one from the AP (Not your network) and one from your network

Since the module is getting to your WiFi network you do NOT need an additional
Access point so I suggest turning if off.

Regards
Jman

 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 02:04am 05 Dec 2014
Copy link to clipboard 
Print this post


I should have realised that John, I knew mode 3 was AP & client. I've just gone back to AT+CWMODE=1 and now getting one address returned. For some reason though the code is returning 0.0.0.0 as the address even though it's actually connected to 192.168.1.2 (I've checked it with the terminal program and I can ping it). Also it now doesn't return the Version number whereas before it did. I'm wondering whether it's corrupted something that it stores in flash and maybe I should re-flash it.

BTW I noticed that on ESP8266 forum that Espressif put out a new firmware version on the 28th Nov. From what I've read about it there though there are other issues now.

Greg
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 11:52am 06 Dec 2014
Copy link to clipboard 
Print this post

Hi

Greg I have attached the latest SSP8266 firmware
Upgrade the module and then try the attached basic code
The ESP8266 now supports a watchdog so we can recover if the module goes
haywire

Regards
Jman

2014-12-06_215131_ESP8266_AT_V00180902_04.zip

2014-12-06_215146_WebServerJman.zip
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 03:11am 07 Dec 2014
Copy link to clipboard 
Print this post


OK John, I re-flashed it to the file above and now I'm running the ..-AIO3 version. Thanks for posting that.

I then ran the Version of "Garden" you posted above (after getting slightly confused with the DHT11 stuff till I realised what was going on ) and after a few tries when it could only get the Version number again, it finally found the IP address and I could access it properly with the browser. Unfortunately that just lasted for a few runs and it lost itself again. At this stage I've tried re-starting a few times and powering off/on but still can't get it - right now it doesn't even find the Version number.

I wondered if it was having trouble accessing the router but that's only about three meters away, albeit through a plaster wall, and there have been times when it's had no trouble so I think that's unlikely.

I'll press on.

Greg


 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:03pm 07 Dec 2014
Copy link to clipboard 
Print this post

Hi Greg

Just a thought does your module have a good 3.3V supply at full power these
modules seem to pull more than the MCP1702 can supply the LM1117 seems to work ok
also add .100uf cap across the power pins on the module.

Try adding the line below this will enable the modules watchdog

' Open communications with the ESP8266 module
Open "COM1:115200, 1024" As #1
Print #1, "AT+CSYSWDTENABLE" '<<<<<<<<<< Add this line

Let us know who you get on

Regards
Jman
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 02:31am 08 Dec 2014
Copy link to clipboard 
Print this post


Hi John,
The supply should be fine, it's an LM2596 based adjustable switchmode supposed to be good for better than 2A. However, I did put a 0.1uF across the supply and when I first fired it up tonight with last night's code it came in immediately, found the IP on the first try and then gave me three good sets of responses from the browser. Unfortunately then it stopped.
I then tried several combinations of restarts and power down/ups to no avail, then I added in the module watchdog and still no go.

I started wondering about my router so had a look at its log and below is a section of it. That MAC address is the module and it looks like it's sending to the router alright but not acknowledging the "ack".

Dec 08 22:37:42 daemon DHCP SERVER: DHCPDISCOVER from 18:fe:34:98:67:09 via br0
Dec 08 22:37:43 daemon DHCP SERVER: DHCP offer to 18:fe:34:98:67:09
Dec 08 22:37:43 daemon DHCP SERVER: DHCP request from 18:fe:34:98:67:09
Dec 08 22:37:43 daemon DHCP SERVER: DHCP ack to 18:fe:34:98:67:09
Dec 08 22:38:30 daemon DHCP SERVER: DHCPDISCOVER from 18:fe:34:98:67:09 via br0
Dec 08 22:38:31 daemon DHCP SERVER: DHCP offer to 18:fe:34:98:67:09
Dec 08 22:38:31 daemon DHCP SERVER: DHCP request from 18:fe:34:98:67:09
Dec 08 22:38:31 daemon DHCP SERVER: DHCP ack to 18:fe:34:98:67:09
Dec 08 22:39:01 daemon DHCP SERVER: DHCPDISCOVER from 18:fe:34:98:67:09 via br0
Dec 08 22:39:02 daemon DHCP SERVER: DHCP offer to 18:fe:34:98:67:09
Dec 08 22:39:02 daemon DHCP SERVER: DHCP request from 18:fe:34:98:67:09
Dec 08 22:39:02 daemon DHCP SERVER: DHCP ack to 18:fe:34:98:67:09


I was getting a bit excited there for a while.

Greg
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 04:19pm 08 Dec 2014
Copy link to clipboard 
Print this post

Bought a copy of the December issue to see the article on the $5.00 Webserver.

I was disappointed that Geoff didn't grab onto a golden opportunity to promote MMBASIC/Micromite in the article and post a working example in code.
Obviously he has it working nicely.

@Geoff, is your source code posted anywhere so that we can play with it?
My Propeller/Micromite mini-computer project.
 
     Page 1 of 2    
Print this page
© JAQ Software 2024