GithubHelp home page GithubHelp logo

yenya / ibus-altitude-sensor Goto Github PK

View Code? Open in Web Editor NEW
28.0 4.0 3.0 3.5 MB

I-Bus Altitude Sensor for FlySky Telemetry

License: GNU General Public License v2.0

Makefile 13.00% C 36.26% CSS 21.90% Assembly 8.59% HTML 20.25%

ibus-altitude-sensor's Introduction

I-Bus Altitude Sensor for FlySky Telemetry

Requirements

  • FlySky transmitter with AFHDS-2A telemetry. Preferably FS-i6 with modified firmware from qba667.
  • Receiver with I-Bus sensor input, such as FS-iA6B. No firmware modification required.
  • Atmel AVR-based board. Tested with SparkFun ProMicro clone, and Arduino Nano clone. ProMicro is about the lightest but powerful ATmega-based board. Nano is a bit heavier, but it has 3.3V dedicated output, so that it can be directly used with BMP-280 breakout board.
  • Supported pressure sensor with I2C on a break-out board. Currently supported is BMP-180 on a GY-68 board, and BMP-280 break-out board. The later is more precise, but it requires 3.3 V power.
  • 390K and 15K resistors for voltage divider for reading the battery voltage (optional).
  • some wires and a 3-pin servo female connector for I-Bus.
  • AVR toolchain (avr-gcc, avr-libc, avrdude, make, ...).

Wiring

Here is how to connect things together:

wiring

And here is my (rather messy) real-world example in Sky Surfer 1400:

Wiring in Sky Surfer 1400

Here is the version with Arduino Nano and BMP-280:

Nano with BMP280

Firmware

The firmware is based on the following libraries:

The I-Bus code is in the main file ibus-sensor.c. It provides the following sensors:

  • Temperature sensor from BMPxxx
  • Altitude relative to the power-on value
  • Absolute altitude (reported as GPS-Altitude sensor)
  • Maximum relative altitude reached since power on
  • Climb rate
  • External voltage (can be used for battery voltage alarm; optional)

It also provides visual feedback about the main loop (on-board Tx LED) and the I-Bus communication (on-board Rx LED).

Edit the Makefile to set up the exact AVR board version and pressure sensor used.

License

This project, is licensed under the terms of GNU General Public License, version 2 (only). See the file COPYING.

Author

Written by Jan "Yenya" Kasprzak.

ibus-altitude-sensor's People

Contributors

yenya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ibus-altitude-sensor's Issues

Use an attiny85 or any board of choice via Arduino IDE

Thank you for this nice project!
I like to make an altitude sensor to use in cooperation with the FlyPlus firmware; I was just wondering if it might be possible to use an attiny85 instead of one of the Arduino clones you have used.
It is probably just a minor change in the Makefile (like 1MHz and AVRDUDE settings) but that is just the part I am not familiar with, since I normally program the different boards/mcu's via the Arduino IDE and everything is configured in there.
Do you have an idea if this is easy to do and how? Or might it maybe be an idea to add an .ino file to compile and upload the source via the Arduino IDE to any board or mcu of choice?

Thank you in advance!

Trouble compiling for arduino nano

I modified the makefile in order to compile for the arduino nano instead of the promicro but i then get a bunch of errors:
ibus-sensor.c: In function 'serial_init':
ibus-sensor.c:85:2: error: 'UBRR1' undeclared (first use in this function)
UBRR1 = UBRR_VAL;
^
ibus-sensor.c:85:2: note: each undeclared identifier is reported only once for each function it appears in
ibus-sensor.c:87:2: error: 'UCSR1A' undeclared (first use in this function)
UCSR1A = 0;
^
ibus-sensor.c:89:2: error: 'UCSR1B' undeclared (first use in this function)
UCSR1B = _BV(RXEN1) | _BV(RXCIE1) | _BV(UDRIE1);
^
In file included from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/io.h:99:0,
from /Applications/Arduino.app/Contents/Java/hardware/tools/avr/avr/include/avr/interrupt.h:38,
from ibus-sensor.c:3:
ibus-sensor.c:89:15: error: 'RXEN1' undeclared (first use in this function)
UCSR1B = _BV(RXEN1) | _BV(RXCIE1) | _BV(UDRIE1);
[...]
Is there anything I'm doing wrong? Thanks for your help

