Introduction: Accurate Wireless Weather Vane

This wireless weather vane has some unique features- wind direction with a simple, economical, and accurate absolute encoder. Some consumer weather stations Comparison have a limited wind direction resolution of 22.5 degrees, updated every 14 seconds. This weather station's wind direction has a resolution of one tenth degree, updated once a second. The Bluetooth LE module, a HM-10, allows sleeping between display readings to save power.

Step 1: A New Type of Wind Vane

I wanted to construct a wind direction indicator that is more accurate than consumer grade equipment, but is also cheaper than a professional quality wind vane. The goal was to make it using an relatively cheap ($6) sensor, and send the wind direction data via Bluetooth to a display station. Bluetooth enables a faster update rate than consumer grade wind vanes. Another goal was to make the sensor solar rechargeable. Materials had to be easily available and low cost, yet be able to resist rain and exposure to the elements.

The Bluetooth interface and Display are virtually identical to my previous Instructable, Wireless digital scale, except for the programming.

Step 2: Gather Materials

2 ea. (8 spare) Miniature deep groove ball bearing 625ZZ 5*16*5 mm ball bearings

1 ea. (14 spare) Wood dowels 3/16" x 11-7/8" dowels

1 ea. N48 Neodymium Magnet Dia 1/4"x1/2" Diametrically Magnetized diametrically magnetized magnet

1 ea. 3/4" Copper pipe cap, hardware store

1ea. 1/2" Copper pipe coupler, hardware store

1 ea. 6" x 1/2"Copper pipe, hardware store

1 ea. 12" x 3/4" Copper pipe, hardware store

1 ea. 3/4" to 1/2" Copper pipe reducer, hardware store

1 ea. Hall type absolute position encoder, SPI, SOIC-8, MLX90316KDC-BDG-100-RE encoder

1 ea. ATmega328 ATmega328P-PU

1 ea. socket DIP-28 socket

1 ea. 16 Mhz crystal oscillator oscillator

2 ea. 20pf capacitors cap

2 ea. HM-10 Bluetooth Low Energy module, configured as master, HM-10 serial

1 ea. HM-10 Bluetooth Low Energy module, with carrier board and voltage regulator, HM-10 w/carrier *

1 ea. 2 cell AA battery holder battery holder

1 ea. pin Adapter adapter

1 ea. USBasp Programmer USBasp programmer

1 ea free Aduino IDE Arduino IDE

1 ea. 2 x 16 LCD, I2C interface LCD

1 ea. Arduino Pro Mini 8 Mhz 3.3v 8Mhz Pro Mini ATmega328

1 ea. USB to TTL serial adapter FTDI adapter

1 ea. USB battery bank battery bank

10 ea. momentary tactile button (9 spare) buttons

1 ea. clear soap dish enclosure for display, from Daiso.

1 ea. rectangular plastic organizer enclosure for remote, from Dasio.

Notes: * check if board has HMSoft firmware. Otherwise flashing may be required to support I/O and connection functions. See this Instructable, and especially the comments.

Assorted: wires, small perfboard, 3 2N2222 transistors, IRF9540 Mosfet, resistors, and diodes.

Step 3: Testing the MLX90316 Sensor

Since this is the first time I have used the MLX90316 magnetic rotary encoder sensor, I needed to find out how sensitive it is in order to build the wind vane housing and mount the magnet the correct distance away from the sensor. I thought if the strong magnet saturates the sensor, it is unlikely to work- but found that distance made little difference from direct contact to about 1/2" away. I also checked out some valuable resources which I used, see this German lab experiment. It is important to get the correct version of the MLX90316, they have an analog version, a proprietary protocol version, and a SPI version. Since the existing Arduino code for this sensor used an older version of the Arduino IDE, I needed to add #include (right after the comment section) to the MLX90316.h file. Also, the sketch uses the Metro.h library, see Metro timed events. Note that MOSI and MISO share the same data wire, unlike normal SPI.

Use a Arduino Uno with test.ino to test the sensor. The sensor requires 5 volts and ground; Digital pin 13 connects to SCK, Digital pin 12 (MISO) not connected, Digital pin 11 to MOSI, and Digital pin 10 to SS.

Step 4: Programming the HM-10 Modules

