-
Notifications
You must be signed in to change notification settings - Fork 2
/
ESP32_SpecificGravity.ino
54 lines (45 loc) · 1.48 KB
/
ESP32_SpecificGravity.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
// Calculates fermenting wort Specific Gravity from tilt angle of floating sensor,
// where tilt angle varies with wort density.
// Tilt Angle is calculated assuming device only has rotational (not linear) motion
// Specific Gravity is calculated from the tilt angle with reference to a nth order polynomial
// - for this implementation only a first order is used with 2 data points
// See README.md for more info.
//
// Connections:
// MPU6050 ESP32
// ADO GND
// SDA GPIO 21 (green)
// SCL GPIO 22 (yellow)
// GND GND (brown)
// VCC 3V3 (white)
//
// Check accelerometer works properly (can be faulty), by checking that
// gXYZ is close to 1g, and gX varies between to 0g (horizontal) to +/- 1g (vertical)
//
// The battery voltage to be measured needs to go thru a voltage divider comprising
// two equal high value resistors to keep voltage below 3V3 at the ADC pin.
//
// s60sc 2020
// s60sc 2018, 2023
#include "appGlobals.h"
static bool startedUp = false;
void setup() {
logSetup();
// prep storage & load saved user configuration
if (startStorage()) loadConfig();
#ifdef DEV_ONLY
devSetup();
#endif
// connect wifi or start config AP if router details not available
startWifi();
startWebServer();
if (strlen(startupFailure)) LOG_WRN("%s", startupFailure);
else {
// start rest of services
if (SGsetup()) startedUp = true;
checkMemory();
}
}
void loop() {
if (startedUp) SGloop();
}