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.

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.

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

Laravel 4 SSL on single instance AWS Elastic Beanstalk

Setting up SSL on Laravel 4 on an Elastic Beanstalk server is tricky, there are a couple of land mines to avoid, which took me a day of coding to find and resolve.

This guide will help you through the process, and will remind me when I next have the problem and am searching for the solution – you’re welcome future me!

  1. Apply for your secure certificate
  2. Create singlessl.config file in your .ebextensions folder
  3. Copy in your certificates
  4. Teach Laravel how to identify a secure connection (It’s not as simple as it sounds)
  5. Update all internal links to https
  6. Deploy

Read More