Git Product home page Git Product logo

sensor-hp203b's Introduction

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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

#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;
}

sensor-hp203b's People

Contributors

aler9 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

braveheart007

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.