Posts Tagged ‘yun’

Windspeed A/D Dials

Wednesday, June 17th, 2015
Finished product - dials and arduino all working

Finished product – dials and arduino all working

My father and grandfather were sailors (amateur and professional, respectively) and would pay attention to the weather.  Whenever we moved to a new house, a set of windspeed and direction indicators would appear on the wall – brass and glass, with lights for compass direction and a needle to show the windspeed.  These faded into the background for me growing up – they were always there, so I just never really thought that they were unusual.

Now that I live outside of the sheltered city, weather has more of an important role in my own life. I pay attention to where the wind is coming from, and how fast. I put a windspeed measurement and direction system (and temperature/humidity/rain measurement) on my 100′ tower so I could get a fairly un-sheltered perspective of the wind, and that worked great.   But I think that looking at a screen for seeing windspeed and direction is tedious, and often it will just be hidden behind other screens and so I’ll never look at it.  I needed the brass dials on the wall.  My hobbies, after all, have me living in the past – I like analog.

So I decided to blend the digital and analog worlds.  This project set out to get the old-time analog gauges working with my modern digital weather station, and also about getting a bit more hands-on time with Arduino.  This is one in a long line of analog-to-digital converters to get the speed and direction of the wind visible to me while sitting inside.

Goal

I wanted to create a wall-mounted analog gauge set that would take an HTTP GET command and set the direction and speed.  The device would have to be wireless, only relying on a plug to get AC power.  It would have to look nice, with maybe cherry or walnut mounting board and to the untrained eye look identical to a weather gauge set that was run by analog methods. It would have to be tremendously simple for my ham-handed API calls.

Components

Core: I chose Arduino for the core of the panel.  I have done other Arduino projects before (I’ll write up my programmable LED tower light system later) and so I had a good idea about how I could get the boards and pieces to go together. I chose the Arduino Yun as the core, since it has wifi built in and I’ve already figured out how to feed Arduino systems commands via HTTP GET. Other Arduino systems could have worked, but this was super-simple for me to get running and didn’t require much (any) soldering, which I hate doing.  Also, the size factor would fit easily behind a board.

Weather collection system: It’s a Davis Vantage Pro, which is a nice system – the tower unit is solar-powered with a built-in panel, and it relays data back via radio to a receiver.  While it’s not obviously listed on their product pages, the version I have doesn’t have a screen at the receiver end – it’s just a little plastic box.  This was a Craigslist purchase for around $150 (new) which is a bargain. There are a bunch of speed/direction/rainfall detectors out there which will work just as well – the Davis is a bit more on the “professional” end than most might need. The receiver is USB-connected to a Mac Mini, which in turn is running WeatherSnoop.  WeatherSnoop is nice, in that it can (with the right license) show speed, direction, and all of the chart-y type of things that come pre-built into the system.  But I don’t use WeatherSnoop for that – I feed the data into Indigo 6 (which has a plug-in for WeatherSnoop) and then chart from within Indigo so all of my home automation systems are plotting from the same toolset.  I can also take action based on weather data, if I want (“Is it starting to rain when I’m not home?  Send me an SMS!”)  Now, the design of the system really doesn’t care what weather collection system it is taking data from.  The HTTP request is general enough that it could just be taking information off of Weather Underground from someone else’s station and re-writing it and feeding it to the gauges.  But since I had a live feed I figured I would use that data.

Gauges: The gauges that are most familiar to me are made by Cape Cod Wind and Weather. I looked on eBay and found a set of wind and direction gauges for $40.  Score!

Wood panel: I don’t like working with wood.  It’s fiddly, non-exact, and I don’t have the right tools.  So I paid someone to make a nice walnut mounting board for the equipment.  I know this is the “craft” part of the project, but… I’m not a craftsman in the woodly arts, so I outsource that stuff. The panel was made so it had a hollow back area about 1.75″ (4cm) deep where the power supply, arduino boards, and wiring could be hidden.  I told the carpenter to put an “air gap” on the top and bottom of the enclosure, so that there would always be the ability for air to flow up and out of the case against the wall, so that if things got warm in there the natural convection would pull cooler air in from the bottom.   Also, the cord needed to have space to come out from the back and I didn’t just want to put a hole somewhere since I hope to have this mounted at some point on a wall where the cord will run through the wall and not dangle below.

