Olimex ESP 8266 dev with Arduino IDE

Bits and pieces of this are everywhere but I’ve not found it all in one place. The ESP Thing docs are excellent and mostly apply to the Olimex too, but there are some subtleties in the setup. I’ve put what I did here so I remember how to do it again.

I had a few ESPs I’d bought in May and not used – these ones from Olimex. I read recently that you can now use ESPs from the Arduino IDE, so I thought I’d give it a go.

The goal is to be able to put some code that uses wifi on the ESP using the Arduino IDE. The basic flow is:

  • Buy ESP and an FTDI USB to Serial cable, plus a small breadboard and some male-male jumper wires, and a cheap voltage regulator
  • Solder the ESP’s legs on
  • Put it in the breadboard
  • Connect it up to the FTDI cable
  • Put it in FTDI mode(?)
  • Plug it in to USB on a laptop and test it using the serial monitor on the Arduino
  • Download the Arduino ESP environment and load it in to the IDE
  • Put test code on the ESP and check it worked

Buy ESP, FTDI and other bits

I think if I was buying them now I’d get some of these ESP Things,  as they have a bunch of nice features (though not many GPIOs), but the excellent docs seem to apply to the ones I have too.

Edit – I was under the misapprehension that FTDI cables could supply 3.3V. No idea why, unless I misread the labels for some of the other outputs. But anyway: the one I bought doesn’t. You can’t use a voltage divider to get the voltage you want either, because that only works for things with tiny amounts of resistance. But, you can get a voltage regulator (e.g for 99p at Maplin) which gives you 3.3V from 5V happily enough.

5V will fry your ESP (though actually it didn’t fry mine), so do this or use a separate power supply (e.g. 2 AA batteries will work).

Solder the ESP’s legs on

I think I soldered mine’s legs on upside down, because the names of the pins were on the underside, although it’s the same way up as the Fritzing component, conveniently. Here’s the pinout document I eventually found. Here are the pin names as written on the board from the perspective I needed (some of them differ from their internal names, no idea why):

esp_pins

Put it in the breadboard

Put it across the middle, like this:

esp_breadboard

Connect it up to the FTDI cable

Like this:

esp_ftdi

The ESP will be powered from the FTDI (red jumper). Ground across the board to GPIO0 (21) puts it in FTDI mode (black jumpers). Yellow is RX, orange is TX.

Put it in FTDI mode

The Olimex docs suggest that you need to solder and desolder the dip switches, the three little fellas between pins 3 and 20 in the diagram above. What worked for me is to leave them as they came (which was as in the diagram above, which I think is 0 0 1). I’m fairly confused about why this worked, as the Olimex site says it comes in Flash mode, so maybe I have it upside down or something. But it did work.

Plug it in to USB and test it using the serial monitor on the Arduino

You can apparently use screen for this, but I couldn’t get it to respond “ok”.

screen /dev/tty.usbserial-A402O05B 115200

(Your serial port name will differ).

But, opening up the Arduino IDE and then the serial monitor (selecting the correct port) did work. The baud rate is 115200 – follow the link above for the commands and process.

Download the Arduino ESP environment and load it in to the IDE

These instructions worked very well for me. Make sure you actually select the board! (or else you’ll get strange errors with compiling and end up down a rathole of installing libraries manually. There’s no need, and they’ll conflict).

Then connect up the ground to GPIO0 (21) if you haven’t already, else you’ll get errors uploading like this:

warning: espcomm_send_command: wrong direction/command: 0x00 0x08, expected 0x01 0x08

Put test code on the ESP and check it worked

I used this code example, putting a little edit in the name I could actually find my board on phant. It worked!

esp_ftdi

 

 

A cheap BTLE button with Android

Thanks to the marvellous @fiverfun I have a few Bluetooth LE buttons at £3 a pop. I’m not sure what I want to do with them yet, but well, £3 each, who could resist?

anti-lost

They took a month to come and arrived just before Christmas, and I persuaded Richard to install the app (iTracing) on his phone via the QR code on the instructions, but it (a) didn’t work and (b) when I tried it later on my phone, kept turning the sound on and making a horrible siren noise. I uninstalled it.

Fortunately Sylvek has already had the patience and enthusiasm to  work out the protocol these buttons use and made available an Open Source app that does actually work with them. The rest of this post is some quick instructions on how to compile an Android app on the command line, and install it via adb via Mac OS X (I have a Wileyfox Storm running Cyanogen). I’d never done it before, and it was pretty easy (I had Java and adb installed already).

Check you have Java

java -version

Download gradle