Compiling issue

Sir @Yenya could you please help me where to compile the "ibus-sensor.c" file and upload it to Arduino nano??
Because Arduino ide is only accepting file in .ino format not .c
if I am wrong please correct me.

build error

Thanks for your work @Yenya !

When building in ATMEL Studio, I got the error :
recipe for target 'gccversion' failed.

The line that is in error is the 389 of the makefile :
388 gccversion :
389 @$(CC) --version

So I put them on the same line, and I got this error :
make: *** No rule to make target '@AVR-GCC', needed by 'gccversion'. Stop.

Do you have an idea of what to do?

With what program did you compile it?

With what program did you compile it?
I have used make with WinAVR and XLoader. I work for BMP280 with nano, but for bmp180 with pro micro it doesn't work I don't get ibus-sensor.hex

Now I see that the problem only happens when using Pro Micro, With arduino nano it works well for both BMP180 / 280 sensors.

`-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling C: ibus-sensor.c
avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -DSENSOR_BMP085 -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./ibus-sensor.lst -std=gnu99 -MMD -MP -MF .dep/ibus-sensor.o.d ibus-sensor.c -o ibus-sensor.o
In file included from ibus-sensor.c:8:
bmp085/bmp085.h:69: warning: function declaration isn't a prototype
bmp085/bmp085.h:70: warning: function declaration isn't a prototype
bmp085/bmp085.h:71: warning: function declaration isn't a prototype
bmp085/bmp085.h:72: warning: function declaration isn't a prototype
ibus-sensor.c: In function 'read_adc_sync':
ibus-sensor.c:166: error: 'ADCW' undeclared (first use in this function)
ibus-sensor.c:166: error: (Each undeclared identifier is reported only once
ibus-sensor.c:166: error: for each function it appears in.)
ibus-sensor.c: At top level:
ibus-sensor.c:375: fatal error: opening dependency file .dep/ibus-sensor.o.d: No such file or directory
compilation terminated.
make: *** [ibus-sensor.o] Error 1`

how to make it work?

Hi, can you please explain, how to make it work and use your device. My steps was:
1 made a very simple diy arduino board(small one), it doesn't have any usb-uart chip on it, only
2 compile source code , using winavr and last avr toolchain 3.6.2, selecting mcu=328 and bmp085, getting lots of warnings and hex file of 16kb. here is compiling log.

