To measure the wind direction I need a wind vane. A simple way to do that is to use hall sensors and a small magnet, which rotates with respect to the sensors (the hall sensor triggers an output when the magnet is close). My solution is to use four such sensors, one for each cardinal direction (north, south, west, east).
Note that this does not mean I'm restricted to measuring only four directions; by placing the magnet at the correct distance, I will get two sensor readouts when it's in between directions. In other words I get eight directions (see table).
Direction | Readout (N,W,S,E) |
North | 1,0,0,0 |
North-East | 1,1,0,0 |
East | 0,1,0,0 |
South-East | 0,1,1,0 |
South | 0,0,1,0 |
South-West | 0,0,1,1 |
West | 0,0,0,1 |
Noth-West | 1,0,0,1 |
The most straight forward way to connect this to the BL600 processor is to use in total six wires; four to BL600 inputs and two for GND and supply. That's a bit of waste of inputs that can be used for other peripheral devices, and I need the vane to be quite far from the main PCB so I'd also like to reduce the amount of wires. Therefore I decided to combine the four digital signals into one analog.
It's quite common to combine several buttons into one analog signal (see example here). The problem, though is that they most of them assume that you're only going to press one button at a time. For example, in the picture below, if I press "RIGHT", it doesn't matter what other button is pressed, since "AD0" is already grounded.
Instead I used this approach: By choosing different values of the resistors N, E, S and W, I will get different voltage outputs for combinations of presses. I made a spreadsheet to fiddle with resistor values (see here) and after a while I found a configuration with maximum 70 mV difference between the states I care about. The worst case ADC resolution is about one tenth of that, so that should be fine.Considering that I need quite accurate placement of the sensors, I decided to make a PCB. Below you can see the schematic and layout.
As usual, all the source files can be found through the project links.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.