ESP8266-EVB Lua MQTT example

mqttorg-glow

MQTT is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol. It works like Twitter – you have many sensors which post so main server their info which is streamed and other clients/users can subscribe for sensors of interest out of the whole stream. The advantage is very lightweight protocol and low bandwidth usage.

Another advantage is that the sensors do not need specific IP address to operate, they establish the connection to MQTT server and thus you do not need to specially configure your home network to map ports using NAT etc. You just need internet connection, then the sensors connect to the server and send their info.

Peter Lalov sent us today link to his MQTT implementation for ESP8266-EVB with Lua, the project is open source released under BSD-3 licensee on Github.

Espressif ESP8266 Bug Bounty Program – Report a bug and win USD1000

ESP8266-EVB

Espressif is working hard to remove bugs in their very popular ESP8266 WiFi SoC. They want to make superior solution to CC3000 competetive product from TI, which is well known for it’s security issues.

So on March 20th Espressif boldly posted on their BBS the Bug Bounty Program – they will give USD 1000 to anyone who reports bug in ESP8266 .

We are working intensively with ESP8266 to make our plug and play IoT solution with pluggable UEXT modules to ESP8266-EVB and one of our developers Peter found bug in SSL implementation where you can brick or reset ESP8266 by sending large amount of data over https. He reported the bug to Espressif and today he got this e-mail:

