-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ino
82 lines (78 loc) · 1.78 KB
/
main.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
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
//Arduino Code
#include <TSYS01.h>
#include <Wire.h>
#include <floatToString.h>
#include <MS5837.h>
#ifdef USE_PULSE_OUT
#include "ph_iso_surveyor.h"
Surveyor_pH_Isolated pH = Surveyor_pH_Isolated(A0);
#else
#include "ph_surveyor.h"
Surveyor_pH pH = Surveyor_pH(A0);
#endif
MS5837 depthReader = MS5837();
TSYS01 tempReader = TSYS01();
void startReading()
{
if (depthReader.init())
{
depthReader.read();
}
if (tempReader.init())
{
tempReader.read();
}
String tempStringC;
if (tempReader.temperature() < -1000)
{
// Serial.println("No Got it");
tempStringC = String(depthReader.temperature(), 5);
}
else
{
// Serial.println("Got it");
tempStringC = String(tempReader.temperature(), 5);
}
String depthString = String(depthReader.depth(), 5);
String altString = String(depthReader.altitude(), 5);
String pressureString = String(depthReader.pressure(), 5);
Serial.println("Reading: " + depthString + "," + altString + "," + tempStringC + "," + pressureString + "," + pH.read_ph());
}
void startSensors()
{
depthReader.setModel(MS5837::MS5837_30BA);
depthReader.setFluidDensity(997);
if (depthReader.init() && tempReader.init())
{
Serial.println("All sensors are ready.");
}
else
{
Serial.println("failed.");
}
if (pH.begin()) {
Serial.println("Loaded EEPROM");
}
return 0;
}
void setup()
{
Serial.begin(9600);
Wire.begin();
startSensors();
// loop();
}
void loop()
{
String givenString = Serial.readStringUntil('.');
if (givenString == "start")
{
while (givenString != "stop")
{
givenString = Serial.readStringUntil('.');
delay(10);
startReading();
givenString = Serial.readStringUntil('.');
}
}
}