-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbme280_server.hpp
executable file
·116 lines (96 loc) · 3.5 KB
/
bme280_server.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
The MIT License (MIT)
Copyright (c) 2017 Wassim Filali
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
___________________________________________________________________________________
dependencies :
- the compensation code in set_all_measures_8(), compensate_XXXXXX, set_calib_XXXXX
is taken from the datasheet
https://cdn-shop.adafruit.com/datasheets/BST-BME280_DS001-10.pdf
all associated rights reserved
___________________________________________________________________________________
File : bme280_server.cpp
creation date : 2016.10.30
* Loads sensors calibration from file
* compensate measures of identifed sensors with their id
*/
#ifndef __BME_280_SERVER__
#define __BME_280_SERVER__
//for uint8_t
#include <cstdint>
#include <string>
#include "json.hpp"
using json = nlohmann::json;
class bme_measures_c
{
public:
bme_measures_c(){isReady = false;}
//----------------------- Measures -----------------------
public:
bool isReady;
void set_all_measures_8(uint8_t *data);
public:
int32_t adc_P;//Pressure
int32_t adc_T;//Temperature
int32_t adc_H;//Humidity
int32_t t_fine;
//----------------------- Calib Params -----------------------
public: //calib params
void set_calib_part1_10(uint8_t *data);
void set_calib_part2_10(uint8_t *data);
void set_calib_part3_6(uint8_t *data);
void set_calib_part4_8(uint8_t *data);
uint16_t dig_T1;//usigned short
int16_t dig_T2;//signed short
int16_t dig_T3;//signed short
uint16_t dig_P1;//usigned short
int16_t dig_P2;//signed short
int16_t dig_P3;//signed short
int16_t dig_P4;//signed short
int16_t dig_P5;//signed short
int16_t dig_P6;//signed short
int16_t dig_P7;//signed short
int16_t dig_P8;//signed short
int16_t dig_P9;//signed short
uint8_t dig_H1;//unsigned char
int16_t dig_H2;//signed short
uint8_t dig_H3;//unsigned char
int16_t dig_H4;//signed short
int16_t dig_H5;//signed short
int8_t dig_H6;//signed char
int32_t comp_T;
int32_t comp_P;
int32_t comp_H;
public:
int NodeId;
float temperature;
float humidity;
float pressure;
public:
void set_all_measures_Text(std::string Measures);
void load_calib_data(json &node_calib);
int32_t compensate_T_int32();//adc_T provided with m.set_all_measures_8()
int32_t compensate_P_int64();
int32_t compensate_H_int32();
float get_float_temperature();
float get_float_humidity();
float get_float_pressure();
std::string get_temperature();
std::string get_humidity();
std::string get_pressure();
};
#endif /*__BME_280_SERVER__*/