https://github.com/aler9/sensor-hp203b
C library for interacting with the HP203B barometer sensor
https://github.com/aler9/sensor-hp203b
barometer hp203b
Last synced: about 2 months ago
JSON representation
C library for interacting with the HP203B barometer sensor
- Host: GitHub
- URL: https://github.com/aler9/sensor-hp203b
- Owner: aler9
- License: mit
- Created: 2019-09-18T12:34:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-28T16:39:36.000Z (over 5 years ago)
- Last Synced: 2024-10-06T05:06:23.638Z (8 months ago)
- Topics: barometer, hp203b
- Language: C
- Size: 16.6 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sensor-hp203b
C library for interacting with the HP203B barometer sensor.
Features:
* works with the Raspberry Pi and probably with almost every single-board computer equipped with I2C## Installation
Copy all the files ending with `.c` and `.h` into your project folder.
## Usage
```
#include
#include
#include
#include#include "hp203b.h"
int main() {
int i2c_fd = open("/dev/i2c-1", O_RDWR);
if(i2c_fd < 0) {
return -1;
}hp203bt* hp203b;
error* err = hp203b_init(&hp203b, i2c_fd, DSR_4096);
if(err != NULL) {
return -1;
}err = hp203b_do_adc(hp203b, 1);
if(err != NULL) {
return -1;
}double p;
err = hp203b_get_pressure(hp203b, &p);
if(err != NULL) {
return -1;
}double a;
err = hp203b_get_altitude(hp203b, &a);
if(err != NULL) {
return -1;
}double t;
err = hp203b_get_temperature(hp203b, &t);
if(err != NULL) {
return -1;
}printf("%f %f %f\n", p, t, a);
return 0;
}
```