Power: The Arduino needs a regulated 5vdc supply, and I chose a Mean Well RS-15-5 power supply from Jameco, sold on Amazon for around $15.  These power supplies will work pretty much anywhere in the world on AC power, and I did a quick fine-tune on it so that it feeds out exactly 5 volts.  To hold it in place, I used bathroom mirror hold-downs from a hardware store and got some self-tapping screws that were just long enough to get a grip in the wood but long enough to clamp down on the box when put through the hold-downs.

Wires and connectors: I bought some breadboard connectors of various styles (m/m, f/f, m/f) somewhere local.  I’m sure they can be found on Amazon or eBay easily enough for a few bucks.  I didn’t solder anything other than the 110vac power connector wiring, which I also heat-shrink wrapped.

Resistors: I needed a few resistors (notably to reduce the power going to the needle gauge) and all my old resistor libraries are buried somewhere in a shipping container, so I just bought a new set of various resistors for $10 on Amazon here.

Relay board: To control the lights, I bought a solid state relay board off eBay (search for “8 Channel 5V Solid State Relay Board”) which is more or less designed to work with Arduino devices.  It had 8 relays which was perfect, since I have 8 lights in the compass rose.  There happen to be more than 8 outputs on the Yun, so I was all set to control the relays from the Yun by triggering the output pins.

Methods

The lights are NE-2 type neon lights, which take 60-110vac.   I plumbed the neutral AC line to the common connector on the back of the light panel, and to the power supply.  I then split out the hot line into 9 separate wires, 8 going to one side of each relay, and the 9th going to the power supply.  I connected outputs 2 through 9 to each of the relays, so that bringing those lines high would in turn trigger the solid state relay and let 110VAC flow to the NE-2 bulb in whatever position corresponded to that pin.

To get the needle working, I set pin 10 of the Arduino to be analog and acting as a pulse width modulated signal.  This means that the voltage pulses on the line, so that it “fools” the end device into thinking that it has a lower voltage.  For an analog needle, this is pretty much perfect.  See more on Arduino PWM here.  I did a little tiny bit of math to convert the MPH value to a 1-255 value on the pinout.

I put a 41k resistor (yellow/brown/orange/gold) in line with the output of pin 10 on the Arduino. This reduced the voltage on the output to match what the needle required, so that at a setting of 255 the needle was at the 100mph (maximum) value.  Comparing the settings across the speed range seems to be pretty close (within 1mph) of what I’m looking for.

I used brass hardware to fasten the plates to the walnut board on the front and the boards and control circuits to the back, drilling much smaller pilot holes after carefully measuring and marking placement on the board.  I made sure that the boards had nice thick wood, so I could be a little sloppy in the length of my fasteners and not worry about punching through to the finished side.

Here’s the assembly during and after construction:

IMG_20150607_180157  IMG_20150607_180204   IMG_20150617_151129

To activate the device, I wrote some code.  I won’t go into the details here – look at the code for more information.

Arduino Windspeed/Direction Code

The gist of it is this: connect to port 80, and create a fetch like this:

http://x.y.z.a/arduino/direction=<compass>&speed=<speed-in-mph>

The <compass> value can be in degrees, or it can be one of N, NE, E, SE, S, SW, W, NW.  There is very little (no) error checking, so it’ll happily fail silently if you feed it indigestible data.

If there is no data sent within 60 seconds, the “N” light will start to flash as an indicator that something has gone wrong.  You can of course tune this in the code to some higher value if you think that 60 seconds is too short, but I like the updates to be fairly rapid so I am automatically updating the indicators every 7 or 8 seconds.  Also, when the device boots it will spin through the compass lights to test them all.  I have my Arduino’s MAC address fixed in my DHCP server so it’s always on the same IP address, so my Indigo systems knows where to go to set the speed/direction.

Notes

– I had to update my Yun firmware – the firmware it came with had some sort of error that would cause my sketch to fail about 20 minutes after bootup and the lights/needle wouldn’t change.

– The NE-2 bulbs may actually not work well at 110vac, but they seem to be doing OK so I’m going to leave them alone.  The manufacturer (Cape Cod) recommended a 56k resistor on each pole of the power going to them, and there is even a warning written on the back of the dial about it.  If anyone has comments on why I should put those resistors back in, let me know.