Arduino Variometer

Notification for paragliders

Sorry for waiting that long. I found how to change Arduino code for paragliders. But I have no way to test it. If you need that for your paraglider or whatever flying thing, please leave me comment below. We need first test it, so that I can be sure that it works, then will upload this post. Thanks. Sensitivity can be changed in next line (original value is 50). line 31:

toneFreq = (lowpassSlow – lowpassFast) * 10;

The main part is with silencing vario when no much ressure/altitude change (now it is silent between certain points, experiment with those values -50 and 50, maybe -30/30, or -70/70, this is how much frequency will change with pressure change in time):
line 39:

if (toneFreq < -50 || toneFreq > 50 && ddsAcc >0 )

Sorry, previous change on this web page was wrong for same reason. This one should work. I am not sure what happened, perhaps forgot to update.

Please notify me after you confirm that it is useful for paragliders.

Arduino variometer for those who fly RC Gliders, DLGs, and other motorized and non-motorized RC sailplanes, as well as ‘big brothers’ – ‘manned’ gliders and parachutes, indicating whether there is thermal or not, or better known as “vertical speed indicator“, or simple Vario (this one is simplified version, without any display):

No radio? Direct audio mode:

Someone contacted me and asked if it is possible to use this vario without need for RF chip – for direct use. Answer is yes. Simply by adding crude audio amplifier to passive buzzer, which is actually speaker (loudspeaker). Sorry for ugly drawing.

variometer

If you have small “magnetic” buzzer, as Banggood describes, and if it is passive, then capacitor is 100 nF (0.1 uF), because low frequency sounds will reproduce badly anyway of such small membrane of the speaker. If you use some bigger speaker, then consider to use 1 uF or more, the best value is 100 uF, but it is maybe overkill because any small loudspeaker that can fit in your hand has actually bad low tone reproduction. Passive buzzer on Banggood: BUZZER 1-5V

Alternative option is to use 1W GPS (General Purpose Speaker) on eBay: 1W GPS loudspeaker

Sidenote:

If you are sure that output on pin PD2 (or just 2 on Arudino pro mini V3) will not remain HIGH or digital 1, then you can omit this capacitor. DO NOT attach directly loudspeaker on the PD2 pin, because it has very low impedance and can ruin your Arduino. Although there is overcurent protection, I will not gamble with that. If sound is too loud, then add 1-500 Ohm resistor in series with loudspeaker. This way it will save power if you have battery powered device.

Schematic, for those who are lazy to visit RCgroups forum: variometer Note that on MS5611, there are used only four wires of seven. That is because other three wires are used in the case of SPI connection instead I2C as is on this schematic. Those ‘extra’ three wires leave not connected (NC). Arduino sketch, hover with mouse over the top of the code, click on “copy”, then CTRL+C for copy to buffer, and CTRL+V to paste into your Arduino IDE:

// All code by Rolf R Bakke, Oct 2012

#include <Wire.h>

const byte led = 13;

unsigned int calibrationData[7];
unsigned long time = 0;

float toneFreq, toneFreqLowpass, pressure, lowpassFast, lowpassSlow ;

int ddsAcc;

void setup()
{
Wire.begin();
Serial.begin(115200);
setupSensor();

pressure = getPressure();
lowpassFast = lowpassSlow = pressure;
}

void loop()
{
pressure = getPressure();

lowpassFast = lowpassFast + (pressure - lowpassFast) * 0.1;
lowpassSlow = lowpassSlow + (pressure - lowpassSlow) * 0.05;

toneFreq = (lowpassSlow - lowpassFast) * 50;

toneFreqLowpass = toneFreqLowpass + (toneFreq - toneFreqLowpass) * 0.1;

toneFreq = constrain(toneFreqLowpass, -500, 500);

ddsAcc += toneFreq * 100 + 2000;

if (toneFreq < 0 || ddsAcc > 0)
{
tone(2, toneFreq + 510);
}
else
{
noTone(2);
}

ledOff();
while (millis() < time); //loop frequency timer
time += 20;
ledOn();
}

