ESP8266 + temp sensor fail!

I’ve designed a few sensor boards that collect temperature, humidity, light, sound etc… and send them over wifi, or a local radio network. Recently I switched to the ESP8266, and had my first fail.

The temp sensor was mounted next to the ESP8266, which is fine until you turn everything on, and realise that the ESP gets warm and completely compromises the readings on the temp sensor.


Version 1

I designed a second version of the board, with some physical separation between the ESP and the temp sensor, making cuts into the board to stop the heat traveling through to the sensor area.

Version 2

Even with this change we still get heat transfer between the ESP and the temp sensor. Within 10 minutes of power up we have a 4°C rise in temperature readings.


At this point I have a few options

1. Re-design the board, giving even more physical separation between the ESP and the sensors
2. Add a heatsink to the ESP to try and dissipate the heat
3. Modify the software to put the ESP into sleep mode between sensor readings, to reduce heat output

I’ll try a combination of the second two, although ultimately a new board might be the better solution.

ESP8266 WifiClient Error

I’ve been writing some code for the ESP8266, using it to send sensor data to a server, to be logged and charted. I started with the WifiClient example, from the ESP8266 Arduino board manager.

I modified the example code to use multiple sensors, and came upon an issue. The board started resetting itself, leading me to think I had a hardware issue, especially since two boards were doing it.

I was receiving this error on the serial line

ets Jan 8 2013,rst cause:2, boot mode:(1,7)
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset

The watchdog seemed to be unhappy, and was resetting the processor.

I had commented out the following line, right after the data transfer had been started.

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

String line = client.readStringUntil(‘\r’); empties the read buffer, and is crucial, even if you don’t do anything with the results.

Putting this line back in fixes all issues.

So if you’re having issues with that sketch, with random watchdog resets, make sure you are reading the return data to clear the buffer, and keep the watchdog happy.


We’ve been running a series of workshops at Cambridge Hackspace over the last few months, getting people to build electronics projects.

The evening is spent learning basic soldering techniques, assembling and soldering the components, and then programming the Arduino software. Usually we learn a bit of fault finding too, as there’s always someone that applied too little or too much solder somewhere, and we have to track it down.


So far we’ve run workshops to build clocks and thermometers, we also have upcoming workshops building spectrum analysers, multimeters, wifi display screens, and internet connected environmental sensors.


The inspiration came from Paint Nite, a local company providing group painting classes, where you go home with your own painting to hang on your wall. You get to learn, create, and have something to show for it afterwards.

That’s exactly what we’re doing at hackspace, with a focus on electronics and software.

Not only do our up-and-coming electronic engineers get to benefit from the evening, but we get to earn some money too, which goes towards improving our workshop and making the space more appealing to new members.


ESP8266 as Arduino

You can program the ESP8266-12E as an Arduino, using the board manager plugin in the Arduino IDE. It’s great for deploying simple code with access to wifi, and at less than $2 (including shipping) it’s really affordable.

Because it’s made by multiple sources in China, and because they don’t seem to talk to each other, you get some inconsistencies between the seemingly identical boards.


Pins 4 and 5 are swapped on some of them, which means you have to account for this in your PCB designs. I2C runs on these pins, and so it’s important you have them the right way around.

The operation of the reset button is also different on different boards. Usually you need to press the reset button on power up to be able to program, but on some boards you need to keep that button pressed until the upload has started.

This makes the ESP8266 a potentially tricky board to use at first, if you don’t know the quirks.

Modify git commit timestamp

Sometimes it’s useful to modify the timestamp of a git commit, like when archiving old files (I usually want the timestamp to match when the file was last modified, rather than todays date)

This can be done easily once the files have been committed, but before they are pushed

git commit --amend --date "Apr 19 19:12:01 2010"
GIT_COMMITTER_DATE="Apr 19 19:12:01 2010" git commit --amend

You can now see the updated timestamps in your git history, and can push you’re file to Github with a more appropriate timestamp.

Rocketeer on Laravel 5

