@@ -92,6 +92,7 @@ typedef enum {
|
|||||||
S_INFO, // LCD text device / Simple information device on controller, V_TEXT
|
S_INFO, // LCD text device / Simple information device on controller, V_TEXT
|
||||||
S_GAS, // Gas meter, V_FLOW, V_VOLUME
|
S_GAS, // Gas meter, V_FLOW, V_VOLUME
|
||||||
S_GPS, // GPS Sensor, V_POSITION
|
S_GPS, // GPS Sensor, V_POSITION
|
||||||
|
S_WATER_QUALITY,// V_TEMP, V_PH, V_ORP, V_EC, V_STATUS
|
||||||
} mysensor_sensor;
|
} mysensor_sensor;
|
||||||
|
|
||||||
/// @brief Type of sensor data (for set/req/ack messages)
|
/// @brief Type of sensor data (for set/req/ack messages)
|
||||||
@@ -153,7 +154,10 @@ typedef enum {
|
|||||||
V_TEXT, // S_INFO. Text message to display on LCD or controller device
|
V_TEXT, // S_INFO. Text message to display on LCD or controller device
|
||||||
V_CUSTOM, // Custom messages used for controller/inter node specific commands, preferably using S_CUSTOM device type.
|
V_CUSTOM, // Custom messages used for controller/inter node specific commands, preferably using S_CUSTOM device type.
|
||||||
V_POSITION, // GPS position and altitude. Payload: latitude;longitude;altitude(m). E.g. "55.722526;13.017972;18"
|
V_POSITION, // GPS position and altitude. Payload: latitude;longitude;altitude(m). E.g. "55.722526;13.017972;18"
|
||||||
V_IR_RECORD // Record IR codes S_IR for playback
|
V_IR_RECORD, // Record IR codes S_IR for playback
|
||||||
|
V_PH, // S_WATER_QUALITY, water PH
|
||||||
|
V_ORP, // S_WATER_QUALITY, water ORP : redox potential in mV
|
||||||
|
V_EC,// S_WATER_QUALITY, water electric conductivity μS/cm (microSiemens/cm)
|
||||||
} mysensor_data;
|
} mysensor_data;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
The MySensors Arduino library handles the wireless radio link and protocol
|
||||||
|
between your home built sensors/actuators and HA controller of choice.
|
||||||
|
The sensors forms a self healing radio network with optional repeaters. Each
|
||||||
|
repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||||
|
network topology allowing messages to be routed to nodes.
|
||||||
|
|
||||||
|
Created by mboyer85
|
||||||
|
Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||||
|
|
||||||
|
Documentation: http://www.mysensors.org
|
||||||
|
Support Forum: http://forum.mysensors.org
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
version 2 as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
|
||||||
|
Example sketch showing how to send PH readings back to the controller
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Enable debug prints to serial monitor
|
||||||
|
//#define MY_DEBUG
|
||||||
|
|
||||||
|
// Enable and select radio type attached
|
||||||
|
#define MY_RADIO_NRF24
|
||||||
|
//#define MY_RADIO_RFM69
|
||||||
|
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <MySensor.h>
|
||||||
|
|
||||||
|
#define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
|
||||||
|
|
||||||
|
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
|
||||||
|
float lastPH;
|
||||||
|
boolean receivedConfig = false;
|
||||||
|
boolean metric = true;
|
||||||
|
// Initialize PH message
|
||||||
|
MyMessage msg(0, V_PH);
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
//Setup your PH sensor here (I2C,Serial,Phidget...)
|
||||||
|
}
|
||||||
|
|
||||||
|
float getPH() {
|
||||||
|
//query your PH sensor here (I2C,Serial,Phidget...)
|
||||||
|
float dummy = 7;
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void presentation() {
|
||||||
|
// Send the sketch version information to the gateway and Controller
|
||||||
|
sendSketchInfo("PH Sensor", "1.1");
|
||||||
|
present(0, S_WATER_QUALITY);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
float ph = getPH();
|
||||||
|
|
||||||
|
#if COMPARE_PH == 1
|
||||||
|
if (lastPH != ph) {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Send in the new PH value
|
||||||
|
send(msg.set(ph, 1));
|
||||||
|
// Save new PH value for next compare
|
||||||
|
lastPH = ph;
|
||||||
|
|
||||||
|
#if COMPARE_PH == 1
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
sleep(SLEEP_TIME);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user