The HM-10 modules come configured as slave units, and no auto sleep. They need to connect immediately, master to slave, without a password or other negotiation. To program them, use the FTDI 232 adapter (set to 3.3 volts). You connect pins 3.3v, Gnd, Rx to Tx and Tx to Rx; it will be helpful to have a female header to stick on the FTDI pins, then solder small flexible wires to the female header pins, and from there solder the wires to the HM-10. See the circuit diagram for the HM-10 Manual , the mode led on pin 24, the reset wiring on pin 23, and the connection of grounds to pins 13,14, 21, and 22 needs to be accomplished- it takes a fine tipped soldering iron and a steady hand (plus a 3rd hand accessory to hold the board) . You will need some sort of terminal program, the best is Realterm because it allows you to send AT modem commands to change the configuration. See this excellent instructable to familiarize yourself on the steps required Programming the HM-10 .

/////////////////////////////////////////////////////////////////////////////////////////////////

Program the slave as:

MODE 2, data and AT commands in same data stream. send AT+MODE2

PWRM 0, auto sleep mode, send AT+PWRM0

ROLE 0, slave/remote/peripheral unit, send AT+ROLE0

PCTL 1, power output, max. send AT+PCTL1

FLOW 0, flow control not used. send AT+FLOW0

ADDR ?, you need to find the MAC address for this device, write it down. Used to set CONN in master. send AT+ADDR?

CONN XXYYZZ etc., set the slave to connect to master's MAC address. send AT+CON22C22FF22DA2 [whatever the master MAC address is]

BAUD 0, default baud rate 9600 baud (as fast as the ATtiny85 can send) send AT+BAUD0

POWE 2, 0 dBm transmit power, send AT+POWE2

TYPE 0, make sure no passcode is used, send AT+TYPE0

VERS ?, version. My version was v540. send AT+VERS?

///////////////////////////////////////////////////////////////////////////////////////////////////////

Program the master as:

MODE 2, data and AT commands in same data stream. send AT+MODE2

PWRM 1, no sleep mode (master has external soft latch power down), send AT+PWRM1

ROLE 1, master/central unit, send AT+ROLE1

PCTL 1, power output, max. send AT+PCTL1

FLOW 0, flow control not used. send AT+FLOW0

ADDR ?, you need to find the MAC address for this device, write it down. Used to set CONN in slave. send AT+ADDR?

CONN XXYYZZ etc., set the master to connect to slave's MAC address. send AT+CON22C22FF22DA2 [whatever the slave MAC address is]*

BAUD 0, default baud rate 9600 baud (as fast as the ATtiny85 can send) send AT+BAUD0

POWE 2, default 0 dBm transmit power, send AT+POWE2

TYPE 0, make sure no passcode is used, send AT+TYPE0

VERS ?, version. My version was v540. send AT+VERS?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

Note: in V540, the units no longer link automatically on power on. Instead, the sketch sends CONN XXYYZZ etc. each time the Display starts up.

Other interesting AT commands:

TEMP ? send AT+TEMP? to get the temperature

RSSI ? received signal strength send AT+RSSI?

BATT ? battery voltage (has A/D converter!), send AT+BATT?

PIO4, PIO7 etc. set or clear output pins (not used here, but could be handy). The Atmega328P is awakened from sleep via any serial data sent from the HM-10 Tx line via 10 K resistor to INT0 hardware interrupt pin. Could have used the PIO pins to do the same like I used to power up and down the ATtiny85 in the previous project, but thought this would be a less complicated way to do it.

Step 5: Mechanical / Electrical Details of the Weather Gathering Remote Unit

Electrical

The weather unit uses an Atmega 328p and 16 Mhz crystal on a piece of perfboard programmed with the usbasp programmer (although you could remove the chip and program it with an Arduino Uno). The MLX90316 sends direction data to the 328p, where it is converted to TTL serial data and sent by the HM-10 Bluetooth Low Energy module to the display unit.

If you use usbasp, be sure to have the 3.3v/5v jumper in the 5v position or the upload will fail. Also, on a raw 328p, you need to burn bootloader on the tools tab first. When loading the sketch with usbasp, first select the pro mini board with 328p chip on the Tools tab, with usbasp selected as programmer, then go to the sketch tab to upload via programmer (not via the normal button).

The sensor is mounted on an adapter board from Proto-Advantage , which just barely fit into a short stub of 3/4" copper pipe. Use thick super glue to secure the corners of the adapter inside the pipe. You may leave the copper section with the sensor not secured to the pipe tee so you can rotate it to give a north reading when installed with the wind vane pointed north. Add some foil duct tape to weather proof and secure the sensor section to the other pipe sections.

Mechanical

The weather vane rotates on 2 inexpensive ball bearings. The grease and seals of the bearing need to be removed for less friction. With jeweler's screwdriver, pry the metal shields out, then spray with wd-40 to remove the grease. Find a super light oil to lubricate the bearings. The wood dowel is the axle that the magnet is glued to on one end. The dowel fits into the top pipe cap, fitting into a brass tube soldered through the pipe cap. The dowel is further secured to the brass tube via a nut and screw drilled through both. The vane is epoxied to the brass tube.

