I’ve been getting back into the ESP8266 now that there is an Arduino port for it. I’ve not used the full IDE, just installed the hardware core into my existing vanilla 1.6.3 IDE using this setup.

I then made a little DS18B20 and ESP-01 module, which runs off of 2xAA batteries which are boosted to 3.3v using the Pololu step-up regulator. It started off as a 3xAA battery setup with a diode dropping the voltage down from 3.9v to 3.1v:


I then made a sketch that allows you to toggle an LED and read back the temperature. Other webserver examples didn’t work well – I think there was a memory leak as the sketch would only run for about 4 loops before hard crashing the unit, this version is also much faster:

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// configure wifi
const char* ssid = "myessid";
const char* password = "mypassphrase";
ESP8266WebServer server(80);

String form = "<form action=&#039;led&#039;>
  <input type=&#039;radio&#039; name=&#039;state&#039; value=&#039;1&#039; checked>On
  <input type=&#039;radio&#039; name=&#039;state&#039; value=&#039;0&#039;>Off
  <input type=&#039;submit&#039; value=&#039;Submit&#039;></form>";

// configure io
const int ledPin = 2;
OneWire oneWire(0);
DallasTemperature ds18b20(&oneWire);

void handle_led()
    // get the value of request argument "state" and convert it to an int
    int state = server.arg("state").toInt();
    digitalWrite(ledPin, state);

    // ds18b20 temperature
    float celsius = ds18b20.getTempCByIndex(0);

    server.send(200, "text/html", String("LED is now ") + ((state)?"on":"off") + "<br>Temperature: " + celsius + "c");

void setup()
    // debugging

    // configure ds18b20

    // configure led
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin, LOW);

    // connect to wifi network
    Serial.println("Connecting to ");
    WiFi.begin(ssid, password);

    // static ip, gateway, netmask
    WiFi.config(IPAddress(192,168,1,100), IPAddress(192,168,1,1), IPAddress(255,255,255,0));

    // connect
    while (WiFi.status() != WL_CONNECTED)
    Serial.println("WiFi connected");
    Serial.print("Use this URL to connect: ");

    // set up the endpoints for http server
    server.on("/", [](){
        server.send(200, "text/html", form);

    server.on("/led", handle_led);

    // start the webserver
    Serial.println("Server started");

void loop()
    // check for incomming client connections frequently in the main loop:

I also made a adapter for the Wroom version of the ESP8266 as donated by Espressif:



I can flash firmware to it, and using esptool.py I can read back its Mac address, FlashID and even a memory dump, but I can’t get it to boot into anything useful. I assume the bootloader is somehow locked so that it won’t run custom firmware.

As the bootloader runs at a weird 74880 baud, I had to use the Mega2560’s 2nd hardware UART (pin 19=RX and 18=TX) to read it back as Linux doesn’t like that baudrate. The sketch is:

void setup()
    Serial.begin(9600);   // usb
    Serial1.begin(74880); // esp8266

void loop()
    // read from port 1
    if (Serial1.available())
        // write to port 0
        int inByte = Serial1.read();

And the output was:

ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 32640, room 16 
tail 0
chksum 0xef
load 0x00000000, len 0, room 8 
tail 0
chksum 0xef
aoad 0x00000000, leoacxmc

In flash mode it’s (1,7).