Using Rocketeer to deploy code with Laravel 4.2 is nice and easy, using the standard Rocketeer library in Laravel’s composer file. Rocketeer doesn’t play so well with Laravel 5, and so we have to approach the install from a different direction.

The solution here is to use composer to install Rocketeer globally.

composer global require anahkiasen/rocketeer

Config files can then be found in the .rocketeer folder, you can also setup your environment using the ignite command

rocketeer ignite

Then, to deploy your code you can use:

rocketeer deploy



If this method doesn’t work, you can download the file manually

chmod +x rocketeer.phar
sudo mv rocketeer.phar /usr/local/bin/rocketeer

Full Server

Recently one of our app servers stopped serving, the server was running, but it had run out of disk space. The database wasn’t too large, and the Laravel apps log files weren’t massive.

The first stop then was to find any large files, to see what was clogging up the system.

find / -size +10M -ls

This revealed a 17Gb log file: /var/log/mysql/mysql-slow.log

It appeared that MySQL was taking it’s time with some queries.

We sync our database with various external APIs every day, these are inserted in bulk, so I don’t mind them taking over 0.1 second to run (the default slow-query log threshold set in our mysql config). What I do mind is having the server run out of space due to large log files.

Read More

Laravel to Digital Ocean using Server Pilot and Rocketeer

Recently I have been using Digital Ocean, they provide simple, quick, secure, and easy to setup servers which are perfect for hosting Laravel projects. They use SSD drives, take less than a minute to create, and cost as little as $5 a month, pretty nice!

I also recently discovered Server Pilot, a *really* easy way to manage your new server. With one line of code in terminal it sets up the server ready for use. It installs ngnix + Apache (yes, both at the same time), deals with security, then makes virtual hosts, ssl certificates and mysql (including security) as easy as 1 click.

Rocketeer is a deploy script, used for deploying php code simply, it integrates with Laravel nicely too.

Laravel is my MVC framework of choice, and here’s how I get it running on Digital Ocean using Server Pilot and Rocketeer.


In this post we’ll be

  1. Creating a Laravel project on your local machine
  2. Uploading that to Github or Bitbucket (I’ll be using Bitbucket)
  3. Creating a server on Digital Ocean
  4. Using Server Pilot to setup the server for our needs
  5. Logging into the server to confirm a few basics
  6. Using Rocketeer to deploy our code to the server

This guide assumes you can use git, and you have accounts with the following sites:

It also assumes you have Git, Composer, and PHP installed locally.

Right, lets get stuck in!

Read More

PiTFT – Load the desktop with a physical button (startx)

I recently discovered the PiTFT screen, a 2.5″ TFT screen from Adafruit that sits on top of a Raspberry Pi. You can send it images, video, or set it up as a desktop environment. This became immediately appealing as I realised I could setup the pi as a webserver for my home automation, and load the browser fullscreen to interact with it. Oh yeah, it has a touchscreen, making interacting with the interface really nice.


One small issue it getting the screen to start a desktop. You have 2 options:

  1. Start the pi, connect to ssh and type startx
  2. Start the pi and make the default desktop the tft (meaning no output anymore on hdmi)

Neither of these are great, one involves having to login every boot, the other means you don’t get your regular desktop over hdmi.

Enter option 3!

Read More

Parsing csv/tsv with Laravel 4

We needed to parse tsv files in one of our projects, and I found some nice code to achieve that –

Getting this to work with Laravel is actually quite easy, although undocumented.

1. Add goodby/csv to your composer file

    "require": {
        "goodby/csv": "*"

2. Update composer

composer update

3. Add the following lines to the aliases array in the app/config/app.php file

'Lexer' => 'GoodbyCSVImportStandardLexer',
'Interpreter' => 'GoodbyCSVImportStandardInterpreter',
'LexerConfig' => 'GoodbyCSVImportStandardLexerConfig',

4. Run your code

$lexer = new Lexer(new LexerConfig());
$interpreter = new Interpreter();
$interpreter->addObserver(function(array $row) {
    // do something here.
    // for example, insert $row to database.
$lexer->parse('data.csv', $interpreter);

Full docs can be found at