-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvironmentMonitor.ino
48 lines (38 loc) · 1013 Bytes
/
EnvironmentMonitor.ino
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
/*
* This simple Arduino sketch reads from an Adafruit MS8607 and a RadiationWatch counter
* to give a periodic reading of pressure, temperature, and radiation level
*/
#include <Adafruit_Sensor.h>
#include <Adafruit_MS8607.h>
#include <RadiationWatch.h>
#define MS_DELTA 1000
RadiationWatch radiationWatch;
Adafruit_MS8607 ms8607;
unsigned long last_log = 0;
void setup()
{
Serial.begin(9600);
radiationWatch.setup();
if (!ms8607.begin())
{
Serial.println("Failed to find MS8607 chip");
while (1) { delay(10); }
}
}
void loop()
{
radiationWatch.loop();
// If it's been more than MS_DELTA since the last long, then log
if(millis() - last_log > MS_DELTA)
{
sensors_event_t temp, pressure, humidity;
ms8607.getEvent(&pressure, &temp, &humidity);
Serial.print(pressure.pressure);
Serial.print(",");
Serial.print(temp.temperature);
Serial.print(",");
Serial.print(radiationWatch.uSvh());
Serial.println();
last_log = millis();
}
}