Grove - Barometer Sensor

From openPicus Wiki
Jump to: navigation, search

Contents

Device description

621px-Grove-Barometer.jpg The device is based on Bosch BMP085 high-accuracy chip to detect barometric pressure and temperature. It can widely measure pressure ranging from 300hPa to 1100hPa, AKA +9000m to -500m above sea level, with a super high accuracy of 0.03hPa(0.25m) in ultra-high resolution mode.

The communication with Flyport is realized through a specific library only needing few commands to make it works.It has a I2C interface.
Specifications:

  • power supply: 3.3 - 5V;
  • Wide barometric pressure range
  • Ultra-low power consumption
  • Temperature measurement included
  • Fully calibrated

Applications:

  • Enhancement of GPS navigation
  • Weather forecast
  • Vertical velocity indication (rise/sink speed)

How to use

This device uses its specific library plus the Grove basic libraries that are embedded into the GROVE TEMPLATE available from IDE 2.3. Just create a new Project on the IDE using the right GROVE TEMPLATE.
The device must be connected on the I2C port of the Grove board.
Accelerometer can share I2C bus with other Grove devices using a different address (all the incompatible devices are specifically adviced in this wiki). You can use only one accelerometer device per I2C port.

  • Connect to port: I2C;
  • Library to use: Barometer library + Grove basic library included into each Grove Template on the IDE

Once the library is added to the project, using the External lib button, the line #include "barometer.h" must be inserted in taskFlyport.c to include the header file. The line must also be inserted in HTTPApp.c if you want to access the device from webserver.

More infos and examples can be found in the Grove Library page.

Software commands

As usual the steps the use the device are:

  • Initialization: the device is initialized as Baro type and the I2C address is specified. In this case the I2C address is unique and is used the constant BAROM_ADDR, so the function to use is void* device_name = new(Baro, BAROM_ADDR);
  • definition of the port: the sensor must be "attached" to the right port of the board, in this case the I2C port: attachToPort(board_name, device_name, I2C);
  • configuration: no additional parameters are needed, it's just an hardware initialization of the sensor. So it requires only the name of the device: configure(device_name);
  • reading of the data: the two values(temperature and pressure) can be read separately, so in the get() function must be specified the name of the sensor and the desired parameter:
parameter function
Temperature get(device_name, BMP085_TEMP);
Pressure get(device_name, BMP085_PRES);

Pay attention: Remember to check the flag status, performing readError() funcion, in order to know if the data that you have just got is valid or not

Example

#include "taskFlyport.h"
#include "grovelib.h"
#include "barometer.h"
 
void FlyportTask()
{	
 
	vTaskDelay(50);
	UARTWrite(1,"Welcome to GROVE NEST example!\r\n");
 
	// GROVE board
	void *board = new(Board);
 
	// Barometer GROVE device	
	void *baro = new(Baro,BAROM_ADDR);
 
	//Attach Barometer device to the I2C port 
	attachToBoard(board, baro, I2C);
 
	if(!configure(baro))
		UARTWrite(1,"Barometric sensor configured properly!\r\n");
	else
		UARTWrite(1,"Error: no response from Barometric sensor!\r\n");
 
	char msg[45];
	float data =0;
	while(1)
	{
		vTaskDelay(200);
		data = get(baro,BMP085_TEMP);
		if(!readError())
		{
			sprintf(msg,"Temperature %f\n\r",(double)data);
			UARTWrite(1,msg);
		}
		vTaskDelay(200);
		data = get(baro,BMP085_PRES);
		if(!readError())
		{
			sprintf(msg,"Pressure %f\n\r",(double)data);
			UARTWrite(1,msg);
		}
	}
}

External references

  • Seeed studio wiki: complete guide of the Barometer Grove device;
Personal tools
Namespaces

Variants
Actions
START HERE
DEVELOPMENT
HARDWARE INFO
RESOURCES
PHASED OUT
Toolbox