Arduino Nano Altimeter Using GY-BMP280

17,521

16

10

Introduction: Arduino Nano Altimeter Using GY-BMP280

This is my first project.

I searched how to setup this sensor using i2c with an Arduino Nano but couldn't find anything that worked right away. I had to change some stuff in the default library to get it work with my sensor and wrote a simple sketch to store the data and display it to the serial monitor.

I started flying RC planes and wanted something to check how far up I went. the next step is to integrate the data in the OSD (on screen display, used for flying FPV).

Step 1: Copy Paste Code and Library

the wiring is simple:

VCC to the 3V3 (important, do not use 5V, could destroy the sensor)

GND to GND

SDA to A4

SCL to A5

If the code does not work, but you hooked up everything accordingly try scanning for i2c devices using the scanner (not my program, author is declared in the header, also I didn't write most of the other, I left the original header of those as well). I changed the i2c address in the library to 0x76 as the sensor appeared on my scanner. if you detect your sensor on 0x77 just change this in the library.
If this still does not work you need to change the wire connection. On my Arduino Nano (some cheap chinese knock-off) I figured that the i2c ports are on A4 and A5. But there are several versions out there and some of them seem to use pin 4 (SDA) and pin 5 (SCL). If it still does not work you could download some other guys code. good luck! I hope it worked though :)

I will soon (if I get it to work) program the arduino to output the data via PWM (FrSky Smart Sensor) to use telemetry and compatibility with mini OSD

edit1: added new testing.ino file (code for arduino) that should be sleeker. make sure you have the libraries in the correct folder. ( /arduino/libraries/"library name"/"library name".h ) this caused me some trouble...

3 People Made This Project!

Recommendations

  • For the Home Contest

    For the Home Contest
  • Big and Small Contest

    Big and Small Contest
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge

10 Comments

0
RobertP416
RobertP416

4 years ago

works with the i2C, but i have to add level shifter and modify the address in Adafruit_BMP280.h from 0x77 to 0x76

0
steveinjava
steveinjava

4 years ago

This chip is 3.3V logic so it ought not to work with 5V logic. That is the SDA and SCL should need a converter. But if you are sure this works then there must be tolerance in the system somewhere...Thanks for the info

0
cladeport
cladeport

Reply 4 years ago

It worked for me. But i would check the datasheet of your sensor. Logic level shifters are cheaper than good sensors :)

0
nediffs
nediffs

5 years ago

By the way, if you're not using just SDA +SCL but all the pins then the variable needs to be

#define BMP_SCK 13

#define BMP_MISO 12

#define BMP_MOSI 11

#define BMP_CS 10

Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);

instead of just

Adafruit_BMP280 bme;

Had a huge issue with that, thought my soldering was shit, then I thought i screwed the sensor, but thanks to the i2c scanner seeing the sensor I eventually figured it out.

0
nliviu
nliviu

Reply 5 years ago

How did you map BMP_SCK, BMP_MISO, BMP_MOSI and BMP_CS to the SCL, SDA, CSB and SD9 pins?

Thank you.

0
nediffs
nediffs

Reply 5 years ago

Here's how mine is set:
VCC to 3.3V
GND to GND
SCL to 13 (BMO_SCK)
SDA to 11 (BMP_MOSI)
CSB to 10 (BMP_CS)
SDO to 12 (BMP_MISO)

Believe it or not I think I went trough every possible combination to figure out what goes where ... I used some online site to give me all possible combos of 4 items and went trough them all ...

0
nliviu
nliviu

Reply 5 years ago

Thank you.

0
cladeport
cladeport

Reply 5 years ago

I used i2c not SPI protocol, i think if you look up your specific arduino board pinout you should find the appropriate pins on your board and then declare them in the program. Look into the library wire.h to simplify the use of SPI.
-also search for an SPI library on the Arduino IDE.
I hope this helps

0
Swansong
Swansong

6 years ago

Thanks for sharing :)

0
cladeport
cladeport

Reply 6 years ago

did you get to try it out?