Files
MySensors/examples/PHSensor/PHSensor.ino
Mikael Falkvidd git@mjo.se 858b80b6a4 Use bool instead of boolean in examples
In the Arduino IDE, boolean is an alias for bool.
The Arduino IDE might deprecate boolean in the future, see
https://github.com/arduino/Arduino/issues/4673 for details.
2016-08-06 12:03:22 +02:00

80 lines
1.9 KiB
C++

/**
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 <MySensors.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;
bool receivedConfig = false;
bool 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);
}