资源简介
气压传感器lcd1602显示
代码片段和文件信息
/*
BMP085 Test Code
April 7 2010
by: Jim Lindblom
Test code for the BMP085 Barometric Pressure Sensor.
We‘ll first read all the calibration values from the sensor.
Then the pressure and temperature readings will be read and calculated.
Also attempts to calculate altitude (remove comments)
The sensor is run in ultra low power mode.
Tested on a 3.3V 8MHz Arduino Pro
A4 (PC4) -> SDA
A5 (PC5) -> SCL
No Connection to EOC or XCLR pins
*/
#include
#include
#include
#include
#include
#include “types.h“
#include “defs.h“
//#include “math.h“ // To calculate altitude
#include “i2c.h“
#define FOSC 8000000
#define BAUD 9600
#define BMP085_R 0xEF
#define BMP085_W 0xEE
#define OSS 0 // Oversampling Setting (note: code is not set up to use other OSS values)
#define sbi(var mask) ((var) |= (uint8_t)(1 << mask))
#define cbi(var mask) ((var) &= (uint8_t)~(1 << mask))
///============Function Prototypes=========/////////////////
void BMP085_Calibration(void);
///============I2C Prototypes=============//////////////////
short bmp085ReadShort(unsigned char address);
long bmp085ReadTemp(void);
long bmp085ReadPressure(void);
void bmp085Convert(long * temperature long * pressure);
///============Initialize Prototypes=====//////////////////
void ioinit(void);
void UART_Init(unsigned int ubrr);
static int uart_putchar(char c FILE *stream);
void put_char(unsigned char byte);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar NULL _FDEV_SETUP_WRITE);
void delay_ms(uint16_t x);
/////=========Global Variables======////////////////////
short ac1;
short ac2;
short ac3;
unsigned short ac4;
unsigned short ac5;
unsigned short ac6;
short b1;
short b2;
short mb;
short mc;
short md;
int main(void)
{
long temperature = 0;
long pressure = 0;
//long altitude = 0;
//double temp = 0;
ioinit();
i2cInit();
delay_ms(100);
BMP085_Calibration();
while(1)
{
bmp085Convert(&temperature &pressure);
printf(“Temperature: %ld (in 0.1 deg C)\n“ temperature);
printf(“Pressure: %ld Pa\n\n“ pressure);
// For fun lets convert to altitude
/*temp = (double) pressure/101325;
temp = 1-pow(temp 0.19029);
altitude = round(44330*temp);
printf(“Altitude: %ldm\n\n“ altitude);*/
delay_ms(1000);
}
}
void BMP085_Calibration(void)
{
printf(“\nCalibration Information:\n“);
printf(“------------------------\n“);
ac1 = bmp085ReadShort(0xAA);
ac2 = bmp085ReadShort(0xAC);
ac3 = bmp085ReadShort(0xAE);
ac4 = bmp085ReadShort(0xB0);
ac5 = bmp085ReadShort(0xB2);
ac6 = bmp085ReadShort(0xB4);
b1 = bmp085ReadShort(0xB6);
b2 = bmp085ReadShort(0xB8);
mb = bmp085ReadShort(0xBA);
mc = bmp085ReadShort(0xBC);
md = bmp085ReadShort(0xBE);
printf(“\tAC1 = %d\n“ ac1);
printf(“\tAC2 = %d\n“ ac2);
printf(“\tAC3 = %d\n“ ac3);
printf(“\tAC4 = %d\n“ ac4);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 126976 2011-07-17 12:32 GY-65气压模块发送资料\bmp085模块引脚图.JPG
文件 88765 2012-05-24 11:41 GY-65气压模块发送资料\电路图.jpg
文件 566501 2011-03-31 23:32 GY-65气压模块发送资料\数据手册\BMP085_Flyer_Rev.0.2_March2008.pdf
文件 842732 2011-02-28 16:29 GY-65气压模块发送资料\数据手册\BMP085.pdf
文件 12165 2012-06-02 15:39 GY-65气压模块发送资料\GY-65测试程序\51-MCU\51单片机串口输出BMP085.txt
文件 170671 2011-07-30 14:01 GY-65气压模块发送资料\GY-65测试程序\51-MCU\GY-65气压模块接线图.jpg
文件 12972 2012-06-02 15:34 GY-65气压模块发送资料\GY-65测试程序\51-MCU\STC51-BMP085 LCD1602测试程序.txt
文件 4623 2011-12-24 23:06 GY-65气压模块发送资料\GY-65测试程序\Arduino\BMP085\BMP085_TEST\BMP085_TEST.pde
文件 2367 2008-04-27 17:21 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\defs.h
文件 5123 2010-04-08 13:55 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\i2c.h
文件 7216 2011-07-16 21:03 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\main.c
文件 12499 2010-04-08 15:11 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\main.hex
文件 19518 2010-04-07 13:38 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\Makefile
文件 16110 2010-01-09 18:03 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\math.h
文件 1521 2007-09-23 13:34 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328\types.h
目录 0 2012-06-02 15:36 GY-65气压模块发送资料\GY-65测试程序\Arduino\BMP085\BMP085_TEST
目录 0 2012-06-02 15:40 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code\ATmega328
目录 0 2012-06-02 15:36 GY-65气压模块发送资料\GY-65测试程序\Arduino\BMP085
目录 0 2012-06-02 15:40 GY-65气压模块发送资料\GY-65测试程序\AVR\BMP085 Example Code
目录 0 2012-06-02 15:35 GY-65气压模块发送资料\GY-65测试程序\51-MCU
目录 0 2012-06-02 15:36 GY-65气压模块发送资料\GY-65测试程序\Arduino
目录 0 2012-06-02 15:40 GY-65气压模块发送资料\GY-65测试程序\AVR
目录 0 2012-06-02 15:35 GY-65气压模块发送资料\数据手册
目录 0 2012-06-02 15:35 GY-65气压模块发送资料\GY-65测试程序
目录 0 2011-07-17 12:25 GY-65气压模块发送资料
----------- --------- ---------- ----- ----
1889759 25
- 上一篇:TCP网速加速器.zip
- 下一篇:如何捆绑exe和影音文件
评论
共有 条评论