Make the vane as light as possible. Balance the vane about the brass tube connection, and be sure there is more area to the fin than the pointer counterbalance weight. See the images of Weather Field No. 1 art installation (Santa Monica, CA) to get an idea of optimum construction.

Step 6: Assembling the Display and Programming It

The Display is just a modified version of my previous instructable Wireless Digital Scale .

Hot glue the Arduino Pro Mini to a bit of Popsicle stick, and hot glue the Popsicle stick to the lcd so as to keep the Pro Mini above the tabs on the lcd display. Build the Softlatch on/off circuit on a piece of perfboard according to the circuit diagram- credit to Ardweeny and wire it to Ground and Raw input of the Pro Mini, and control lines to pins 5 and 6 of the Pro Mini. Wire the on/off button lead and ground to an case mounted button. Hot glue the Softlatch circuit to the lcd.

Since the power supply needed to power the lcd with 5 volts, but the HM-10 needs 3.3 volts, a Pro Mini with an onboard 3.3 volt regulator was chosen. That simplified logic level interfacing between the Pro Mini and HM-10, and even to the I2C backpack (5V I2C components can be connected to the SDA and SCL lines of the 3.3V Pro Mini I2C-bus), while still giving the lcd 5 volts for a normal display. A common USB battery bank was chosen to provide the 5 volts because it was easily rechargeable via USB, fit well in the project box (soap dish), and came in a pleasing color to show through the clear soap dish case. Because lengthwise space is limited in the soap dish, a USB connector was cut down and wires soldered to the cut down connector (outer 2 pins) and extended to the Softlatch circuit board power input.

Carefully drill 4 holes for mounting the lcd in the soap dish lid, and attach lcd to lid with 4 ea. 1/2" long miniature screws and matching nuts. Drill holes for the on/off pushbutton, and hold in place temporarily with earthquake putty. Apply epoxy sparingly to top and bottom of toggle and allow to cure. Wire according to circuit diagram.

Program the Pro Mini with the sketch using the FTDI adapter plugged into the female programming header.

Position the HM-10 so the built in Antenna faces towards the front of the case, clear of metal or wiring, and in such a position that the HM-10 mode led can be seen. Secure with hot glue to the lcd.

Step 7: Testing and Results

The absolute encoding sensor was better than I imagined it would be. It has great accuracy, and is low in cost ($6). Only a few years ago, it was impossible to find an absolute encoder with reasonable accuracy for less than $100. It was possible to make an optical encoder, but that was a complex task of arranging IR emitters and detectors, making an optical encoder disk, then sandwiching the parts into a reasonable size housing.

The Display works great, and the HM-10 Bluetooth link is robust. In my house, the Display can turn on the remote sensor from the kitchen. Interestingly, the Display unit can not turn on the sensor from other rooms, though once connected, the connection remains solid in other rooms. This may be due to the advertising behavior of the HM-10 in sleep mode- there is a AT command for changing this parameter, but I haven't tried changing it yet.

My next step is to add a small solar panel to recharge the 3 AA Ni-Mh batteries in the remote. Without recharging, I expect the life of the batteries to be about 2 weeks of intermittent use, which is about half the life of the 2 AA alkaline batteries used for my previous project, the wireless hummingbird scale. The reason for the expected shorter life is the much greater current draw in operation (about 70mA), though the sleep current consumption is about the same.

Comments

author
laith+mohamed made it!(author)2016-07-10

Nice work

author
HgIAB2016 made it!(author)2016-07-07

Hi - firstly this is a really great project so I am a bit perplexed with what the actual OD size of the bearings really is? Your excellent construction pictures shows that both of these bearings are mounted inside the 1/2 inch copper coupler (which only has and ID of 12.7mm) but you have said that the bearing OD is 16mm - is this simply a typo for the bearing diameter or am I totally missing something in your construction? I am following your construction very closely so I would really greatly appreciate you clarifying what the bearing size is, or if the bearings really are 16 mm dia as you have shown can yu please explain what I wm apparently missing in your pictures? Cheers

author
jbike made it!(author)2016-07-09

