-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmartScale.ino
More file actions
71 lines (59 loc) · 1.3 KB
/
SmartScale.ino
File metadata and controls
71 lines (59 loc) · 1.3 KB
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
#include "GsmHandler.h"
#include "HX711.h"
#include "BMPProvider.h"
#include "Display.h"
//Display
// #define DEBUG
Display display;
//GSM
#define SIM_RX 10
#define SIM_TX 11
GsmHandler gsmHandler;
//Scale
#define calibration_factor 12140.0
#define DOUT A1
#define CLK A2
HX711 scale;
//BMP
#define ALTITUDE 91.0
BMPProvider bmpProvider;
void setup()
{
display.init();
gsmHandler.init();
scale.begin(DOUT, CLK);
scale.set_scale(calibration_factor);
scale.tare();
}
void loop()
{
gsmHandler.handle(onSmsReceived, onCallReceived);
}
void onCallReceived(String phone)
{
gsmHandler.hangOffCall();
notifyRecipient(phone);
}
void onSmsReceived(String phone, String message)
{
notifyRecipient(phone);
}
void notifyRecipient(String phone)
{
float weight = scale.get_units(100);
if (weight < 0.00) {
weight = 0.00;
}
bmpProvider.init();
double temperature = bmpProvider.getTemperature(100);
double pressure = bmpProvider.getPressure(temperature, 100);
double seaLevelPressure = bmpProvider.getSeaLevelPressure(pressure);
String message = "Weight: ";
message.concat(weight);
message.concat(" kg.\nTemperature: ");
message.concat(temperature);
message.concat(" C.\nPressure: ");
message.concat(seaLevelPressure);
display.println(message);
gsmHandler.sendSms(phone, message);
}