ESP8266 Building Hello World Blink LED and Simple Web Server to drive the Relay and check Button status

ESP8266

ESP8266-EVB is small 57×50 mm board with Relay and Button which are connected to Internet via ESP8266 WIFI module.

ESP8266 has inside Xtensa106 processor and RF front end circuit, you do not need separate processor to drive the relay and read the button as ESP8266 can be programmed with custom code.

Here we will explain how to setup your tools and make your first project.

First you need to install your tools. It’s simple, just follow the instructions here: https://github.com/esp8266/esp8266-wiki/wiki/Toolchain

There are just few small mistakes as some commands will require SUDO before them and some paths are not exactly same, but you have to follow the steps and once you get error to read and correct the problem.

Here is what we do on Ubuntu 14.04 LTE 64-bit:

sudo apt-get install git autoconf build-essential gperf bison flex texinfo libtool libncurses5-dev wget gawk libc6-dev-amd64 python-serial libexpat-dev
sudo mkdir /opt/Espressif
sudo chown $username /opt/Espressif/
sudo cd /opt/Espressif
sudo git clone -b lx106 git://github.com/jcmvbkbc/crosstool-NG.git 
cd crosstool-NG
./bootstrap && ./configure --prefix=`pwd` && make && make install
./ct-ng xtensa-lx106-elf
./ct-ng build
PATH=$PWD/builds/xtensa-lx106-elf/bin:$PATH
cd /opt/Espressif
mkdir ESP8266_SDK
wget -O esp_iot_sdk_v0.9.3_14_11_21.zip https://github.com/esp8266/esp8266-wiki/raw/master/sdk/esp_iot_sdk_v0.9.3_14_11_21.zip
wget -O esp_iot_sdk_v0.9.3_14_11_21_patch1.zip https://github.com/esp8266/esp8266-wiki/raw/master/sdk/esp_iot_sdk_v0.9.3_14_11_21_patch1.zip
unzip esp_iot_sdk_v0.9.3_14_11_21.zip
unzip esp_iot_sdk_v0.9.3_14_11_21_patch1.zip
mv esp_iot_sdk_v0.9.3 ESP8266_SDK
mv License ESP8266_SDK/esp_iot_sdk_v0.9.3
cd /opt/Espressif/ESP8266_SDK/esp_iot_sdk_v0.9.3
sed -i -e 's/xt-ar/xtensa-lx106-elf-ar/' -e 's/xt-xcc/xtensa-lx106-elf-gcc/' -e 's/xt-objcopy/xtensa-lx106-elf-objcopy/' Makefile
mv examples/IoT_Demo .
cd /opt/Espressif/ESP8266_SDK/esp_iot_sdk_v0.9.3
wget -O lib/libc.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libc.a
wget -O lib/libhal.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libhal.a
wget -O include.tgz https://github.com/esp8266/esp8266-wiki/raw/master/include.tgz
tar -xvzf include.tgz
cd /opt/Espressif
wget -O esptool_0.0.2-1_i386.deb https://github.com/esp8266/esp8266-wiki/raw/master/deb/esptool_0.0.2-1_i386.deb
dpkg -i esptool_0.0.2-1_i386.deb
cd /opt/Espressif
git clone https://github.com/themadinventor/esptool esptool-py
ln -s $PWD/esptool-py/esptool.py crosstool-NG/builds/xtensa-lx106-elf/bin/

For less experienced users, we are preparing VirtualBox disk image which to run on Virtual machine on any OS like Linux, MAC OS, Windows, and everything inside is pre-configured and ready to use, hopefully we will upload this image on ESP8266-EVB web page tomorrow as we didn’t manage to complete it today.

Once you have setup the Tools you can download our examples from GitHub:

cd /opt/Espressif
git clone https://github.com/OLIMEX/ESP8266.git
cd ESP8266-EVB-blinkLED
make

the project will be compiled and you will see something like this:

AR build/app_app.a
LD build/app.out
FW firmware/0x00000.bin
FW firmware/0x40000.bin

congratulations you made your first code!

now we hae to load it to ESP8266-EVB

you need: ESP8266-EVB, 5V adapter like SY0605E, USB-Serial-Cable-F
connect the USB-SERIAL-CABLE-F to ESP8266-EVB UEXT connector as follows:

  • blue wire to pin#2
  • green wire to pin#3
  • red wire to pin#4

plug the USB cable to your computer USB connector and check which serial port it connects by typing:

lsusb

your computer should display something like:

...
Bus 004 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
...

if you type:

ls /dev/tty*

you will see:

.... /dev/ttyUSB0 ....

If the USB device is with different name you have to update it in the makefile.

After the code is compiled with no errors you can write it to ESP8266 by following these steps:

  1.  first you have to press button and hold it and to apply power 5V, ESP8266 will enter bootloader mode
  2. type ‘sudo make flash’ and wait until code is loaded:
sudo make flash
/opt/Espressif/esptool-py/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 firmware/0x00000.bin 0x40000 firmware/0x40000.bin
Connecting...
Erasing flash...
Writing at 0x00007300... (100 %)
Erasing flash...
Writing at 0x00061200... (100 %)
Leaving...

now Green LED must start blinking!

So far so good, you just made blinking LED on ESP8266, now let’s make something more complicated – to run Embedded web server on ESP8266, go to esphttpd project directory:

cd /opt/Espressif/ESP8266/esphttpd
make

then upload the code

sudo make flash

then upload web pages with:

