Monday, July 14, 2014

Weather Station v0.1

The winds in Las Cruces can get pretty fierce and I have lost some shingles off the roof, so I decided to measure the "local" wind speed.  I wanted to learn a little about the power consumption of small Wi-Fi connected devices, so rather than buy an off the shelf unit, I decided to build something from a kit.

The article Weather Station Wirelessly Connected to Wunderground was an excellent starting point and so I sourced the parts from Sparkfun.  It looked like the Electric Imp had enough input capacity to do what I needed, so rather than use an Arduino to run the weather software and the Imp as a dumb modem, I attempted to use the Imp in both roles.

The Sparkfun Weather Shield "is an easy to use Arduino shield that grants you access to barometric pressure, relative humidity, luminosity and temperature. There are also connections on this shield to optional sensors such as wind speed, direction, rain gauge and GPS for location and super accurate timing"

One potential mapping of these variables to the Imp is:

Shield variable Type Imp Pin
Wind speed DI 1
Wind direction AI 2
Rain gauge DI 5
Luminosity AI 7
Battery voltage AI unused
Barometric pressure I2C 8, 9
Humidity/Temperature I2C 8, 9

Looking at the schematic for the Weather Shield, it is seen that the shield variables swing 0-5V, whereas the Imp is a 3.3V device.  Now there is a bus transceiver chip, the 74LVC245, to interface the digital inputs and an op amp/divider will fix the analog inputs.  But it was then I realized this speedbump was a wonderful opportunity to give me pause, get something working ... a version 0.1 of a weather station (and thus the title of this blog entry).

So I started with the following signal allocation:
Variable Type Imp Pin
Wind speed DI 5
Battery voltage AI 7
Temperature AI 9

A small piece of perfboard, served to mount the Imp and handful of components.


v0.1 sensor board + Imp



The Imp was powered by a large, sealed lead acid battery, a UB645 chosen for its price and durabilty, rather than being the smallest battery for the job. The wind speed was measured using an input, configured as "DIGITAL_IN_PULLUP", which allowed a handler function to be called every time the windspeed reed switch closed.  The battery voltage is measured via a simple divider off Vin.  Note that Vin is after the reverse polarity protection MOSFET on the battery input, so 0.6V lower than the actual battery voltage.

For only a few lines, the Squirrel code is pretty easy to get going.  The raw data is serialized to the ElectricImp server, where the communication to Wunderground takes place. As noted in the Sparkfun blog entry announcing their data service, Wunderground does not allow custom fields in their data sets, and I wanted to track battery voltage.  So I added code at the ElectricImp server to push data to a public stream on data.sparkfun, to record weather + battery voltage and RSSI ... nothing fancy, but dead simple.

Note, to form the query URL to Wunderground and Sparkfun, it is necessary to concatenate the strings in Squirrel for the various key/value pairs.  Rather than using the "+" operator, which generates a lot of garbage, consider using a blob as write buffer:

    buffer <- blob="" p="">    ....
    buffer.seek(0, 'b');
    buffer.writestring(sfDataSparkfunStr);
    buffer.writestring(sfPublicKey);
    buffer.writestring("?");
    buffer.writestring(sfPrivateKeyPrefix);
    buffer.writestring(sfPrivateKey);
    ....
    ....
    local len = buffer.tell();
    buffer.seek(0, 'b');
    local url = buffer.readstring(len);


Now that I have been collecting data for a few days, time to look at interfacing the Weather Shield proper to the Imp.

Tuesday, June 24, 2014

Saturday, June 14, 2014

Could robots replace nearly half of us in the workforce?

A very sobering look at the impact of robotics on employment.  And instances like "... soon half of all iron ore produced in the Pilbara will be transported by driverless robotic trucks ... " are not small scale, unimportant experiments.


Tuesday, April 15, 2014

Solar powered Open-Mesh Wi-Fi access point

I have an Open-Mesh wireless network on my hotel.  The property comprises 6 buildings on 4.5 acres and we currently use 8 access points (APs) to provide good coverage.  I have used OM2P-HS access points exclusively, all but one mounted outside in the optional outdoor enclosure.

To layout the network, I used the network view on cloudtrax.com, the cloud based network management software for Open-Mesh.  The network view utilizes Google Maps, which provides adequate resolution to position APs, checking distances and line-of-sight.

As I re-positioned APs to strengthen & buildout the network, one required location had no AC power available (at reasonable price).  I used to have a Meraki system which offered a solar power option, but the Open-Mesh system which I replaced it with does not.  Having an old envelope handy, I did a little sketch of what a sufficient solar power unit might look like and describe it below for others that may have such need.  There was no detailed engineering, rather a "likely to work"  design.

A friend (thanks Jack) had given me a 12V, 15W solar panel and I guessed it might be good enough for my needs.  I looked at the power consumption of the OM2P-HS.  The nameplate states:

DC Input: 12~20V dc, 1~1.2A
PoE Input: 12~24V Passive PoE

Putting an ammeter inline with the DC input, yielded a quiescent consumption of about 90mA, with a 150mA peaking consumption during a disk image download to a laptop connected to one of the two wired connectors.  So I used 1.5W as a power consumption baseline.  I live in southern NM, which is an idyllic location for solar and allows me to run a little closer to the edge on design margin.

Plugging the numbers into a solar power calculator suggests that the panel I have and a 10Ah battery will work.  I used the following parts, readily available locally (assuming you have a Harbor Freight and Battery+Bulb, or equal, in town).  No product endorsements are made or implied.

15W, 12 V solar panel
solar panel frame mounting kit
100W solar charge regulator  (needed to protect the battery from over/under charge)
solar power connection cable kit

12V 10Ah AGM battery

The solar charger noted provides a 12V output, which I wired directly into the Open-Mesh PoE injector, using one of the cables in the cable kit.

The mounting kit allowed the solar panel to be mounted at several angles, which compared nicely to guidance provided at Optimum Tilt of Solar Panels.

The final setup looks like this (the panel faces due south, set at 30 deg).




Friday, March 28, 2014

Does Thought Crime Pay ?

An entertaining and insightful look at some of the computer language landscape, by Gilad Bracha.

Sunday, March 23, 2014

Go, for the curious

The transcript of a nice talk, that might make you curious about Go (the language).

Thursday, February 13, 2014

Not your average intro ...

The talk DART for the language enthusiast is a quick introduction to Dart by a very capable speaker, that touches on a lot of interesting issues and provides perspective on the language, without dwelling on how to write "Hello World".