curl -O https://services.gradle.org/distributions/gradle-2.10-all.zip
unzip gradle-2.10-all.zip
cd gradle-2.10

Download the Android sdk

Get the tools (this part took a while)

cd android-sdk-macosx
tools/android update sdk --no-ui

fix this issue with gradle-2.10

git clone https://github.com/sylvek/itracing2
cd itracing2

Tell Gradle where things are

export PATH=$PATH:/Users/libbym/android_button/gradle-2.10/bin
export ANDROID_HOME=/Users/libbym/Development/android-sdk-macosx

Do whatever it is that Gradle does

gradle assembleDebug

Find the output

ls app/build/outputs/apk/
> app-debug-unaligned.apk app-debug.apk

Install on a connected device (you need to enable developer mode: 7 taps on the Settings>About phone>Build number field and then enable USB debugging: Settings>Developer Options>USB Debugging. Make sure you have a USB data cable. For my Wileyfox I had to add 0x2970 to ~/.android/adb_usb.ini to trigger it to authorise the laptop.) Then:

adb install app/build/outputs/apk/app-debug.apk

Done!

Helpful links:

Critical IoT Reading List – Summaries

I’m doing quite a lot of reading lately, and one topic area is the “Internet of Things”. My favourite article on it at the moment is by Bruce Sterling – who argues eloquently that we’re just vassals in the next epic fight between tech giants – and he tweeted this list of critical IoT articles a new days ago, so I thought it was worth a look.

So: here are a quick summaries of the articles on that list. Some articles are much shorter than others, some covering many topics, some just one interesting idea. Almost all of them mention the fridge. This is all my own opinion and skewed towards my particular obsessions.

The articles are from 2013 to November this year (2015). The main themes I found were these:

  • Motivation, nudging, measurement and the limitations thereof – and associated monitoring of people and fitting them into a specific fixed set of behaviours
  • Ownership and inheriting of devices; identifying and debugging them, resetting them, interrogating them
  • Colonisation of the home by big tech companies: and the associate movement of data to the cloud

The most interesting ones for me were Dan Lockton on co-construction, Evan Selinger on the problems with “enchanted things”, Scott Smith in  an audio interview about always-on listening devices, Justin McGuirk on monitoring data and preventing proscribed behaviours, and my favourite, I think: an interesting, thoughtful article by Stephanie Rieger based on her experiences of the objects you “inherit” when renting a home. McGuirk’s article made me think that everyone in this field should try a Nest: I find it a very creepy experience (they ‘blink’ as your walk past), because they ‘need to’ know if there are people home.

Data Dada and the Internet of Paternalistic Things by Sara Watson, and Lich House by Warrren Ellis are two nice pieces of design fiction writing, well worth a read, as is Quinn Norton’s eloquent rant about how broken computer security is. And The Internet of Things You Don’t Really Need by Ian Bogost is a fun read on the uselessness of most of the proliferation of products.

Here are brief summaries of all the articles on the list with some further links I found at the end.


As We May Understand, Dan Lockton, November 2014

Interesting and long. Lockton argues that the internet has enabled people to create and understand their world better, and he’s interested in behaviour change that might result from this understanding. These changes could come from IoT devices and data – but one size doesn’t fit all and behaviour change has to be in context. He wants to people to connect their behaviour to the larger system – to understand the relationship between the individual behaviour (dropping litter) and the aggregate results (poor living environments).

He argues that the IoT is a community of people trying to solve problems, in an interesting, constructivist way (learning by doing, goal is exploration and linking physical to the abstract world), but it’s a fairly small, closed world. Co-construction – facilitated exploration with a diverse set of people – would lead to a more nuanced view of the IoT world. It helps the IoT community, but also the people involved:

“We can only trust something if we think we know how it works… When we don’t know how a thing works we make it up.”

This is similar to some of our thinking around Radiodan.


The Internet of Things Will Ruin Birthdays Joanne McNeil, July 2014

She’s right! Birthday harrassment and co-opting by companies.


If This Toaster Could Talk  Alexis Lloyd, September 2013

A classification of the new properties of connected objects to objects as portals, objects as subjects, and objects as oracles. And a link to this interesting piece of speculative fiction by Warren Ellis.


Too Much Magic, Too Little Social Friction , Evan Selinger, January 2015

Critical review of a book by David Rose, who talks about enchanted objects as an alernative to cyborgian future (fashionable adjuncts to our bodies) or one of glass everywhere (screens). Critical, because:

  • “Magic” hides the complexity of how things got there, including the social and economic processes:

“The magic is founded on grossly underpaid, casualized labor”

  • Motivational fitness, communication of stats and nudging, and especially communication of emotional states – speeding them up and simplifying them isn’t a good thing, it’s a bad thing. The communication is a part of it.

