Tag Archives: esp8266

The Arduino (or in some cases also Genuino) is a physical hard and software development plattform. During the recent years its developing environment grow to a useful and library rich developing platform. Because of that the esp8266 team created an conversion tool to its internal programming language lua.

Setting up the Arduino IDE for esp8266 programming is really easy. Just follow this small guide.

Step 1: Download the arduino IDE software

Go to the most recent version download page of the Arduino IDE. Please keep in mind that you’ll need at least version 1.6.x. In some cases it is not available at the packet repositories of your beloved Debian Distribution.

Click on Windows, Linux or Mac Version of your choice. We are going to use the Linux 64bit for further pictures.

Extract the provided tar.gz. For windows or Mac please use a extraction software like 7zip, Winrar etc accordingly.

Please make sure the arduino.sh file in your directory is excecutable.

You also can use the terminal command:

Shell

1

chmod+x-/arduino.sh

After that double click the application…

or use the terminal to start the IDE. This is also very useful to see possible errors after they occure while flashing the esp8266 from time to time.

Et voila, your IDE should look somehow like this:

Step 2: Setting up the IDE to work with ESP8266 by board manager.

We need to add an additional url to the boards manager sources list. For that open File > Preferences

And add
http://arduino.esp8266.com/stable/package_esp8266com_index.json to the Additional Boards Manager URLs.

After that open Tools > Boards > Boards Manager and search for esp8266.

install the latest version:

After that you should be able to select the Generic ESP Module board in Tools > Board

Congratulations! You are now able to compile esp8266 code from the arduino IDE.

Step 3: Use the Examples to learn to code

This step is easy. Open File > Examples > ESP8266Wifi > WifiWebServer as a good starting point.

In the next post we will have a look at how to wire the ESP8266 up for an easy flashing.

Today I built a small wifi light which rotates in case a certain hostname (my smartphone) is in the local wifi. As these devices tend not to answer to ping or arp requests, and bonjour or mDNS where to slow, I crawl my dhcp server every five to ten seconds. Additionally i decreased the lease time of the dhcp to improve the switch off response time. As my smartphone usually logs into my wifi instantly when I enter the house it’s usually switches on before the main door has been opened.

The interior of the lamp consists of seventeen ws2812b rgb leds which I controlled in an intermediate stage with the esp2866 opc code on github. As this would have required a constant network packages flow and a device delivering the UDP packages, I later on switched over to control the led animation by the esp8266.

Something I discovered today is that soldering the 2mm grid esp8266 upside down onto a 2.54 grid prototyping circuit board improves handling and speed, as well as the size of the final circuit. You also can see the pin map information on the final product, which is nice.

After putting some hot glue on the board to prevent shorts and improve lifetime, I took some measurements regarding current consumption: about 0,1Amps at 5V, which should result to 0.5W with a constant rotating light and wifi crawling. This makes the device capable to be run on most USB power providers. The final result looks like this in action:

As the code is very specific and dependent on my local setup, I will not post it on github this time. Just one thing I would have found really helpful to find in the internet while I was struggling with a constantly without information resetting esp8266 would have been this:

Howto grab and parse a HTTP.Auth protected website with the esp8266 as a client:

Arduino

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

boolgetPage(){

boolfoundHost=false;

WiFiClientclient;//initialising the client globally leads to crashes

if(client.connect(http_site,80)){//the more common version !client.connect() crashes

// We now create a URI for the request

Stringurl="/dhcp";

// This will send the request to the server

client.print(String("GET ")+url+" HTTP/1.1\r\n"+

"Host: "+http_site+"\r\n"+

"Authorization: Basic YWRTeW4kYWRmaW4=\r\n"+//this is Http.Auth as a Client (Base 64)

"Connection: close\r\n\r\n");

delay(500);// you'll need to wait until repsonse

Stringline="";

// Read all the lines of the reply from server and print them to Serial

while(client.available()){

line=client.readStringUntil('\r');

//Serial.print(line);

if(line.indexOf(hostname)!=-1){

foundHost=true;

break;

}

}

}else{

Serial.println("connection failed");

}

}

In conclusion, this was a nice little project I really enjoyed doing in a sleepless night 🙂 And with about 10€ plus the lamp I got as a gift a long time ago, not that expensive.

I recently built an WLAN Thermometer which needed to be partly whaterproof and support temperatures under 0 and over 85 degrees celsius. Therefore the usual temperature measurement chips like DHT11 or LM35 couldn’t be used, especially as the surrounding circuits might be damaged by the steam of the sauna environment. After a while I found the DS18B20, which has an metalic and whaterproof end and perfectly matches the requirements. In china the one-wire-supporting chip currently costs around 2 USD and comes with a 1m whaterproof cable.

Top

back

from above

The ESP8266 works with 3,3 Volts which isn’t very common among my old power adapters which is why I soldered a chinese version of the AMS1117 (an Lm2596 step down controller) on the board, which enables the setup also to be run by USB cable as you can see on the pictures.

For the webinterface I wrote a small external javascript file, which gets called by the esp8266 on most web requests. It fetches the temperature by json and visulizes it with d3.js in real time. The scales fit to the measured temperature and time automagically. It further is possible to display the site on multiple clients without loosing data or performance.