I think we are both right as regards the copper pipe sizes. The problem is that the U.S. uses a different size than in the U.K. or E.U. for the same so called 1/2" pipe. For the U.S., see http://www.engineeringtoolbox.com/astm-copper-tubes-d_779.html. For the U.K., see http://copperplumbing.org.uk/sites/default/files/content_attachments/en-standards_0.pdf Also see https://en.wikipedia.org/wiki/Copper_tubing. Anyway, it is still likely that you could find common plumbing components where you live that would be able to fit a 16 mm bearing, maybe requiring a layer of two of tape over the bearings to fit. Alternatively, you might use 21/32 brass tube per http://hobby.uk.com/round-brass-tube-12x21-32.html but check first, will be a tight fit.

author
HgIAB2016 made it!(author)2016-07-09

Thanks again for your explanation however the only way that would clinch the diameter differences irrespective of any possible differences in Cu pipe standards would be for you to physically put a caliper (measuring device metric or imperial) around the OD of the coupler carrying the bearings, photograph this and then repeat the same exercise for the large diameter of the 3/4 inch to 1/2 inch reducer connected to the bearing tube housing and photograph this! This would clear up all questions concerning this issue once and for all because 1mm in any system is 1mm and this is totally invariant. Bit of extra work for you if you feel inclined to do so? Cheers.

author
jbike made it!(author)2016-07-08

I measured the bearing O.D. as 15.98 mm. According to http://www.gizmology.net/pipe.htm, 1/2" copper pipe has an O.D. of 5/8", so the coupler has to be slightly bigger I.D. so the pipe can fit in for soldering. Anyway, 5/8" x 25.4 mm/in. = 15.875 mm so the coupler is that plus the extra needed for fitting. The bearing is actually a little loose in the coupler. A bearing is in both sides of the coupler ( in the middle of the coupler is a pipe stop that the bearings can't move past); also inserted in the lower part of the 1/2" coupler is a very short 1/2" copper pipe section used to fit into the 1/2" to 3/4" coupler. The metal tape holds the 1/2" and 1/2" to 3/4" couplers together.

author
HgIAB2016 made it!(author)2016-07-08

Hi mate - thanks for your reply however (with respect) your comments are totally in error according to the sizes and pictures you have provided as far as I can see in your project because it is the ID of the 1/2 inch coupler that is where the bearings are shown to be sitting and not the outside of the 1/2 inch coupler or inside of the 3/4 inch pipe, please check your own pictures [the bearings are clearly shown sitting inside the smaller coupler ID and the only other larger pieces shown are the 3/4 inch pipe and 3/4 inch to half inch reducer]. The 1/2 inch coupler has an OD of 14.6mm [not 5/8, inch (equiv metric 15.9mm OD as you say)] and the ID of this coupler is 12.77mm - which just fits over the OD of 1/2 inch copper pipe - whose OD is 12.70mm - so that the coupler (with bearings and shaft inside this coupler) can then just slide over? Clearly, 16mm OD bearings will not fit inside the ID of the 1/2 inch coupler? The only other situation that might make some sence here is if you have possibly used some other copper pipe diameters other than the 1/2 inch and 3/4 inch pipe diameters you mention. Just to complete what I have measured 3/4 inch Cu pipe has an OD of 19.3mm dia and an ID of 16.7mm [in which the bearings would loosly fit] - is it possible you could have mixed up the 1/2 inch and 3/4 inch pipe diameters and that the bearings are sitting inside the 3/4 inch dia Cu pipe? If this latter explanation is correct then you must have used a larger dia Cu pipe and associated fittings to slide over this 3/4 inch pipe and bearings housing??? No big deal either way except that there really does seem to be some discrepancies between what you have said you have used and the measurements you have provided. I am not having a go at you, I am simply trying to accurately reproduce what you have said you have done. Please help me to understand excatly what you have use and done - I would be very, very grateful if you do. Cheers, ian

author
Dogdance made it!(author)2016-06-10

Fantastic! just what I've been looking for. Now all I need is an anemometer. Here's an idea, instead of just the solar charger, augment it with a wind generator, it can double up as a speed indicator. Hey ho, early morning flights of fancy. Thanks again good information.

author
jbike made it!(author)2016-06-11

Thanks. I have to think about the anemometer, want to redesign it to give a faster wind speed response.

author
Tecwyn+Twmffat made it!(author)2016-06-09

This is a great project - very informative! Thanks!

author
jbike made it!(author)2016-06-09

Thanks, glad you like it.

author
Tecwyn+Twmffat made it!(author)2016-06-09

This is a great project - very informative! Thanks!

author
Tecwyn+Twmffat made it!(author)2016-06-09

This is a great project - very informative! Thanks!

About This Instructable

9,977views

189favorites

License:

More by jbike:Levitator / Motor, Solar PoweredDouble Acting Electric MotorHex-a-gone-wild (solar Motor)
Add instructable to: