Hi @ciaocibai, no big changes to the code, maybe just MY_SMART_SLEEP_WAIT_DURATION_MS set to 1000 to ensure the valve is not impacting receiving/transmitting when triggering. All the rest is the same, just using the latest version of NodeManager. Ah, I also added a push button for turning irrigation on/off directly from the device.
Difficult to say regarding battery usage: since I've placed it far away I had to do some changes in the radio management piece which is draining battery considerably. With this setup 3 AA batteries last for around 2 months which is nothing but I believe this is mainly due to the radio settings.
Just for reference this is the latest version of the code:
/**********************************
* MySensors node configuration
*/
// General settings
#define SKETCH_NAME "Irrigation"
#define SKETCH_VERSION "3.2"
//#define MY_DEBUG
#define MY_NODE_ID 6
// RFM69 radio settings
#define MY_RADIO_RFM69
#define MY_IS_RFM69HW
#define MY_RFM69_NEW_DRIVER
#define MY_RFM69_ATC_MODE_DISABLED
#define MY_RFM69_TX_POWER_DBM (10)
#define MY_RFM69_MAX_POWER_LEVEL_DBM (10)
// Advanced settings
#define MY_BAUD_RATE 9600
#define MY_SMART_SLEEP_WAIT_DURATION_MS 1000
#define MY_SPLASH_SCREEN_DISABLED
#define MY_SIGNAL_REPORT_ENABLED
/***********************************
* NodeManager configuration
*/
#define NODEMANAGER_DEBUG ON
#define NODEMANAGER_INTERRUPTS ON
#define NODEMANAGER_SLEEP ON
#define NODEMANAGER_RECEIVE ON
#define NODEMANAGER_DEBUG_VERBOSE OFF
#define NODEMANAGER_POWER_MANAGER OFF
#define NODEMANAGER_CONDITIONAL_REPORT OFF
#define NODEMANAGER_EEPROM OFF
#define NODEMANAGER_TIME OFF
#define NODEMANAGER_RTC OFF
#define NODEMANAGER_SD OFF
#define NODEMANAGER_HOOKING ON
#define NODEMANAGER_OTA_CONFIGURATION OFF
#define NODEMANAGER_SERIAL_INPUT OFF
// import NodeManager library (a nodeManager object will be then made available)
#include <MySensors_NodeManager.h>
/***********************************
* Add your sensors
*/
//PowerManager power(5,6);
#include <sensors/SensorBattery.h>
SensorBattery battery;
#include <sensors/SensorSignal.h>
SensorSignal signal;
#include <sensors/SensorInterrupt.h>
SensorInterrupt button(3);
#include <sensors/SensorLatchingRelay2Pins.h>
SensorLatchingRelay2Pins valve(5,6);
/***********************************
* Main Sketch
*/
void toggleValve(Sensor* sensor) {
valve.toggleStatus();
}
// before
void before() {
/***********************************
* Configure your sensors
*/
// battery sensor
battery.setMinVoltage(3.2);
battery.setMaxVoltage(4.6);
battery.setBatteryInternalVcc(false);
battery.setBatteryPin(A0);
battery.setBatteryVoltsPerBit(0.00459433);
battery.setReportIntervalMinutes(30);
//signal sensor
signal.setReportIntervalMinutes(30);
// button
button.setInterruptHook(&toggleValve);
button.setInterruptMode(FALLING);
button.setInvertValueToReport(true);
nodeManager.setInterruptDebounce(1000);
// valve
valve.setSafeguard(120);
valve.setWaitAfterSet(2000);
valve.setLegacyMode(true);
valve.children.get(1)->setChildId(4);
// node configuration
nodeManager.setSleepBetweenSendSleepOrWait(true);
nodeManager.setSleepSeconds(60*5);
// call NodeManager before routine
nodeManager.before();
}
// presentation
void presentation() {
// call NodeManager presentation routine
nodeManager.presentation();
}
// setup
void setup() {
// call NodeManager setup routine
nodeManager.setup();
}
// loop
void loop() {
// call NodeManager loop routine
nodeManager.loop();
}
#if NODEMANAGER_RECEIVE == ON
// receive
void receive(const MyMessage &message) {
// call NodeManager receive routine
nodeManager.receive(message);
}
#endif
#if NODEMANAGER_TIME == ON
// receiveTime
void receiveTime(unsigned long ts) {
// call NodeManager receiveTime routine
nodeManager.receiveTime(ts);
}
#endif
Legacy myHouse issue was mainly around extensibility hence this distributed, plugin-based architecture allowing users to package functionalities and/or contents without me doing any change in the core code. And turning it in a cloud-based service (as an option) could be also really easy. But for now the hope is to build a little community around it so to make it evolve further. Just as a starting point
Nice project btw! Which compilation error are you receiving from Nodemanager? I also wonder if you can leverage Nodemanager's hooks capabilities to interact with it in a more clean way. Thanks!












Your understanding is correct, if you just connect the + and - of the battery to the valve you should hear a "click" and if you reverse the wire, another "click". I wonder if that battery would be powerful enough, I've noticed that valve drains really a lot of current (>1A) when triggering. Try with AA batteries at first, just to check if the valve is functioning.