From: Quote
Sent: Wednesday, April 8, 2015 5:26 PM
To: peter@
Subject: ESP8266-Bug Bounty Winner Information Requirement (BBP#29)

Thank you for your bug report, which will help us improve our SDK.
Our engineer has confirmed your bug report and they will release debug method to you later.
I am assigned to give the reward to you.
Please provide some information to us, which is needed for us to keep record.

a.. The company you are working for
b.. Your name
c.. Your nickname that you want to be announced
d.. contact number or mail
e.. Paypal account or bank account
You should declare tax according to your local law by yourself.

Yay! Quick USD1000 earned 🙂 Glad to see Espressif stands behind their word.

And from the e-mail header seems Peter is not alone but #29 in the Bug Bounty Program.

In other hand if they have decided to open source their binary blobs these bugs would be fixed by the community (which is huge and growing with each next day). So they could save themself these $30K.

Having the sources would also make less nervous people who want to use ESP8266 in more serious stuff where is not good to have “black boxes” with unknown code inside.

Programming ESP8266-EVB with Arduino IDE

arduino

 

We made Arduino style library to easy the stand alone ESP8266 programming, but we were not using any IDE but mostly command line compile and programming. Two of our developers decided to use Eclipse and set it up for ESP8266 tools.

Yesterday we spotted on ESP8266_wiki GitHub account that someone already add support for ESP8266 in the latest Arduino 1.6.1 IDE release, how cool is this?

I decide to try it today. I downloaded the pre-build binaries arduino-1.6.1-linux64.tar.xz and decompress it in /home folder then ran terminal and “sudo ./arduino” in the Arduino-1.6.1 folder, the Arduino IDE was launched.

Then I connected USB-SERIAL-Cable-F to ESP8266-EVB Open Source Hardware board UEXT connector connecting blue wire to PIN2, the green wire to PIN.3 and red wire to PIN.4 on the UEXT connector as on this picture:

esp8266

Then in Arduino IDE I Selected Tools->Board-> Generic ESP8266 board

Then connected USB-SERIAL-CABLE-F to USB and selected Tools-> Port -> /dev/ttyUSB0

Then selected Tools-> Programmer->esptool

From examples loaded Blink LED then changed the port 13 to port 5 where the relay is connected.

I pressed the ESP8266-EVB button and connect 5V power supply to board to make it enter in bootloader mode, then click on Upload button.

The sketch was compiled and uploaded successfully then the relay start to switch on and off like expected.

Well done! I didn’t check all the libraries, but I see inside demos for web servers etc.

 

Free ESP8266 Workshop – March 7th in Olimex training building

ESP8266

ESP8266 is amazing low cost little device which allow you to run web server on it and to connect embedded devices to Internet via WiFi. We organize free ESP8266 workshop in our training building on 7th of March starting at 14.00 o’clock.

Some of the topics which will be discussed:

  • Where we are with ESP8266 development boards, new boards and plans.
  • How to install all tools necessary for development with ESP8266.
  • How to make your first blink LED program.
  • How to make simple web server.
  • New Arduino style library for ESP8266 with GPIO, ADC, DAC(PWM), SPI, I2C, Serial. Access to the 2MB Flash in Olimex modules for data logging, web pages and more.
  • How to develop with Lua and MQTT with ESP8266.
  • New Plug and Play firmware for ESP8266-EVB with automatic recognition of UEXT modules connected for measurement of temperature, humidity, accelerometer, LCD, etc.
  • How to make web server with secure access
  • Low power modes and battery operation.

Everyone is welcome! If you have project with ESP8266 which you want to share or make lighting talk about please send us e-mail to include you in the workshop program.

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!

New Product in stock: ESP8266-EVB the ultimate Internet of Things development board

ESP8266-EVB

We now have in stock ESP8266-EVB.

It’s small 57 x 50 mm development board with MOD-WIFI-ESP8266-DEV board on socket, Relay 250VAC / 10A, button, UEXT connector, 0.1″ step connector with all ESP8266 signals. Power supply 5V jack.

The board price is EUR 9.95/ea

The demo code we work on now will create WIFI AP hot spot where you can connect with any device with WIFI capability, then from the web page you can switch on/off the relay, read the button status and send I2C or SPI commands. Small tutorial how to setup the GCC and SDK also will be blogged this week.

The button is with dual purpose, it’s general purpose button, but if it’s pressed during power up the ESP8266 will go in bootloader mode and you will be able to upload new firmware in the chip.

To upload code you will need any USB to serial 3.3V converter like USB-Serial-Cable-F which directly plugs to UEXT pins.

ESP8266-DEV can be powered with SY0605E.

ESP8266-EVB is run in production, to be in stock before Christmas

ESP8266-EVB

ESP8266-EVB is complete and run in production, we hope to have it assembled and tested in stock before Christmas 🙂

What we got here?

  • MOD-WIFI-ESP8266-DEV module with soldered connectors
  • Base board with female connectors for accepting MOD-WIFI-ESP8266-DEV
  • Power Relay 10A/250VAC connected with driver to GPIO output
  • User Button connected to GPIO input
  • Power supply jack – 5V input
  • DCDC power converter to 3.3V to supply ESP8266 and UEXT modules with up to 1.5A current
  • UEXT connector where you can connect different modules and sensors from Olimex
  • GPIO  CON3 with 16 pins where all ESP8266 resources are available
  • 4 mounting holes

The price of ESP8266-EVB (which includes MOD-WIFI-ESP8266-DEV) will be EUR 12.00 for single quantity and will drop under EUR 10 for 50+ order.

ESP8266 update – The Ultimate Development boards for ESP8266 are in stock

MOD-WIFI-ESP8266-DEV-1 MOD-WIFI-ESP8266-DEV-2 (1)

ESP8266 already got a lot of attention, but the problem is that this chip has more to offer than just UART to WIFI module, there is C compiler, SDK which allow you to write user program and have access to all GPIOs and resources of the chip so instead to add dumb microcontroller to ESP8266 module you will be able to put all your application in the ESP8266 itself.

The problem is that most existing modules do not allow access to all ESP8266 resources… until now, you see the untilate development board for ESP8266 now, it have access to all ESP8266 resources, GPIOs, bootloader etc.

The module MOD-WIFI-8266-DEV have UEXT connector footprint on the back so it can connect to all OLIMEX boards which have UEXT connectors, two rows of 0.1″ connectors for breadboarding and split pads which could be soldered directly to PCB.

MOD-WIFI-ESP8266-1 MOD-WIFI-ESP8266-2

For these who want to use ESP8266 just as SERIAL-to-WIFI bridge MOD-WIFI-ESP8266 is the better choice with smaller size and soldered female UEXT connector it direcly will plug to any board with UEXT.

Both boards are in stockMOD-WIFI-ESP8266 cost EUR 5.00 for single quantity,MOD-WIFI-8266-DEV  cost EUR 5.50 in single quantity.

MOD-WIFI-ESP8266-EVB with Relay, button, Power supply, GPIOs access is in production and will be available in couple of weeks! It have on it MOD-WIFI-ESP8266-DEV on socket.

ESP8266 WIFI chips and modules arrived

ESP

Recently we blogged about the new ultra low cost UART to WIFI modules based on ESP8266 ICs. Today the WIFI modules and sample chips arrived so we can finally test them.

The low cost $5 modules focused the interest of many people. We already have translated datasheet, forum and some people even started write code for Arduino without having these modules at all 🙂

One problem I see is that there are no official schematic with components with values nor reference design. We are going to change this as we already got 3 different modules and the components around ESP8266 are not so many, so we will capture the schematic and make reference PCB layout in the next few days.

Hackaday.io 

ATcommands

Tutorial

Forum

Next Newer Entries