Beruflich Dokumente
Kultur Dokumente
Distributed
with a
free-will
license.
// Use it any way you want, profit or free, provided it fits in the licenses
of its associated works.
// BMP180
// This code is designed to work with the BMP180_I2CS I2C Mini Module
available from ControlEverything.com.
// https://www.controleverything.com/content/Pressure?sku=BMP180_I2CS#tabs-0-
product_tabset-2
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <math.h>
void main()
{
// Create I2C bus
int file;
char *bus = "/dev/i2c-1";
if((file = open(bus, O_RDWR)) < 0)
{
printf("Failed to open the bus. \n");
exit(1);
}
// Get I2C device, VEML6070 I2C address is 0x77(119)
ioctl(file, I2C_SLAVE, 0x77);
// Calculate Altitude
long altitude = 44330 * (1 - pow(pressure1/1013.25, 0.1903));