Test Board Review with - Exerciser / Web server / Web Client
Posted: Sat Sep 12, 2015 7:26 pm
I am a newcomer to the ESP8266 as I only recently bought an ESP8266-11 to see what they were all about. I did manage to get a little program running using the AT commands, but was anxious to take another step. Looking in the usual low-end catalogs, I saw an inexpensive ESP-12 with some I/O on the board. This board is usually advertised as the “Serial Port Wi-Fi Stable Version Test Board” or something similar and goes for about $4-$10 USD. Pictured below, you can see that it includes a number of SMT LEDs, an RGB LED and a CdS photo resistor.
The board has a battery connector and a 3v regulator. No manual or data sheet was available that I could find. The advertisements included some pictures of some kind of android phone interface, but that did not interest me. So, first, I did what I always do in a case like this: Go search what is out there. The search saved me some time and effort as the pinouts and some information on the board was available through the efforts of others (thanks) – see:
http://benlo.com/esp8266/esp8266Project ... spotfinder
http://blog.squix.ch/2015/07/esp8266-lo ... after.html
The ESP8266-12 board has:
1 blue power indicator SMT LED
6 red SMT LEDs mapped to GPIO
1 RGB LED mapped to GPIO
1 CdS photo resistor mapped to GPIO
Additionally, pins on the ESP are broken out to headers.
A couple of pointers:
Connect the jumper when flashing only – remove for normal use.
The board will operate on three AA batteries, but I found this problematic for doing a lot of flashing (rechargeable ones draining too quickly). For my investigation, I connected a reliable 5v supply to the battery case after removing the batteries. During final testing, I did use batteries.
The TXD GND RXD pins on the front of the ESP board (not the pins nearest to the chip) are straight through to the USB-serial board, not the usual TX->RX and RX-TX. I used this http://www.dxsoul.com/product/jy-mcu-us ... duiyMuFO4Q USB-serial board and installed a 3v jumper and then verified that all relevant signals were at 3v.
Attached are three programs that resulted from my testing. The first uses the ArduinoESP IDE and is an embellished, and a rather silly, “Hello World” blinker/exerciser. All of the LEDs flash sequentially and I also demonstrate the PWM on the RGB. By the way, I needed to decrease the PWM speed considerably to avoid “popping”. That is, during a change in PWM value, the LED appears to be all on as a digital output rather than a PWM value.
The second program, also using the ArduinoESP IDE is a very simple web server based on the Web Server example included in the IDE. In this case, the server allows a client to access the board’s I/O. A couple of points on this program:
As usual, add your own SSID and PW.
I decided to set the local address to 192.168.1.10 so it would not vary. You can see this in the code using WiFi.config(xx,xx,xx). It did not give me any problems but I am not sure what happens if that address is already allocated by my router (I suppose it just can’t connect). You don’t have to do it this way and if you only use WiFi.begin(SSID,PW) the server will be assigned a local IP by your router. If you go that way, set DEBUG to 1 in the program so that it will report the information through the serial monitor.
The server listens on port 80. There is a set format for communicating with the server. It is looking for a string of the form port=xx val=xxxx. Two digits for port and four digits for val. There is very little error checking done.
Port numbers correspond to the GPIO numbers on the board. Val(ue) depend on what the port does. For the digital outputs (00, 02, 04, 05, 14 and 16), val=0000 to turn the LED on and val=0001 to turn the LED off. The GPIO are set to sink rather than source current.
For the analog (PWM RGB LED) ports (12, 13 and 14), val=0001 as the minimum PWM (dim) and val=1023 as the maximum PWM (bright).
The CdS photo resistor is attached to the ADC on the ESP8266. Specifying port=99 will return the value of the ADC.
The screenshot below illustrates a communication with the server using a regular browser. The address string was http//192.168.1.10/port=00-val=0000 which turned on the LED attached to GPIO00 and the server reported that the port was on.
The final program is a windows client (Visual Basic 2010). A screen shot is below. This lets you turn on/off the LEDS, query the ADC, and use slider bars to set the PWM values for the RGBLED. I’m including the .exe file as well as the .vb and .vbproj which have the code. I also included the little jpg that is needed in the resource file if you compile it yourself. Visual studio produces a lot of files for the simplest of projects, so let me know if something else is needed to compile.
So far, all of these example server/client functions are using the local area network. I have, however, tested access using a WAN and everything works fine. To do this, I had to set up my router to forward port 333 (I chose that port because I read about someone else using that for their example) to port 80. I also had to set up my firewall to allow incoming requests on 333. Thereafter, the client would use my WAN IP address and port 333 with the same formatted string (e.g., (assuming my WAN IP is 123.12.121.12), “http://123.12.121.12:333/port=00-val=0000” to turn on GPIO00 from the outside (and with absolutely no security).
As a newcomer to the ESP8266, I’m interested in expanding my knowledge and skills. The introduction of the Arduino ESP8266 IDE was fuel for the effort. This IO board made experimenting easy and on that basis, it was useful for me. But, once past the experimenting, I don’t know how much I will use this board. I foresee taking a soldering iron to it and removing the peripheral devices. That leaves an ESP8266-12 with pins brought out to a header and a 3v regulator with a battery case. I can see using that in a project, so all-in-all, I recommend the board.
Cheers,
DrG
Edit: added the form1.designer.vb file to the archive
The board has a battery connector and a 3v regulator. No manual or data sheet was available that I could find. The advertisements included some pictures of some kind of android phone interface, but that did not interest me. So, first, I did what I always do in a case like this: Go search what is out there. The search saved me some time and effort as the pinouts and some information on the board was available through the efforts of others (thanks) – see:
http://benlo.com/esp8266/esp8266Project ... spotfinder
http://blog.squix.ch/2015/07/esp8266-lo ... after.html
The ESP8266-12 board has:
1 blue power indicator SMT LED
6 red SMT LEDs mapped to GPIO
1 RGB LED mapped to GPIO
1 CdS photo resistor mapped to GPIO
Additionally, pins on the ESP are broken out to headers.
A couple of pointers:
Connect the jumper when flashing only – remove for normal use.
The board will operate on three AA batteries, but I found this problematic for doing a lot of flashing (rechargeable ones draining too quickly). For my investigation, I connected a reliable 5v supply to the battery case after removing the batteries. During final testing, I did use batteries.
The TXD GND RXD pins on the front of the ESP board (not the pins nearest to the chip) are straight through to the USB-serial board, not the usual TX->RX and RX-TX. I used this http://www.dxsoul.com/product/jy-mcu-us ... duiyMuFO4Q USB-serial board and installed a 3v jumper and then verified that all relevant signals were at 3v.
Attached are three programs that resulted from my testing. The first uses the ArduinoESP IDE and is an embellished, and a rather silly, “Hello World” blinker/exerciser. All of the LEDs flash sequentially and I also demonstrate the PWM on the RGB. By the way, I needed to decrease the PWM speed considerably to avoid “popping”. That is, during a change in PWM value, the LED appears to be all on as a digital output rather than a PWM value.
The second program, also using the ArduinoESP IDE is a very simple web server based on the Web Server example included in the IDE. In this case, the server allows a client to access the board’s I/O. A couple of points on this program:
As usual, add your own SSID and PW.
I decided to set the local address to 192.168.1.10 so it would not vary. You can see this in the code using WiFi.config(xx,xx,xx). It did not give me any problems but I am not sure what happens if that address is already allocated by my router (I suppose it just can’t connect). You don’t have to do it this way and if you only use WiFi.begin(SSID,PW) the server will be assigned a local IP by your router. If you go that way, set DEBUG to 1 in the program so that it will report the information through the serial monitor.
The server listens on port 80. There is a set format for communicating with the server. It is looking for a string of the form port=xx val=xxxx. Two digits for port and four digits for val. There is very little error checking done.
Port numbers correspond to the GPIO numbers on the board. Val(ue) depend on what the port does. For the digital outputs (00, 02, 04, 05, 14 and 16), val=0000 to turn the LED on and val=0001 to turn the LED off. The GPIO are set to sink rather than source current.
For the analog (PWM RGB LED) ports (12, 13 and 14), val=0001 as the minimum PWM (dim) and val=1023 as the maximum PWM (bright).
The CdS photo resistor is attached to the ADC on the ESP8266. Specifying port=99 will return the value of the ADC.
The screenshot below illustrates a communication with the server using a regular browser. The address string was http//192.168.1.10/port=00-val=0000 which turned on the LED attached to GPIO00 and the server reported that the port was on.
The final program is a windows client (Visual Basic 2010). A screen shot is below. This lets you turn on/off the LEDS, query the ADC, and use slider bars to set the PWM values for the RGBLED. I’m including the .exe file as well as the .vb and .vbproj which have the code. I also included the little jpg that is needed in the resource file if you compile it yourself. Visual studio produces a lot of files for the simplest of projects, so let me know if something else is needed to compile.
So far, all of these example server/client functions are using the local area network. I have, however, tested access using a WAN and everything works fine. To do this, I had to set up my router to forward port 333 (I chose that port because I read about someone else using that for their example) to port 80. I also had to set up my firewall to allow incoming requests on 333. Thereafter, the client would use my WAN IP address and port 333 with the same formatted string (e.g., (assuming my WAN IP is 123.12.121.12), “http://123.12.121.12:333/port=00-val=0000” to turn on GPIO00 from the outside (and with absolutely no security).
As a newcomer to the ESP8266, I’m interested in expanding my knowledge and skills. The introduction of the Arduino ESP8266 IDE was fuel for the effort. This IO board made experimenting easy and on that basis, it was useful for me. But, once past the experimenting, I don’t know how much I will use this board. I foresee taking a soldering iron to it and removing the peripheral devices. That leaves an ESP8266-12 with pins brought out to a header and a 3v regulator with a battery case. I can see using that in a project, so all-in-all, I recommend the board.
Cheers,
DrG
Edit: added the form1.designer.vb file to the archive