-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsensors.c
69 lines (60 loc) · 1.45 KB
/
sensors.c
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
#include <nrf_delay.h>
#include "ruuvi.h"
#include "bmp180.c"
#include "ap3216.c"
#include "mpu6050.c"
void init_sensors() {
bmp180_begin();
//alsStart();
////psStart();
alsPsStop();
InitMPU6050();
}
void handle_sensors(uint8_t *buffer) {
static int32_t raw_t = 0*100;
static uint32_t raw_p = 900 * 10000;
static uint32_t raw_h = 1 * 1000;
static int32_t acc[3] = {1, 2, 3};
static uint16_t vbat = 100;
ruuvi_sensor_t data;
//setColor(COLOR_GREEN);
double T;
char status = bmp180_startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
nrf_delay_ms(status);
status = bmp180_getTemperature(&T);
if (status != 0) {
#if BLE_SERIAL
bleSerial.println("temp:");
bleSerial.println(T);
#endif
raw_t = T * 100;
status = bmp180_startPressure(0);
if (status != 0)
{
double P;
// Wait for the measurement to complete:
nrf_delay_ms(status);
status = bmp180_getPressure(&P, &T);
if (status != 0)
{
raw_p = P * 25600;
}
}
}
}
#if 0
// Ambient light as humidity
uint16_t als = getALS();
raw_h = als * 100 / 65;
#endif
parseSensorData(&data, raw_t, raw_p, raw_h, vbat, acc);
encodeToUrlDataFromat((char *)buffer, &data);
//bluetooth_advertise_data(data_buffer, sizeof(data_buffer));
//eddystone_advertise_url(url_buffer, sizeof(url_buffer));
// eddystoneBeacon.setURI(url_buffer);
//delay(10);
//setColor(COLOR_OFF);
}