Team DIANA / Mbed OS Scientific_RTOS

Dependencies:   BOX_1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SI7021.h Source File

SI7021.h

00001 #ifndef SI7021_H
00002 #define SI7021_H
00003 
00004 #include "mbed.h"
00005 
00006 
00007 #define READ_TEMP        0xE0   // Read Temperature Command
00008 #define READ_HUM          0xE5   //  Read RH Command
00009 
00010 /***** Si7012 Read ID *****/
00011 #define READ_ID1_1       0xFA
00012 #define READ_ID1_2       0x0F
00013 #define READ_ID2_1       0xFC
00014 #define READ_ID2_2       0xC9
00015 
00016 #define ADDR    0x80            //Device address
00017 #define FREQ    100000          //Device frequency
00018 #define DEVICE_ID 0x15          //Device id value
00019 
00020 class SI7021
00021 {
00022     public:
00023 
00024         SI7021(PinName sda, PinName scl);
00025         int32_t get_temperature();  // Get last measured temperature data (ºC)
00026         uint32_t get_humidity();    // Get last measured relative humidity data (%)
00027         bool get_data();             // Perform measurement, return: 0 if successful
00028         bool check();               // Check if the sensor is active
00029 
00030     private:
00031 
00032         I2C i2c;
00033         uint8_t  buff_rx[8];
00034         uint8_t  buff_tx[2];
00035         uint32_t humData;
00036         int32_t  tempData;
00037 };
00038 
00039 #endif