long getPressure()
{
long D1, D2, dT, P;
float TEMP;
int64_t OFF, SENS;

D1 = getData(0x48, 10);
D2 = getData(0x50, 1);

dT = D2 - ((long)calibrationData[5] << 8);
TEMP = (2000 + (((int64_t)dT * (int64_t)calibrationData[6]) >> 23)) / (float)100;
OFF = ((unsigned long)calibrationData[2] << 16) + (((int64_t)calibrationData[4] * dT) >> 7);
SENS = ((unsigned long)calibrationData[1] << 15) + (((int64_t)calibrationData[3] * dT) >> 8);
P = (((D1 * SENS) >> 21) - OFF) >> 15;

//Serial.println(TEMP);
//Serial.println(P);

return P;
}

long getData(byte command, byte del)
{
long result = 0;
twiSendCommand(0x77, command);
delay(del);
twiSendCommand(0x77, 0x00);
Wire.requestFrom(0x77, 3);
if(Wire.available()!=3) Serial.println("Error: raw data not available");
for (int i = 0; i <= 2; i++)
{
result = (result<<8) | Wire.read();
}
return result;
}

void setupSensor()
{
twiSendCommand(0x77, 0x1e);
delay(100);

for (byte i = 1; i <=6; i++)
{
unsigned int low, high;

twiSendCommand(0x77, 0xa0 + i * 2);
Wire.requestFrom(0x77, 2);
if(Wire.available()!=2) Serial.println("Error: calibration data not available");
high = Wire.read();
low = Wire.read();
calibrationData[i] = high<<8 | low;
Serial.print("calibration data #");
Serial.print(i);
Serial.print(" = ");
Serial.println( calibrationData[i] );
}
}

void twiSendCommand(byte address, byte command)
{
Wire.beginTransmission(address);
if (!Wire.write(command)) Serial.println("Error: write()");
if (Wire.endTransmission())
{
Serial.print("Error when sending command: ");
Serial.println(command, HEX);
}
}

void ledOn()
{
digitalWrite(led,1);
}

void ledOff()
{
digitalWrite(led,0);
}

Debug option: ‘Serial.println’

This code by default has excluded serial print of temperature and pressure. For testing and debug of variometer – your circuit on serial monitor, remove ‘//’ tags before command lines, highlighted yellow on this picture: Arduino sketch variometer This Variometer is intended for RC models, as is DLGs, where ‘downlink’ is provided by TX and RX on 433 MHz, but if you wish to hear sound directly – without the need to ‘broadcast’ radio signal on 433 MHz, you may add capacitor of say 100 nF (or more for better low frequency reproduction) between pin ‘D2’ on Arduino nano and the audio amplifier. This capacitor serve for galvanic deoupling for protection of Arduino and amplifier. Use small audio amlifier, something like this one: LM386 audio amplifier This amplifier is proven to work on low voltage, ranging from 4 to 12 Volts. The amplifier ($2.11 US): LM386 audio amplifier on Banggood Also, aside eBay -you may find other parts on Banggood. What is the difference – Banggood is more secure and reliable seller, unlike uncertain sellers on eBay (many sellers are okay, but this is a ‘gamble’ – sometimes frustrating and wasting time).

