Cameroon Finance

Aug 31 2017

Wemos webserver example – esp8266 learning #webserver #hardware


#

Wemos webserver example

In this example we will create a basic webserver example using our Wemos, it will connect to your Wifi network and then you will navigate to a URL and a basic page will appear. This page will display 2 links. one will switch on an led connected to D5 and the other option will switch the led off.

Wemos D1 ESP8266 based board

1 x Wemos D1 or D2
1 x USB cable
1 x LED and resistor or use a module

Open the serial monitor. all going well and you will see the IP address and messages like the following

wemos ip address

Using your favourite web browser navigate to the IP above

i wish to make it run with a StepMotor and NeoPixels but i cant make it work . only if i dont use the wifi, but i need the wifi.

I ve added an example which seemed to work for me but basically you need to add the following

// config static IP
IPAddress ip(192, 168, 1, xx); // where xx is the desired IP Address
IPAddress gateway(192, 168, 1, 1); // set gateway to match your network
Serial.print(F( Setting static ip to. ));
Serial.println(ip);
IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network
WiFi.config(ip, gateway, subnet);

What chip and what program are you using because the following line will not compile.
Serial.print(F(“Setting static ip to. “));
When I remark it out the compiler (Arduino with the basic 8266 chip) works.

Its a Wemos so its a ESP-8266EX and im using the Arduino IDE 1.6.5 with the ESP8266 suport added via the additional board manager which pulls in support from http://arduino.esp8266.com/stable/package_esp8266com_index.json

I currently have v 2.0.0 installed

Hi, I don t know why it will automatically disconnected when i trying to turn on/off the led.

connected to wifi

WiFi connected
Server started
Use this URL. http://192.168.137.73/
new client
GET / HTTP/1.1
Client disconnected

new client
GET /favicon.ico HTTP/1.1
Client disconnected

What security does this library understand? I can get this to connect to my iPhone s hotspot, but not to my access point, It prints Connecting to SSID and dots forever. I have moved the Wemos within 10 feet of the AP. Any other reason besides security mismatch this would not work? Cisco 2600 series AP using only the 2.4GHz channels.

According to the library code in ESP8266WiFiScan.cpp

case AUTH_OPEN:
case AUTH_WPA_PSK:
case AUTH_WPA2_PSK:
case AUTH_WPA_WPA2_PSK:

This has always worked out of the box for me, only thing I can suggest is to try some of the other examples that come if you setup support of the ESP8266 in the Arduino IDE. I have read about people having issues and having to disconnect before then trying to connect.

Mine did that. If fixed as soon as I realized the SSID is case sensitive.

Q: I get this, now what to do?

Connecting to EHDT26

Exception (2):
epc1=0x3ffe8450 epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffe8450 depc=0x00000000

ctx: cont
sp: 3ffef820 end: 3ffefce0 offset: 01a0