“Far from “effort” being a bug that limits interpersonal relationships, it’s an essential feature.”


Stepping Down: Rethinking the Fitness Tracker,  Sara Watson, September 2014

Experience of a Fitbit after surgery, and doubts that the one size fits all is useful


Honeywell, I’m Home! The Internet of Things and the New Domestic Landscape, Justin McGuirk, 2015

Good summary of the issues around the “smart home” with an  architectural slant. He argues that the sharing economy is leading to a “commodification of the domestic space”. Nest is maybe the paradigm of a “data hoover”.

“The home, then, becomes an extension of our immaterial labor. It is the producer of metrics.”

and the effects of monitoring and judging us on this data:

“the ever-watchful Evgeny Morozov […] calls it “solutionism.” In the name of efficient problem solving, we increasingly rely on sensors, apps, and feedback loops, and then these tools are designed to elicit prescribed forms of behavior.”


‘Dumb’ Smart Gadgets: The Bubble is Set to Burst — Christopher Mims, May 2015

Opinion piece in the Wall Street Journal: most IoT objects are useless, and most depend on a non-existent ecosystem.


Things Get Weird When Objects Get Hooked Up to the Internet of Things Scott Smith, July 2014.

Using Nest IFFT recipes as a way to understand what people want from it

“And, probably, soon enough someone will create an actual chilling effect via Nest when the party you oppose pushes a law through”


Kids and the IoT — Backchanneled — Changeist

Document missing.


Quantified Us  Susan Cox-Smith

Can we get away from the narcisim of self-tracking and do something more useful? Doesn’t really talk about privacy though.


The Ethics of Experimentation and the IoT , Anthony Townsend

What if Nest started experimenting on us? (eek)


The Anxieties of Big Data, Kate Crawford, May 2014

Big data needs small data methods to understand it.


Talking to CBC Spark about Emotion and the IoT , Scott Smith, Jan 2013

An audio discussion about monitoring (always-listening devices) and emotion (6 minutes), featuring pattern-matching to the typical, and the ethics and exploitation of difficult mood states or emotions. One for Rain, maybe?


The Machines Are Coming, Zeynep Tufekci, April 2015

Machines are replacing humans in work, reducing their bargaining power. and we should all Be Afraid, yes, even you.


Data Dada and the Internet of Paternalistic Things, Sara Watson, December 2014

Very nice short piece of design fiction about devices sharing data and our inability to debug it.


Public Engagement on the Internet of Things is Essential, Sonia Bussu, December 2014

A summary by an LSE academic of some research around public attitudes to technology changes.

“There is a demand for accountability and governance to respond to concerns of privacy, safety and security, guarantee competition and choice (including opt-out choices) and address questions of unintended consequences and liability
Support for technological and scientific advances will most often depend on individuals believing that they, or the wider society, rather than just companies, will benefit
There are concerns around who’s in control and who’s driving the development and direction of research (commercial imperatives vs. societal values).
Issues of equality are often raised: will new technologies produce big winners and big losers?”

She argues for inclusion and consultation on IoT.


Broke and Scared: The Home of the Future — Ben Valentine, April 2014

Similar issues, examples and references to honeywell-im-home above.


The Internet of Things Will be an Internet of Obsolete Junk Toby Miller, Jan 2015

It’s all in the title.


Everything is Broken, Quinn Norton, May 2014

Eloquent rant about how broken security on computers is


Why Tech’s Best Minds Are Worried About the Internet of Things  Klint Finley, May 2014

A Wired report about a summary of interviews with 1606 tech experts, concluding they didn’t like the idea of the IoT because of:

  • Security
  • Privacy
  • Dehumanisation through tracking

The full report is more interesting and more positive:

  • Logistics efficiency improvements
  • Ideas about private clouds
  • Interfaces of various kinds

The Changes Leading to a Hyperconnected World Will Change Our Values and Identities, Iiris Lagus, November 2015

Just a question really: will IoT devices change our values, and if so, how? (because societal changes affect what we think is important).


The Internet of Things You Inherit or Leave Behind,  Stephanie Rieger, October 2015

Interesting, thoughtful article based on experience of the objects you “inherit” when renting a home, and how it’s not currently part of the inventory:

“I suspect that in the not too distant future, tenants will start demanding a detailed list of what software is installed and where, whether it can be updated or reset to suit new occupants, how easy it is to do so, and who bears responsibility for any associated cloud subscriptions or service costs. “

The importance of identification and interrogation of devices (could IFFT help here too?)

