Skip to content

Commit 4a18797

Browse files
committed
Merge pull request arduino#374 from mboyer85/development
Adding Water Quality
2 parents 4c3d700 + 8fede4d commit 4a18797

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

libraries/MySensors/core/MyMessage.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ typedef enum {
9292
S_INFO, // LCD text device / Simple information device on controller, V_TEXT
9393
S_GAS, // Gas meter, V_FLOW, V_VOLUME
9494
S_GPS, // GPS Sensor, V_POSITION
95+
S_WATER_QUALITY,// V_TEMP, V_PH, V_ORP, V_EC, V_STATUS
9596
} mysensor_sensor;
9697

9798
/// @brief Type of sensor data (for set/req/ack messages)
@@ -153,7 +154,10 @@ typedef enum {
153154
V_TEXT, // S_INFO. Text message to display on LCD or controller device
154155
V_CUSTOM, // Custom messages used for controller/inter node specific commands, preferably using S_CUSTOM device type.
155156
V_POSITION, // GPS position and altitude. Payload: latitude;longitude;altitude(m). E.g. "55.722526;13.017972;18"
156-
V_IR_RECORD // Record IR codes S_IR for playback
157+
V_IR_RECORD, // Record IR codes S_IR for playback
158+
V_PH, // S_WATER_QUALITY, water PH
159+
V_ORP, // S_WATER_QUALITY, water ORP : redox potential in mV
160+
V_EC,// S_WATER_QUALITY, water electric conductivity μS/cm (microSiemens/cm)
157161
} mysensor_data;
158162

159163

@@ -336,4 +340,4 @@ uint8_t array[HEADER_SIZE + MAX_PAYLOAD + 1];
336340
#endif
337341

338342
#endif
339-
/** @}*/
343+
/** @}*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
The MySensors Arduino library handles the wireless radio link and protocol
3+
between your home built sensors/actuators and HA controller of choice.
4+
The sensors forms a self healing radio network with optional repeaters. Each
5+
repeater and gateway builds a routing tables in EEPROM which keeps track of the
6+
network topology allowing messages to be routed to nodes.
7+
8+
Created by mboyer85
9+
Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
10+
11+
Documentation: http://www.mysensors.org
12+
Support Forum: http://forum.mysensors.org
13+
14+
This program is free software; you can redistribute it and/or
15+
modify it under the terms of the GNU General Public License
16+
version 2 as published by the Free Software Foundation.
17+
18+
*******************************
19+
20+
DESCRIPTION
21+
22+
Example sketch showing how to send PH readings back to the controller
23+
*/
24+
25+
// Enable debug prints to serial monitor
26+
//#define MY_DEBUG
27+
28+
// Enable and select radio type attached
29+
#define MY_RADIO_NRF24
30+
//#define MY_RADIO_RFM69
31+
32+
#include <SPI.h>
33+
#include <MySensor.h>
34+
35+
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
36+
37+
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
38+
float lastPH;
39+
boolean receivedConfig = false;
40+
boolean metric = true;
41+
// Initialize PH message
42+
MyMessage msg(0, V_PH);
43+
44+
void setup()
45+
{
46+
//Setup your PH sensor here (I2C,Serial,Phidget...)
47+
}
48+
49+
float getPH() {
50+
//query your PH sensor here (I2C,Serial,Phidget...)
51+
float dummy = 7;
52+
return dummy;
53+
}
54+
55+
void presentation() {
56+
// Send the sketch version information to the gateway and Controller
57+
sendSketchInfo("PH Sensor", "1.1");
58+
present(0, S_WATER_QUALITY);
59+
60+
}
61+
62+
void loop()
63+
{
64+
float ph = getPH();
65+
66+
#if COMPARE_PH == 1
67+
if (lastPH != ph) {
68+
#endif
69+
70+
// Send in the new PH value
71+
send(msg.set(ph, 1));
72+
// Save new PH value for next compare
73+
lastPH = ph;
74+
75+
#if COMPARE_PH == 1
76+
}
77+
#endif
78+
sleep(SLEEP_TIME);
79+
}

0 commit comments

Comments
 (0)