sudo make htmlflash

Now ESP8266 firmware is uploaded and ESP8266 create Embedded server.

Scan for WIFI which name starts with ESP_XXXXXXX where XXXXXX is the ESP8266 MAC address and connect to this network then open browser at http://192.168.4.1 you will see this home page:

HOME

if you click on Relay button in the right side you will see new page:

RELAY

On this page you can switch the on-board relay by clicking on ON and OFF button

If you click on the Button button in the right side you will see new page:

BUTTON

If you click on Start scan the web page will start to refresh each second and display the button status if you click on Stop scan the page will not refresh.

This is very basic demo code which can be used as template for your own projects!

PIC-WEB-BOX demo video

Image

 

PIC-WEB-BOX is embedded PIC web server using Microchip’s Open Source TCP-IP stack with two buttons, RS232 interface, UEXT connector, two GPIO connectors, Status LED, 2GB Sd card for web storage. The power supply can be in range 9-30VDC and the low consumption makes this board perfect for controlling things over internet or to read sensors etc.

We setup video where you can see how easy is to program it and using the build-in bootloader you can change PIC-WEB-BOX firmware over the net via TFTP.

UART, I2C, SPI interfaces are available and the video demonstrate how you can drive 4.3″ LCD, Relays, measure temperature with thermocouple etc.

SD card with 2GB is build-in for web storage.

PIC-WEB-BOX is with small enclosure.

 

FREE shipping on all orders to Bulgaria above EUR 30 :-)

Image

Many may have noticed this, but now is time to make some buzz :-)

We quietly implemented FREE shipping option for all orders from Bulgaria which are with value above EUR 30.

When you enter in your basket items for more than EUR 30 on checkout page you will have one more shipping option: Free economy shipping (2 working days delivery) by Speedy which cost 0 BGN. Of course if you are in hurry you can still select the paid Speedy express shipping option (1 working day delivery), or to do local pickup from our office.

 

LPC2378-STK Tutorial: Implementation of PPP connection with TCPNet Stack

Image

Ohmohm tip us this tutorial via Twitter. Its in Russian language but you can use Google translate.

LPC2378-STK in this case act as web server and allow other devices to connect to it via PPP.

http://wiki.ru.com/index.php/90-art/16492-realizatsiya-ppp-soedineniya-s-pomoshchyu-steka-tcpnet

Web Server with MOD-IO + MOD-ENC28J60

Image

Doing embedded Web servers with microcontrollers is not new but Andrew Rossignol blogged recently that he made embedded Web Server with MOD-IO and MOD-ENC28J60, the catch is that MOD-IO have ATMega16 microcontrollers with only 16KB Flash and 1K RAM!

You can read more about his implementation on his blog

Good work!

Connecting Web Camera to A13-OLinuXino for video streaming

Image

In our previous blog post we setup demo where A13-OLinuXino-WIFI both was running web server with MOD-RGB control and at the same time was streaming video from Web Camera so you can see the result from the MOD-RGB control https://olimex.wordpress.com/2013/02/27/a13-olinuxino-serving-mod-rgb-and-web-cam-for-live-stream/

Here is description how the video streaming was done:

USB video cameras use UVC driver which is not enabled by default in A13-OLinuXino kernel so have to be enabled additionally.

  1. Installing UVC
  • # git clone https://github.com/linux-sunxi/linux-sunxi.git
  • # cd linux-sunxi
  • # make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- a13_defconfig;make ARCH=arm menuconfig
  • select in  Device Drivers -> Multimedia support -> Video capture adapters ->  V4L USB devices -> USB Video Class (UVC) (M)
  • # make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j5 uImage modules
  • # make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=output modules_install
  • # cp arch/arm/uImage /<sdcard mount point>/<FAT Partition>/.
  • # cp -aRv output/lib/modules/* /<sdcard mount point>/<EXT Partition>/lib/modules/.
  • # reboot
  • # modprobe uvcvideo

Now you have UVC support in your kernel and can use Web Camera for your Linux apps.

2.  Setup VLC Streaming

  • apt-get install vlc
  • # chmod 777 /dev/video*
  • # adduser vlc
  • # su vlc
  • # cvlc v4l2:// :v4l2-vdev=”/dev/video0″ :v4l-adev=”/dev/null” –sout
    ‘#transcode{vcodec=mpg1,vb=1024,vsize=320,hsize=240}:standard{access=http,mux=ogg,dst=:8080}’

last command is actually setting VLC streamer to stream mpg1 video 320×240 pixels at 8080 port, for more details check: http://wiki.videolan.org/

A13-OLinuXino serving MOD-RGB and WEB-CAM for live stream

Image

In the previous post I wrote how A13-OLinuXino runs Apache server and you can control MOD-RGB strip over the internet, now the A13-OLinuXino service is available online at : http://94.156.100.85:8081/RGB/ you can open this URL and see actually web pages served by A13-OLinuXino

What’s new Dimitar Gmishev did is to connect USB web camera to A13-OLinuXino too, so now you can see the RGB stripe response to the web cntrol.

To see the MOD-RGB stripe via the web cam you need video player – in our case this is open source Kantaris player with Ctrl-B you force it to play stream from internet URL and point it to : http://94.156.100.85:8080 and you will see the web cam video stream, so when you change the RGB color control you see the result on the camera!

Have fun and try it yourself

Previous Older Entries

Follow

Get every new post delivered to your Inbox.

Join 659 other followers