40 thoughts on “Arduino Variometer”

  1. Hi. I am noob. What mean this code

    while (millis() < time); //loop frequency timer
    time += 20;

    I think millis() allways larger then time

    When i am not right?

    1. ‘millis’ I think it is time from start of the process, or start from the beginning of power on. Not sure right now, should look in arduino help forum. Thank you for the comment.

  2. Nice work, tested and works like a charm! Can you please help me porting this code to an Attiny85, just with the bmp180 and buzzer, to use with paraglider, my Fox still fliyng, but now is my turn…lol

    1. Tried to convert it on Attiny85, but there is a problem with sound (tone command) – it does not works as good as with ‘Big Brothers’ as is Arduino nano, Pro, Uno or Mega. For a while I am busy with my house, and then will back. There are chance to use manchester code and send signal over 433 MHZ or other frequencies to the ‘ground’ station. This way, it will be transmitted not only variation in altitude, but also current altitude (and if needed, temperature) state. Then ground station will transfer data to sound, some screen (LCD, TFT…) and tone. With some hope, it can be stored to some SD or microSD card (I havent yet bought RTC timer… will do it soon). I don’t know how soon I will be able to do anything around Arduino codes, but hope soon. Thank you for interest.

  3. Wow!! Really thanks for your prompt reply and best wishes for this new year!!
    I found this http://tinusaur.org/2015/10/14/new-library-usitwix-using-usi-as-twi-i2c/
    And they have a video on youtube doing exactly what I want, but I have stucked to put their libraries onto my IDE 1.6.7, I made a comment today and hope they can help.
    On arduino nano using the standard libraries I can madded the vario work, just the bmp180 and buzzer, but I want so much to reduce the size and using a coin cell battery. Oh and sorry about my english, I am writing from Brazil and do not have much fluency…
    Thanks for the advice about the sensor, I will buying some of this.

    1. Tell me, do you want to make variometer for ‘big’ planes or small gliders? If small gliders, then BMP180 is NOT your choice – it has error of 1 meter. That is noise produced by piezo sensor amplifier. MS5611 has noise of only 0.1 meter – ten times better than BMP180, but does not cost 10 times as much. Earlier day, price was about 10 times, but no more. I hope very soon to ‘back on track’ on Arduino projects. Quadcopters can be addictive, but I should to force myself to back to other unfinished projects as well. Your English is perfect to me, I am not fluent in it as well. Happy New Year!

  4. Hello,

    I just purchased Arduino Nano v3, MS5611 module and piezo buzzer. I do not need wireless transmission.
    This is my first time doing this. I should to learn to code first but but already so itching to get this working.
    Can you help to modify your code to get beeps with what I have ?

    Thank you!

    1. Hello.

      Thanks for post. Which type of buzzer you have? Active or passive? If active (that means buzzer operate on some voltage by itself – whistling when connected to power supply), then there is no hope – it will produce sound all the time. If passive (just make click when on some voltage), then it can be used for this circuit. The simple circuit… okay… I will make the fastest diagram possible now. Just hand draw. One capacitor and one transistor is needed to do what you want exactly.

        1. Hi
          I wired my board as in your drawing and added 0.1uF cap to base of transistor. Then copy paste the code from your link and now it has continuous beep.
          Anyidea ?

  5. Hi, I did not know about the buzzer being active or passive on mine. Then I replaced the buzzer with the speaker I received from amazon. It does make the right sound but volume is so low that I can barely hear it. It needs to be next to my ear. Also the speaker heat up very quickly.
    I am going to try passive buzzer and see how it goes.

    1. I did not get my hands on passive buzzer today. I came home and looking at the drawing, D2 is for switching and I can only imagine speaker getting pulse from 5v source. Don’t I need an amp or something to supply sinusoidal wave for speaker to play ?

    2. Please fiddle for a bit with some resistor – put it parallel to this capacitor. It is also possible to add 1 MOhm resistor between base and collector of the transistor.
      In first case of some 1 kOhm resistor parallel (or completely replacing capacitor) – signal is directly feed to the base of the transistor. DO NOT connect directly base of the transistor to the output pin. I am just suggesting, because can’t find time to experiment with all of this. Sorry. I hope you will find the solution for you.

      1. Hi, Thanks for the suggestions again. As I put in 100kohm (did not have 1Mohm on hand) between base and collector, it got louder that I can hear. But not so loud. now sure how loud this speaker is supposed to me. When I replaced the cap with 1k, it made it worse.
        But this is great starting point and thanks for your time during busy hours. .

        1. I am glad you are close to what you want. Now, when you have too loud thing, just put some resistor (10 or 100 Ohms, maybe more, depend – the more – the silent it should be) in series with loudspeaker. It should decrease current, thus decreasing volume. 1Mohm may make it even louder, but if you put below 10 kOhm, it may heat transistor and destroy loudspeaker. So, 100 kOhm seems okay. Just connect in series some resistor so that meet your requirement and wanted volume. Thank you for visiting my web pages.

  6. Hello wildman
    I’m trying to make the vario but while looking at your video in YouTube, I’ve realised that te vario will sound with any minimum climb or sink. I’m a paraglider pilot and the varios we usually use, don’t make any beep until we sink -1,5m/s or we climb more than +0.5 m/s and will be annoying to hear the vario beeping all the time when we are not climbing nor sinking too much.
    So, do you think will it be some way to silence the vario when the ammount of pressure difference is small specially when the sink is minimum. Think that in still air or when there is no lift the paragliders usually glide at -1m/s

    Thank you very much for sharing your knowledge

    Jaime

    1. Hi Jaime.

      This program is made by Rolf R Bakke, and I can try to modify it, but not sure how to do it on top of my head. By ‘silencing’ vario – total absence of any sound, or just not responding that fast? I should change program, but not sure how soon I will be able to do that, various sh*t happening here.

      1. I meant total absence of sound until the sink is grater than the normal sink of a powerless aircraft that is gliding (in this case -1m/s) -not sure of the amount of drop in pressure is that-. Don’t worry about it, you are doing more than enough just replying to our comments. Thanks again and stay strong!

  7. Hello, I have the same problem as Jaime. I have compiled a project according to instructions. It works perfectly. Amazing. For paragliding but unfortunately useless. Threatens the destruction of my head. Because of the constant whistling.
    I can not be programmed. Please Ask how to change the program. I want to be able to change the bandwidth of silence. For example, -1.5 m / s – 0 m / s.
    thank you for everything

    1. Oh, okay. Now I see that more people have the same issue… so I should to kick myself into lazy ass and inspect arduino sketch and see what can be done. Thanks for the reminder.

      1. Hi,
        Same here. I am using it for paragliding. And very excited about your project. I really thank you for it and looking forward for the parts to arrive.
        Maybe you can make one skript for paragliders:
        – without transmitting to ground; only sound connected to Arduino
        – silence during this movement: -1.5 m / s – 0 m / s

        And one for RC pilots which you have here already.

        Only if possible of course and if you have enough time.
        If you have a donation button. I would use it 🙂

        Cheeers
        ED

        1. Sorry for waiting that long. I found how to change Arduino code for paragliders. Just not willing to post it unless it is tested.
          Sensitivity can be changed in next line (original value is 50).
          line 31:
          toneFreq = (lowpassSlow – lowpassFast) * 10;
          The main part is with silencing vario when no much pressure/altitude change (now it is silent between certain points, experiment with those values -50 and 50, maybe -30/30, or -70/70, this is how much frequency will change with pressure change in time):
          line 39:

          if (toneFreq < -50 || toneFreq > 50 && ddsAcc >0 )

          Please notify me after you confirm that it is useful for paragliders.

          1. I can test it for you if you want.

            I am a paraglider and engineer and I do crazy stuff with arduino and I am very interested in this Vario project.

            My email is :(removed to avoid SPAM)

            If you want that variometer to be tested I can test and analyze further more optimize the code for you.

          2. Yes, please. Just change code as I added above. All I can test is on my desk and in room, so real test will be welcome, and will be published next to code modification. I noticed that someone buying this sensors and Arduionos over my Banggood affiliate, so probably it works for paragliders, but not sure because this code is primarily for RC gliders.
            I will also contact you over email, and I removed your email to avoid SPAM to your mailbox (some internet bot can pickup that address).
            Thanks for the interest. Will contact you soon.

    1. Hi, EDsteve, in your code, you speak of a button, on which pin of the arduino nano this button is connected?
      Do you have a wiring diagram of your assembly?
      Do you still use this variometer to practice paragliding today?

      1. Yes. I still use it today. And I still like it.

        I never test the button function though.

        Seems a pin must be assigned. Should not be difficult. But I am not a coder 🙁

        1. Oh, set button for setting zero on ground. Seems that I forgot to mention that or implement in code. I had many trials and errors, and during upload to page, probably i uploaded wrong one, or did not explain properly.

  8. Hello, I have put it in my rc glider and I send the sound through FPV, but I don’t know why sometimes it sounds an alarm that takes a long time to stop. When it doesn’t sound, the vario works well but if I lose height very quickly the alarm starts to sound and it doesn’t stop anymore.

  9. Hello Milan, thanks for your blog. It’s nice that you can read all relevant information here.
    In the RCGR forum everything has become a bit confusing and hard for non-electronic people to understand everything.

    I built the Vario exactly according to your article and transferred the sketch to the Arduino.
    But unfortunately I get a sound that I can’t interpret. See the video.
    https://www.youtube.com/watch?v=X7ofCUKzL00&feature=youtu.be

    The wiring is exactly the same as on the picture.
    Sensor GY-63
    VCC-get 4.1v from arduino port
    gnd goes to gnd
    SCL goes to A5 (Arduino)
    SDA goes to A4 (Arduino)

    Arduino
    VCC in get 5v from BEC
    GND goes to GND from BEC
    Pin D2 goes to speaker with capacitor (220uF and resistor 150 ohm) in series.(Currently i only have the 220uF capazitor until my orderd set will arrive)

    Can you help me to find the error?
    Thank you very much.
    I really appreciate the help.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.