sensor UV VEML6070, y magnetometro GY 273
SENSOR.h@2:d8487cc76ee2, 2018-06-26 (annotated)
- Committer:
- FannyCalle
- Date:
- Tue Jun 26 15:12:33 2018 +0000
- Revision:
- 2:d8487cc76ee2
- Parent:
- 0:46f5737fe936
areglada la trama ; falta magne;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
FannyCalle | 0:46f5737fe936 | 1 | #ifndef SENSOR_H |
FannyCalle | 0:46f5737fe936 | 2 | #define SENSOR_H |
FannyCalle | 0:46f5737fe936 | 3 | |
FannyCalle | 0:46f5737fe936 | 4 | #include "mbed.h" |
FannyCalle | 0:46f5737fe936 | 5 | //************************************************************* |
FannyCalle | 0:46f5737fe936 | 6 | // definiciones de registros |
FannyCalle | 0:46f5737fe936 | 7 | //************************************************************* |
FannyCalle | 0:46f5737fe936 | 8 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 9 | //sensor uv(veml6070) |
FannyCalle | 0:46f5737fe936 | 10 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 11 | #define UV_ADDR_ARA (0x18)// para leer la parte alta |
FannyCalle | 0:46f5737fe936 | 12 | #define UV_ADDR_MO (0x70)// para leer la parte baja |
FannyCalle | 0:46f5737fe936 | 13 | #define UV_ADDR_H (0x39 << 1)// para leer la parte alta |
FannyCalle | 0:46f5737fe936 | 14 | #define UV_ADDR_L (0x38 << 1)// para leer la parte baja |
FannyCalle | 0:46f5737fe936 | 15 | |
FannyCalle | 0:46f5737fe936 | 16 | |
FannyCalle | 0:46f5737fe936 | 17 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 18 | //sensor magnetometro(hmc5883l) |
FannyCalle | 0:46f5737fe936 | 19 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 20 | #define mag_IDENT_A 0x0A // In this case the identification register A is used to identify the devide. ASCII value H |
FannyCalle | 0:46f5737fe936 | 21 | #define mag_I2C 0x0D // 7-bit address. 0x3C write, 0x3D read. |
FannyCalle | 0:46f5737fe936 | 22 | #define mag_I2C_W 0x1A // Same as (& 0xFE), ensure that the MSB bit is being set to zero (RW=0 -> Writing) |
FannyCalle | 0:46f5737fe936 | 23 | #define mag_I2C_R 0x1B // Same as (| 0x01), ensure that the MSB bit is being set to one (RW=1 -> Reading) |
FannyCalle | 0:46f5737fe936 | 24 | |
FannyCalle | 0:46f5737fe936 | 25 | #define mag_CRA 0x00 //configuracion de registro A |
FannyCalle | 0:46f5737fe936 | 26 | #define mag_CRB 0x01 //configuracion de registro B |
FannyCalle | 0:46f5737fe936 | 27 | #define mag_MR 0x02 //registro de modo del sensor |
FannyCalle | 0:46f5737fe936 | 28 | #define mag_SR 0x09 //registro de estado |
FannyCalle | 0:46f5737fe936 | 29 | |
FannyCalle | 0:46f5737fe936 | 30 | #define mag_DXRA 0x03 //registro alto de datos de X |
FannyCalle | 0:46f5737fe936 | 31 | #define mag_DXRB 0x04 //registro bajo de datos X |
FannyCalle | 0:46f5737fe936 | 32 | #define mag_DYRA 0x05 //registro alto de datos de Y |
FannyCalle | 0:46f5737fe936 | 33 | #define mag_DYRB 0x06 //registro bajo de datos Y |
FannyCalle | 0:46f5737fe936 | 34 | #define mag_DZRA 0x07 //registro alto de datos de Z |
FannyCalle | 0:46f5737fe936 | 35 | #define mag_DZRB 0x08 //registro bajo de datos Z |
FannyCalle | 0:46f5737fe936 | 36 | /* |
FannyCalle | 0:46f5737fe936 | 37 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 38 | // sensor imu(mpu6050) |
FannyCalle | 0:46f5737fe936 | 39 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 40 | |
FannyCalle | 0:46f5737fe936 | 41 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 42 | // conversor analogo/digital (ads1115) |
FannyCalle | 0:46f5737fe936 | 43 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 44 | */ |
FannyCalle | 0:46f5737fe936 | 45 | class SENSOR |
FannyCalle | 0:46f5737fe936 | 46 | { |
FannyCalle | 0:46f5737fe936 | 47 | public: |
FannyCalle | 0:46f5737fe936 | 48 | SENSOR(PinName sda, PinName scl); // definicion de los pines i2c por los cuales se accede. |
FannyCalle | 0:46f5737fe936 | 49 | |
FannyCalle | 0:46f5737fe936 | 50 | //************************************************************ |
FannyCalle | 0:46f5737fe936 | 51 | // definiciones de funciones publicas, a las que se puede acceder desde otro programa |
FannyCalle | 0:46f5737fe936 | 52 | //************************************************************ |
FannyCalle | 0:46f5737fe936 | 53 | |
FannyCalle | 0:46f5737fe936 | 54 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 55 | //sensor uv(veml6070) |
FannyCalle | 0:46f5737fe936 | 56 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 57 | uint16_t getUV(void); |
FannyCalle | 0:46f5737fe936 | 58 | void inicial(void); |
FannyCalle | 0:46f5737fe936 | 59 | |
FannyCalle | 0:46f5737fe936 | 60 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 61 | //sensor magnetometro(hmc5883l) |
FannyCalle | 0:46f5737fe936 | 62 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 63 | uint16_t getMx(void); |
FannyCalle | 0:46f5737fe936 | 64 | uint16_t getMy(void); |
FannyCalle | 0:46f5737fe936 | 65 | uint16_t getMz(void); |
FannyCalle | 0:46f5737fe936 | 66 | /* |
FannyCalle | 0:46f5737fe936 | 67 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 68 | // sensor imu(mpu6050) |
FannyCalle | 0:46f5737fe936 | 69 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 70 | uint16_t getGx(void); |
FannyCalle | 0:46f5737fe936 | 71 | uint16_t getGy(void); |
FannyCalle | 0:46f5737fe936 | 72 | uint16_t getGz(void); |
FannyCalle | 0:46f5737fe936 | 73 | uint16_t getAx(void); |
FannyCalle | 0:46f5737fe936 | 74 | uint16_t getAy(void); |
FannyCalle | 0:46f5737fe936 | 75 | uint16_t getAz(void); |
FannyCalle | 0:46f5737fe936 | 76 | uint16_t getTEM(void); |
FannyCalle | 0:46f5737fe936 | 77 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 78 | // conversor analogo/digital (ads1115) |
FannyCalle | 0:46f5737fe936 | 79 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 80 | |
FannyCalle | 0:46f5737fe936 | 81 | */ |
FannyCalle | 0:46f5737fe936 | 82 | private: |
FannyCalle | 0:46f5737fe936 | 83 | //************************************************************* |
FannyCalle | 0:46f5737fe936 | 84 | // definiciones de funciones privada, solo para la libreria |
FannyCalle | 0:46f5737fe936 | 85 | //************************************************************* |
FannyCalle | 0:46f5737fe936 | 86 | char cmd[2]; |
FannyCalle | 0:46f5737fe936 | 87 | I2C i2c; |
FannyCalle | 0:46f5737fe936 | 88 | char Read(char data); |
FannyCalle | 0:46f5737fe936 | 89 | void Write(char reg_address, char data); |
FannyCalle | 0:46f5737fe936 | 90 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 91 | //sensor uv(veml6070) |
FannyCalle | 0:46f5737fe936 | 92 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 93 | |
FannyCalle | 0:46f5737fe936 | 94 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 95 | //sensor magnetometro(hmc5883l) |
FannyCalle | 0:46f5737fe936 | 96 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 97 | |
FannyCalle | 0:46f5737fe936 | 98 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 99 | // sensor imu(mpu6050) |
FannyCalle | 0:46f5737fe936 | 100 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 101 | |
FannyCalle | 0:46f5737fe936 | 102 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 103 | // conversor analogo/digital (ads1115) |
FannyCalle | 0:46f5737fe936 | 104 | //**************************************************** |
FannyCalle | 0:46f5737fe936 | 105 | }; |
FannyCalle | 0:46f5737fe936 | 106 | #endif |