and… REST

Along with building a prototype for the moisture sensor, I needed to get some kind of prototype endpoint up and running for dumping the data into.  I had always intended this to be a restful interface, but I didn’t know the quickest way of building one.  I’d looked at services such as and but I felt that I should be laying the foundations here for something that I’d be building on later. Ultimately, the server side system will be a Node or Ruby app, but I don’t have time to build that right now, I needed a shortcut.

A quick bit of googling brought me to ArrestDB which was very easy to set up and gave me a fantastically easy endpoint to push data into. It sits on top of PHP and Mysql (just like something else) so I I dropped it onto my existing VPS. As the data grows it will need a server of it’s own, but we arn’t there yet. The only thing about ArrestDB that troubles me is that there is no security out of the box (other than the obvious care you took creating a MySQL user with only the permissions your app needs on the DB it’s going to use), anyone can connect to your endpoint and start spamming/scraping it. I’m planning on adding in a simple secret token to the flow which should stop 90% of naughtiness occurring.

[ {
"id": "6021",
"ts": "2015-05-29 15:48:03",
"thing_id": "iot_test3_10min",
"value": "769"
"id": "6020",
"ts": "2015-05-29 15:47:52",
"thing_id": "iot_test3_10min",
"value": "771"
"id": "6019",
"ts": "2015-05-29 15:47:41",
"thing_id": "iot_test3_10min",
"value": "769"

For now, ArrestDB scores 7/10 on my list of cool things I downloaded from github this week.


DIY breakout for ESP-12


I needed to prototype the soil moisture sensor on a breadboard, but as we all know, the ESP8266’s in their many different guises aren’t the most breadboard friendly modules you’ll ever come across. The secret here (for me anyway) was some tripad stripboard that I had lying around. I dropped two rows of 8pin headers into the breadboard so they were either side of the central divide, and cut a piece tripad big enough to allow the ESP-12 to sit on it, while the headers sat below. I pushed the tripad onto the top of the headers that were in the breadboard and soldered them on.



I then got some thin copper wire and soldered about 15mm to each contact of the ESP-12. This was fiddly, but didn’t take nearly as long as I’d thought it would. (In the photo you can see that I used a bit of White tape to protect the ESP-12 from the grip of the crocs on my helping hands.) Once soldered, I bent the wires on one side nearly 90º downwards and fanned them out a bit so they would fit through the 2.54mm spacing on the tripad. These were then soldered in place. Next, was the other side, this had to be bent a bit more aggressively, and then fanned out again to get through the holes on the triboard, and when I’d got the module sitting nearly level, I soldered these in too.


I think it looks surprisingly tidy for my work, the module sits above the tripad by about 4mm suspended on rows of copper legs. It works great too. allowing for a rapid breadboard prototype to be built.


Garden of Things

Every summer, I go away on holiday.  If it’s a damp, wet week, I’m sad, but I come home happy because I know my plants will have survived.  If its a glorious hot summer break, I’m happy, but I come home to devastation in the garden with all the pots and hanging baskets reduced to dry biomas

Not this year.

I have until the end of June to build an irrigation system that can keep my plants alive for one week, without me being anywhere near them.  The problem is that I’m not really down with the idea of irrigation as a whole.  If your plants won’t grow in your environment without piling on the water, then you are growing the wrong plants. As right-on and ethical my stance on irrigation is, I’m still going to come home to dead hanging baskets and that make me sad.

So the task is, how do I keep my plants alive for one week, assuming a best/worst case scenario of daily average temps of 28ºC while:

  • not being there to turn taps on myself
  • not being at *ANY* risk of flooding my house/garden/neighbours
  • using no more water than I absolutely have to.
  • using as many buzz words and new technologies as I can find
  • Not massively over-engineering the project to the extent that I simply can’t finish it in the time I have given myself

The answer I have give myself is the “Garden of Things” or er.. “The Internet of Gardens” or perhaps “The Garden of Internet of Things” or something like that.

The high level plan is.

Environmental Sensing -- Decision Making -- Actuation -- Irrigation

The four components work together to provide a single solution.

Environmental Sensing

The first element is the gathering of data about the environment.  The principle sensor here will be a soil moisture sensor that works to determine how dry the soil is.  On it’s own, this should be enough to allow the decision making component to keep the plants alive.  But it won’t be very efficient. Soil temperature can also play a big part in how quickly a plant will get stressed so that will be an important data set.  While these are local to the plants, we’ll also need to understand something about the larger environment, so a weather station of sorts would be really useful.  On top of all this we should also feed the decision making component with with some forward looking predictive data, which we’ll have to pull from public API’s.

Decision Making

The  Decision Making component takes in all these data sources, and scores them.  It will boil them all down into a single integer value which is the Water Need Score.  If this score exceeds a threshold that I will have to determine through trial and error, then it will irrigate, if not it stays dry.  The Decision Making component will also need some health check capability to raise alarms if the is a problem with the effectiveness of the solution, or it’s ability to actuate the water supply correctly. It will use the forward looking data to apply a negative score to the Water Need Score if it has high confidence that there is a rainfall event due in the next 12 or so hours.

Actuation and Supply

The Actuation and supply component basically just controls the flow of water to the irrigation system.  It will start simple (but like all the other components) will grow in complexity as my time allows. A water butt will collect rainfall run off from roofs and store it.  Once commanded to by the Actuation system, water will be pumped from the storage through the irrigation network. I’ll monitor the amount of stored water, and again, in conjunction with the forward looking data, allow the system to re-fill the reservoir from the mains water supply if needed.


This component defines that actual network of pipes, drippers, sprinklers and valves that actually deliver the water where it’s needed.


More power for the ESP8266


I recently powered up one of my ESP8266 ESP-01 modules to start experimenting with the ArduinoIDE build for it.  I knew that it sucks juice big time, in excess of 250mA for some operations.  I’d also been warned that the cheapo FTDI adaptors from ebay can struggle to provide enough power to satisfy it.  I wasn’t terribly surprised therefore when I started getting some really odd behaviour out of it.

I was connecting to it over the FTDI serial and trying out some AT commands.  It was responding to the basics, “AT” returned “OK”, “AT+GMR” provided the serial number, but anything more demanding than that and the module just died, the FTDI dropped out too, reseting the COM port which became very irritating, very quickly.

I’ve got some 3.3v Vregs in a TO-92 package which are a no-brainer for breadboard use, but I like to take the path less travelled. I’d Noticed that Adafruit have a really nice breakout for the ESP8266 7/12s which uses an interesting 3.3 Vreg called SPX3819M5 3-3 by Exar which come in the most stunningly unusable package, a 2mmx1mm SOT23-5 package.

My idea was to solider some thin single core wires to the neccessary pins, a plan slightly complicated by the need to bridge pins 1 and 3 (Vcc and EN) while leaving Pin 2 (GND) unencumbered.

I’m pleased to say I was able to nail it on the first attempt, and now I have a rock solid 500mA 3.3v supply to feed the beast that is the ESP.