stack
3ffef9c0: feefeffe feefeffe feefeffe feefeffe
3ffef9d0: feefeffe feefeffe feefeffe feefeffe
3ffef9e0: feefeffe feefeffe feefeffe feefeffe
3ffef9f0: feefeffe feefeffe feefeffe feefeffe
3ffefa00: feefeffe feefeffe feefeffe feefeffe
3ffefa10: feefeffe 00000004 3ffefa70 3ffefa81
3ffefa20: 40107020 00000000 3fff11e8 00000484
3ffefa30: 3ffefc17 feefeffe 000000a5 feefeffe
3ffefa40: feefeffe 00000000 00000000 3ffef9d0
3ffefa50: feefeffe feefeffe feefeffe feefeffe
3ffefa60: 3ffefa80 3ffefa70 00000004 feefeffe
3ffefa70: feefeffe 3ffe8564 3fff11e8 00000068
3ffefa80: 000000a5 3fff0d64 feefeffe feefeffe
3ffefa90: feefeffe feefeffe feefeffe 4010031d
3ffefaa0: feefeffe 00001028 3ffeec64 40100426
3ffefab0: feefeffe feefeffe feefeffe 40100537
3ffefac0: feefeffe 00001000 00000484 401006f5
3ffefad0: 00000484 00001000 000003fd 4010724c
3ffefae0: 40004b31 3ffefb10 0000001c 402244cd
3ffefaf0: 40105ea2 402245b5 3fff0d64 000003ff
3ffefb00: 000003fd 3ffefc17 3fff0d64 000003fd
3ffefb10: ffffff00 55aa55aa 00000010 0000001c
3ffefb20: 0000001c 00000013 00000013 000003ff
3ffefb30: 402249a4 3fff0d64 3fff0d64 000000ff
3ffefb40: 00000001 3ffefc37 40224aff 00000008
3ffefb50: 3fff0d64 000000ff 3ffefc17 00000000
3ffefb60: 3fff0e24 3ffefc78 00000001 40224b8c
3ffefb70: 3ffefc17 3fff0d64 00000000 00000004
3ffefb80: 3ffefc37 3fff709c 3fff0d64 00000000
3ffefb90: 40224bc8 3ffe8414 3ffe8424 feefeffe
3ffefba0: 402027ea 3ffe8424 3ffe8414 4020272a
3ffefbb0: 00000000 feefeffe 00000000 4000050c
3ffefbc0: 401041bc 00040000 00000000 00000000
3ffefbd0: 00000000 00000000 0000001f 40105d55
3ffefbe0: 4000050c 40103196 4010094e 00000030
3ffefbf0: 40227116 3fff0571 3fff03cc 3fffdad0
3ffefc00: 40227f3b 00000023 00000001 00000001
3ffefc10: ffffff00 45ffffff 32544448 feef0036
3ffefc20: 00000018 feefeffe feefeffe 0001c200
3ffefc30: 0000001c 68000000 61737361 6965656e
3ffefc40: 36323632 00000000 3ffe86e5 4020382c
3ffefc50: 00000000 00000005 3ffe8429 3ffeecb0
3ffefc60: 3ffe8370 00000006 3ffeec84 40202ed5
3ffefc70: 3ffe86e4 00fe8368 3ffeec84 40202ed5
3ffefc80: 3ffeeb40 00000000 00000001 40203904
3ffefc90: 402010ae 0000000a 3ffeec84 3ffeecb0
3ffefca0: 3ffe8370 3ffeeb40 3ffeec84 40202461
3ffefcb0: feefeffe feefeffe feefeffe feefeffe
3ffefcc0: 3fffdad0 00000000 3ffeeca9 40202fcc
3ffefcd0: feefeffe feefeffe 3ffeecc0 40100958
stack

ets Jan 8 2013,rst cause:2, boot mode:(1,6)

ets Jan 8 2013,rst cause:4, boot mode:(1,6)

I ve seen this researching the issue on the wemos forum

As a solution I put:
WiFi.persistent(false);
in the beginning of setup() and lo-behold. Crashes no more!

First class Many thanks

Thank you so much. My first wifi program!
Do you know WHY I have to change the baud rate to 9600? Otherwise I get rubbish (B�L ��#�#��).
I use Arduino IDE 1.8.0. The Get board info says BN: Unknown board, VID: 1A86, PID: 7523. How can I solve this?
I miss a lot of information for the D1 I just bought in november (seems to be a R1). On http://www.wemos.cc there is almost no information. I tried to post a message to the forum on wemos.cc, but you have to wait 24 hours to post your first message. I think the wemos products won t be a great success if they do it like that. So thanks again for your great support.

[ ] des Boards findet man hier), WLAN ist an Bord, außerdem ein einfach zu bedienender Webserver. Die erste Demo (Steuerung einer LED per WLAN) war mit guter Anleitung in unter 15 Minuten auf dem Schreibtisch [ ]

thank you but can i use more pins mean d3,d2,d1

Yes, a common example is to connect an RBG LED and use 3 pins and create a slightly different web interface

Hello. I ve just bought wemos d1 (unfortunatly not r2 but the retired version) and i m tring to run the example above. I first tried the first code and i didn t managed to make it work. Then i tried the updated code and i managed to make my wemos connect to my wifi. That means that i have the expected message in serial monitor. The problem is that i cant connect from my chrome browser to the suggested url..
Please help me .

What message do you see in the web browser

Worked fine for me, with example. Then I wanted to change the SSID to another, but both phone and computer (used to connect to the wifi) only sees the OLD SSID, not the NEW one. Is there a way to flush the clients that most likley remembers the old SSID?

As I am testing. when you go the ip address of the web server it really does not read the real state of th relay . it means that if i set it to ON and relogin again to the server it will show the state to OFF even though it is ON
What do i do wrong or it is something that is not solved in this sketch?

thanks it s my first project in wemos

thank you for your code, however i have a small issue. how can i use a name in browser insteated of using an ip address? for example if i want to be connected to wemos device. i go in browser i put like :Joseph

In the loop() function, there is a return. I don t get that. Shouldn t it exit the function and stop?


Written by admin


Leave a Reply

Your email address will not be published. Required fields are marked *