-
Notifications
You must be signed in to change notification settings - Fork 1
/
fluorometer_code_1.0.txt
59 lines (45 loc) · 1.44 KB
/
fluorometer_code_1.0.txt
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
#include <Wire.h>
#include "MS5837.h"
MS5837 sensor;
const int photoDiode_PIN = 14;
void setup() {
Serial.begin(9600);
Serial.println("Starting");
Wire.begin();
// Initialize pressure sensor
// Returns true if initialization was successful
// We can't continue with the rest of the program unless we can initialize the sensor
while (!sensor.init()) {
Serial.println("Init failed!");
Serial.println("Are SDA/SCL connected correctly?");
Serial.println("Blue Robotics Bar30: White=SDA, Green=SCL");
Serial.println("\n\n\n");
delay(5000);
}
sensor.setModel(MS5837::MS5837_30BA);
sensor.setFluidDensity(997); // kg/m^3 (freshwater, 1029 for seawater)
}
void loop() {
// put your main code here, to run repeatedly:
float pd_value = analogRead(photoDiode_PIN);
float pd_voltage = pd_value/1024*3.3;
Serial.print("PD: ");
Serial.print(pd_voltage);
Serial.println(" V");
delay(1000);
// Update pressure and temperature readings
sensor.read();
Serial.print("Pressure: ");
Serial.print(sensor.pressure());
Serial.println(" mbar");
Serial.print("Temperature: ");
Serial.print(sensor.temperature());
Serial.println(" deg C");
Serial.print("Depth: ");
Serial.print(sensor.depth());
Serial.println(" m");
Serial.print("Altitude: ");
Serial.print(sensor.altitude());
Serial.println(" m above mean sea level");
delay(1000);
}