Go Down

Topic: Wind Visualiser Project (Read 2492 times) previous topic - next topic


Hello all.

First of all, thanks for any guidance/help throughout this project; it is all very much appreciated. My project is a visual and auditory experience that will be part of an exhibition in may next year. The idea is that through projections and sounds, the viewer/listener will be able to see and hear my abstract interpretations of the wind. This will be achieved via the use of Processing and Arduino.

At the moment, I am currently working on learning Processing and getting the arduino wired up and working, by 10/11/12 I aim to get the arduino part of the project fully functional. For wind input, a Vortex Wind Speed Sensor is used in conjunction with an arduino uno. The sensor itself is essentially a reed switch. When the reed switch contacts, 5V is diverted to ground which triggers an interrupt on pin 3. Below is a sketch of how the circuit will work:

The circuit fully wired up:

To test my circuit, I took code from a previous weather station project. I am currently getting serial readings, so I know my circuit works. If I let the wind sensor (reed switch) stop spinning however,it breaks: It will for example read 20 mph, then continuously read 0mph unless I reset the Arduino. I am wanting to strip down this code to its core functionality, as I won't really need to precisely measure wind speed: rather just 4 or 5 states of wind velocity. Before I do this I need to figure out why the counter isn't resetting after it reads 0. Please could someone explain to me what is wrong with the code below that stops wind speed being measured.

Code: [Select]
#define uint unsigned int
#define ulong unsigned long

#define PIN_ANEMOMETER 3 // Digital 3

// How often we want to calculate wind speed

volatile int numRevsAnemometer = 0; // Incremented in the interrupt
ulong nextCalcSpeed; // When we next calc the wind speed
ulong time; // Millis() at each start of loop().

// Initialize
void setup() {
attachInterrupt(0, countAnemometer, FALLING);
nextCalcSpeed = millis() + MSECS_CALC_WIND_SPEED;

// Main loop.
void loop() {
time = millis();

if (time >= nextCalcSpeed) {
nextCalcSpeed = time + MSECS_CALC_WIND_SPEED;

// Interrupt handler for anemometer. Called each time the reed
// switch triggers (one revolution).
void countAnemometer() {

// Calculate the wind speed, and send to serial port.
// 1 rev/sec = 2.5 mph
void calcWindSpeed() {
int x, iSpeed;
// This will produce mph * 10
// (didn't calc right when done as one statement)
long speed = 25000;//2.5 mph * 1000
speed *= numRevsAnemometer;
iSpeed = speed; // Need this for formatting below

Serial.print("Wind speed: ");
x = iSpeed / 10;
x = iSpeed % 10;
Serial.print(" mph,  ");

numRevsAnemometer = 0; // Reset counter


Resources used so far:
http://openenergymonitor.org/emon/node/44 (code found in comments section that i've used to test the sensor)


Interesting project.

I don't know if it's your bug, but this line jumped out at me:

Code: [Select]

int x, iSpeed;

Shouldn't they be unsigned long, since speed is?


Edit: never mind, I see they are the scaled output.



Pin 3 is interrupt 1: http://arduino.cc/en/Reference/AttachInterrupt

thanks for the quick reply, its appreciated. Just tested it and it works as intended now.

For anyone interested in this project: I will keep this thread updated with my progress. I imagine I will come across more issues at some point.

Go Up