`C:\ibus-altitude-sensor-master>make

-------- begin --------
avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.2_1759) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling C: bmp085/bmp085.c
avr-gcc -c -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -DSENSOR_BMP085 -Os
-funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-
enums -Wall -Wstrict-prototypes -Wa,-adhlns=./bmp085/bmp085.lst -std=gnu99 bmp
085/bmp085.c -o bmp085/bmp085.o
In file included from bmp085/bmp085.c:18:0:
bmp085/bmp085.h:69:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern void bmp085_init();
^
bmp085/bmp085.h:70:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern int32_t bmp085_getpressure();
^
bmp085/bmp085.h:71:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern double bmp085_getaltitude();
^
bmp085/bmp085.h:72:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern double bmp085_gettemperature();
^
bmp085/bmp085.c:71:6: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
void bmp085_getcalibration() {
^
bmp085/bmp085.c:102:6: warning: function declaration isn't a prototype [-Wstrict
-prototypes]
void bmp085_getrawtemperature() {
^
bmp085/bmp085.c:122:6: warning: function declaration isn't a prototype [-Wstrict
-prototypes]
void bmp085_getrawpressure() {
^
bmp085/bmp085.c:163:8: warning: function declaration isn't a prototype [-Wstrict
-prototypes]
double bmp085_gettemperature() {
^
bmp085/bmp085.c:173:9: warning: function declaration isn't a prototype [-Wstrict
-prototypes]
int32_t bmp085_getpressure() {
^
bmp085/bmp085.c:181:8: warning: function declaration isn't a prototype [-Wstrict
-prototypes]
double bmp085_getaltitude() {
^
bmp085/bmp085.c:189:6: warning: function declaration isn't a prototype [-Wstrict
-prototypes]
void bmp085_init() {
^

Compiling C: ibus-sensor.c
avr-gcc -c -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -DSENSOR_BMP085 -Os
-funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-
enums -Wall -Wstrict-prototypes -Wa,-adhlns=./ibus-sensor.lst -std=gnu99 ibus-
sensor.c -o ibus-sensor.o
In file included from ibus-sensor.c:8:0:
bmp085/bmp085.h:69:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern void bmp085_init();
^
bmp085/bmp085.h:70:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern int32_t bmp085_getpressure();
^
bmp085/bmp085.h:71:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern double bmp085_getaltitude();
^
bmp085/bmp085.h:72:1: warning: function declaration isn't a prototype [-Wstrict-
prototypes]
extern double bmp085_gettemperature();
^

Compiling C: i2chw/twimaster.c
avr-gcc -c -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -DSENSOR_BMP085 -Os
-funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-
enums -Wall -Wstrict-prototypes -Wa,-adhlns=./i2chw/twimaster.lst -std=gnu99 i
2chw/twimaster.c -o i2chw/twimaster.o

Linking: ibus-sensor.elf
avr-gcc -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=16000000UL -DSENSOR_BMP085 -Os -f
unsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enu
ms -Wall -Wstrict-prototypes -Wa,-adhlns=bmp085/bmp085.o -std=gnu99 bmp085/bmp
085.o ibus-sensor.o i2chw/twimaster.o --output ibus-sensor.elf -Wl,-Map=ibus-sen
sor.map,--cref -Wl,--relax -Wl,--gc-sections -lm

Creating load file for Flash: ibus-sensor.hex
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature ibus-sensor.elf i
bus-sensor.hex

Creating load file for EEPROM: ibus-sensor.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load"
--change-section-lma .eeprom=0 --no-change-warnings -O ihex ibus-sensor.elf ibus
-sensor.eep || exit 0

Creating Extended Listing: ibus-sensor.lss
avr-objdump -h -S -z ibus-sensor.elf > ibus-sensor.lss

Creating Symbol Table: ibus-sensor.sym
avr-nm -n ibus-sensor.elf > ibus-sensor.sym

Size after:
text data bss dec hex filename
5484 6 70 5560 15b8 ibus-sensor.elf

-------- end --------

C:\ibus-altitude-sensor-master>`

  1. uploaded code via Xloader to my arduino board and connect the board to ia6b as shown in the schematic, shorting rx to tx with a jumper. And get nothing (( I cannot see any telemetry data from receiver. What I do wrong?
    I use 1.7.5 firmware on transmiter https://github.com/qba667/FlySkyI6/releases/download/1.7.5/fs-i6_vario_deadband.zip
    and https://github.com/povlhp/FlySkyRxFirmware/blob/master/firmwares/iA6B_1.6.bin firmware on receiver.

Can GPS to sensor bringen?

Hi Yenya!
Very nice project.
I build it, programmed and all working from start.
Maybe you can add GPS speed to this sensor than we have complette sensor for electroglider.
I have few gps module than I can help witch tests.
When you want I can send one to you for tests.
I'm living in Germany.
I know Arduino have only one hw serial but exists much libraries for sw serials.
I'm learnigg Arduino than for me this is too much to add this.
You write this in pure C.
Data from gps not to speed came than I think this is no problem.
When you make this in software than i make PCB with ready to build sensor.

With Best Regards
Darek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.