“Smarter and more connected objects may ironically be far more opaque as some (or all?) of the interface may be mediated through software. “

Reminds me of fighting with hotel TVs and particularly the ‘fun’ of batting the bluetooth devices in “Citizen M” in Amsterdam.

“There’s a huge opportunity for brands to develop thoughtful, resilient and sustainable products and ecosystems that truly consider the diversity of contexts and needs related to choosing a home and making it your own — even if just for a week or night.”


Why Smart Objects May Be a Dumb Idea, Zeynep Tufekci, August 2015

Concerns around networked cars


The Internet of Things You Don’t Really Need, Ian Bogost, June 2015

“There’s an infomercial quality to these products. “Take the guesswork out of grilling” with GasWatch. Act now, and get not one, not two, but four Bluetooth wireless-technology enabled GasWatch propane tank meters before the crowdfunding campaign expires.”

and

“It’s time to admit that the Internet of Things is really just the colonization of formerly non-computational devices for no other reason than to bring them into the fold of computation.”

Other links

Raspberry Pi – create an access point for easily getting limited input devices on wifi, chromecast style

Update: thanks to Andrew Nicolaou there is now a better way of doing this.

Getting devices on a wifi network easily is one of the most annoying things about IoT type devices, so being able to do this in a user-friendly manner is very useful. This is what this script does. When the Pi boots up, if it can’t find a wifi network it knows about, it turns into an access point (AP), which you can then connect to using a phone or laptop. That pops up a captive portal in your browser, in a page that lists the wifi networks available. You type in the password for the one you want, reboot within that interface, and when the Pi comes back up, it’ll be on the wifi.

The idea is that this could be part of a physical device (such as an internet radio) with very little in the way of interface of its own – instead it uses your phone or laptop as the interface, both for configuration and for control. Chromecasts do something similar. Unlike the Chromecast, this one doesn’t need an application, just a web page, so it’s a little more manual.

We made this as part of the Radiodan project (home-made IP radio), and I thought I’d try it on Raspberry Pi Jessie, as we previously used Wheezy.

Andrew Nicolaou wrote the code – although he now prefers a resin version, as he describes on his blog. I’m stubborn, so against his advice, I tried the Radiodan version on Jessie. It works, although the Jessie version of hostapd seems to be broken for our purposes, so I had to use an old one.

This version

  • Runs an access point if it can’t connect to a network, making 6 passes to detect network names
  • Runs a captive portal popup using nginx, showing the list of available network names
  • Allows you to enter a password for one, which after a reboot will connect it to the network

You’ll need a Railink RT5370 wifi adaptor such as a WiPi. Here’s some details on cards.

Instructions from scratch on a Pi 2

Download Jessie img from the Raspberry Pi site and unzip it.

then:

diskutil list
diskutil unmountDisk /dev/diskn
sudo dd bs=1m if=~/Downloads/2015-11-21-raspbian-jessie.img of=/dev/rdiskn

(I’ve put “diskn” to indicate the disk number you get from diskutil list – for me it was “disk2”. Here are the official instructions for installing operating systems for the Pi).

When it’s done, put it in the Pi, boot up and ssh or log in.

Expand the filesystem by running

sudo raspi-config

and picking the appropriate option.

Reboot and ssh in again.

Download the Radiodan installation scripts

sudo mkdir /var/log/radiodan
git clone https://github.com/radiodan/provision
cd provision
sudo ./provision avahi wpa nginx

This installs avahi, an old hostapd (hostapd_1.0-3ubuntu2.1_armhf.deb), wpa_supplicant and nginx, plus a custom shell script that does the actual work, and init.d scripts to make it run on boot, plus a hostapd config file and nginx files. It modifies /etc/rc.local to reference the shell script.

Then reboot, unplugging ethernet if that’s what you’re using to talk to it.

After a minute or two you’ll see a wifi network name “radiodan-configuration“. Join that and a captive portal will pop up in your default browser. Click on the network you want to connect it to and type in the password. Reboot by clicking the red “restart now” button.

When the Pi reboots it will connect to the wifi you specified (it rewrites the /etc/wpa_supplicant/wpa_supplicant.conf config file). WiPis handily glow blue when they connect (they don’t glow in access point mode).

If you are also on that network, you can ssh to it using ssh@raspberrypi.local because we’ve installed avahi.

I’ve also found it useful just to have the Pi in access point mode for various things (you can connect to it over ssh on its fixed IP in this mode – 10.0.0.200).

Because this is designed for Radiodan, once rebooted, the nginx config file assumes a server running on port 5000. Obviously you can change this for your own purposes. If you want to change the AP name, you can do so in /etc/hostapd/hostapd.conf.