Battery-powered irrigation controller
-
Hi, this is still a work in progress but I wanted to share the approach I'm aiming to for a battery-powered irrigation controller in case can be useful to somebody else.
Since I have no way to power a device in my garden, I cannot use neither an electrovalve nor a traditional relay controlling a valve (would drain the battery while staying on).
I then found the following solenoid valves which works at a low voltage (3.6V) and requires just a pulse to switch (you may find the same also on amazon):
- http://www.ebay.com/itm/Plastic-Toilet-Closestool-20mm-Male-Thread-Bi-stable-Pulse-Solenoid-Valve-/162277805621?hash=item25c882ce35:g:DCcAAOSw3ihXTc9L
- http://www.ebay.com/itm/Toilet-Closestool-20mm-Male-Thread-Bi-stable-Pulse-Solenoid-Valve-DC-3-6-/332118670306?hash=item4d53d0bbe2:g:ll8AAOSwA3dYlHDN
The principle behind is to switch with positive/negative pulses which I've discovered means simply connecting the two wires to vcc and gnd to open and reverse the wires to close.
All good but when I tried to control this with two arduino pins, there was no way to have it working and the reason simply is the solenoid requires a LOT of current (I've measured between 0.6 and 1A) which is of course way more than what the board the provide.
After some googling I've discovered I needed a H-bridge (http://www.instructables.com/id/H-Bridge-on-a-Breadboard/?ALLSTEPS) to control programmatically the valve. I've tried building mine on a breadboard with different transistors/resistor but the valve didn't switch due to a massive voltage drop. Once gain due to the current draw.
I then bought the following and everything looks working just fine:
I still need to build the rest but this looks like the easy part since I just need to connect the arduino board to IN1 and IN2 and use simple HIGH pulse to open or close.
Thanks
-
can't you use a regular relay and a small solar panel to keep battery charged?
-
Using a solar panel can be for sure a good alternative but I wanted something without this requirement since where I have to put this I don't have a good exposure and I'm always afraid the battery cannot recharge in a good way.
Thanks!
-
Is the node going to sleep?
-
Absolutely, otherwise cannot survive for long I'm afraid. I'll put it to sleep for e.g. 5-10 minutes and with smart sleep I'll send the on/off command when online, at least this is the plan
-
@user2684
that's a cool project
I have built a device like this, batt operated custom board, but not finished sw and enclosure for the moment (too much projects). I'll use it in my garden soon as seedling has started too here.
I also have solar charging option on my board.
-
@user2684 can't you use like 4 relays to supply voltage with different polarity? 2 give pulse for opening and 2 give pulse to close. Maybe not as neat and tidy as the H Bridge but it may do the job without voltage drop.
-
@gohan you're right, a set of relays could definitely do the job, good alternative thanks for the advice!
-
@gohan - I'm struggling to determine why you would prefer to use 4 relays rather than a H-Bridge. If the device is a simple pulse activated device then i don't see any reason to use a relay over a H-Bridge. Is there a specific reason why you would and i'm not aware of that characteristic?
Or am I not following your project plans properly?
-
@Samuel235 it is in the first post where he is saying the H bridge didn't work
@user2684 said in Battery-powered irrigation controller:After some googling I've discovered I needed a H-bridge (http://www.instructables.com/id/H-Bridge-on-a-Breadboard/?ALLSTEPS) to control programmatically the valve. I've tried building mine on a breadboard with different transistors/resistor but the valve didn't switch due to a massive voltage drop. Once gain due to the current draw.
-
In my circuit, I'm not using h-bridge nor relays and i can also control higher voltage solenoid valves like rainbird.. (i'll post my project later),
but imho, I think the H-bridge should work, that depends on resistors values or the circuit was not optimized. 4 relays is a bit gorgeous maybe, but if it works, then it's the most important
-
@scalz sometimes you've got to use what is available and 4 relays usually are laying around somewhere
-
Well I brushed over that because i don't see how a H-Bridge wouldn't work due to high voltage drops. They use these ICs for motors and are fine with that and hence why I kind of brushed over that first point.
I was thinking more in terms of a new product being made for people, relays wouldn't be the best option for a few reasons, one being cost. However, if its just a few products for yourself then its fine obviously
-
Just to share how the finished project looks like in the picture below. I'm powering it with 3 AA batteries (4.5v) since the solenoid valve would not trigger when below 3v. In the picture you can see on the right side the pro mini and the RFM69 radio, on the left the H-bridge module in red and a mini board with a voltage regulator to provide 3.3v to the arduino and the radio and a 1M/300K voltage divider to feed an arduino's analog pin. I have two valves connected to the H-bridge so I'm using 4 pins to control them (pulse on/pulse off for valve 1, pulse on/pulse off for valve 2). On the code side, with NodeManager (https://www.mysensors.org/download/node-manager) I have the following configuration:
nodeManager.setBatteryMin(3.2); nodeManager.setBatteryMax(4.6); nodeManager.setBatteryInternalVcc(false); nodeManager.setBatteryPin(A1); nodeManager.setBatteryVoltsPerBit(0.00459433); nodeManager.setSleep(SLEEP,1,MINUTES); // open valve 1 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,6); // close valve 1 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,7); // open valve 2 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,8); // close valve 2 nodeManager.registerSensor(SENSOR_LATCHING_RELAY,9);
The board sleeps for one minute, then reports back (with smart sleep of course) and the controller sends a SET message with payload 1 to the relevant child id to control the valves when instructed. On this side with myHouse (https://www.mysensors.org/controller/myhouse) I can activate it manually or schedule the duration of the irrigation for each zone.
Here's the pictures (as you can clearly see I'm really bad with hardware so I tend to wire everything up without soldering so I can reuse all the components if needed or, more likely, if the project fails :P):
-
Don't worry about the wire mess, it is normal when building a prototype (breadboards and jumper wires exist for a reason )
So the node every minute checks if any commands have been sent to switch on or off the valves, right? How much battery life are you getting? I guess it will depends on how much time the valves are on. In theory you could swap the AA batteries with a 18650 to save some space, right?
-
@gohan that's correct, I'm using exactly the same principle in my boiler controller with the sensor checking in periodically for new commands since battery powered. I do expect a decent battery life since the valves I'm using are pulse-based so it doesn't matter for how long they stay on (as in my boiler controller I'm using a latching relay and since January moved from 3v to 2.75 now.). And yes, 18650 would be ideal for this project. Only concern with that battery is that when the solenoid triggers, it draws a lot of current and I'm not 100% sure a rechargeable battery is as good as a standard one to handle it.
-
as rule of thumb 18650 can deliver continuous 2C, so they could take a higher load for a brief moment (depends how long those valves take to open or close)
-
@gohan thanks good to know, I will give it a try, a 3 AA pack is actually using too much space!
-
Remember that lithium batteries suffer heat, so put the box in shade
-
Oh didn't know that, I'll stay with the 3 AA batteries then for now since the box is in full sunshine and can become pretty hot during summer time at this latitude Thanks
-
That's an interesting project!
how are these valve working after almost a month of work?some bi-state valves have reputation of get stuck opened or closed. They are cheap enough to i like them if the don't get stuckAnd what about time to control the valvs. Are you requesting from gateway?
For power you can use a 4v or 5 v solar panel to charge 1 li-io cell with this charge regulators((https://cdn.instructables.com/FSH/L5F0/IO0G95Y5/FSHL5F0IO0G95Y5.MEDIUM.jpg?width=614)) if regular batteries have poor life, and of course you can hide battery box under a flat rock or a tile because sun heat.There are common 9v valves that are bi-state as well ,like the ones used on rain bird 9v programmers
my irrigation controller (24v Ac controlled by 5v Dc) its about to be presented here as well soon i'm finishing tests on attached sensors and stability tests and upload on emoncms.com
-
And about selenoids ,this is how i control them:
on arduino pwm pins you can define how much voltage you send to solenoid with "analogwrite" .
You can use any mosfet or transistor that can handle the 3.5v 1a(buy double or triple value of curente for safe)
-
@Tmaster actually I came real here just a few days ago so difficult to say right now. I did notice though a couple of situations in which the command was not executed (which is really annoying since having irrigation going for hours would create a lake :P) but I'm not sure if it is because of the valve or some missing messages from the radio (since quite away from the gw). I was also evaluating a bunch of "close" commands sent periodically by the controller to be sure the valve does not stay open forever but it is not very clean.
Yes, the open/close logic is in the controller which is sending out a turn on/off message during the scheduled timeframes (https://sourceforge.net/p/my-house/forum/general/thread/2d98b751/).
Thanks for the advise regarding the batteries. I'm noticing when the valve toggle a huuuge impact on the battery. After a few tests changed from 4.5v to 3.8v. If confirmed, I will be obliged to move to a rechargeable solution.
Do you have a link of those 9v valves you are using? Just to have a good backup solution in case my approach would somehow fail
Regarding the solenoid, I'm using the following to control it from the arduino: https://www.aliexpress.com/item/2-DC-motor-drive-module-reversing-PWM-speed-dual-H-bridge-stepper-motor-Mini-victory-L298N/32648692160.html and seems to work just fine.
Thanks
-
i think that AA batteries hardly approach the 1A discharge if its your selenoid rate.
Another thing you can change is NEVER trust on a incoming signal to shutdown you valve. if power fails or signal is missing ,you selenoid will be open all life because gw never send the signal in time .what i did is: call time from GW , store it on irrigation node ,and then after time out(2 hours) it shuts off alone .in fact i don't have any code to control valves from gw . Gw only receive status for domotics. all time for valves On and Off its on the node.
See the timeaware sensor example to know how get time from gw and how handle it
you can just use for ex:
if(hour()==09) { //if its 9 hour AM TURN ON
digitalwrite (valve, HIGH)
}
if(hour()==10) { //if its 10 hour AM TURN OFF
digitalwrite (valve,LOW)
}Or on shutdown implement a "time out"timer (if millis have been passed turn off) like on "blink without delay" example
-
@Tmaster that's a very good advice, especially if keeping it open for too long could create any damage. But I'd rather keep the logic on the controller otherwise I'd need to flash a new sketch on a weekly basis. The timeout approach would probably be more close to my requirements, even if millis() doesn't work for sleeping nodes, I can still work with the time as you suggested.
Another issue I'm experimenting with this valve is the loss of pressure, which is of course expected but it is so strong I cannot cover my garden correctly So an alternative I was evaluating is to hack my legacy irrigation controller which is very basic but I need to find a way to handle the rotary encoder. But on the same time I don't want to move away so soon from those valves
-
the only desvantagem you have is ; not having main power there .Because if you have it you coud use standart 24v AC irrigation valves ,controlled by 5vDC as i did and then if power fails it just goes off, because they need current(+-200mha) for work. And they are cheap. the bi state 9v version cost more than 30€ and i never use it
-
Timeout is a nice safe feature, but also could be that if you loose connection to controller for more than X minutes it should shut everything down.
-
@Tmaster that's my issue, I don't have power there so I was trying to find out a way to have this working with batteries. But regardless of the issues I'm experiencing, the idea to add an additional safe guard is definitely great, thanks again for the advice!
-
Just to share this pointer from a similar project: http://rayshobby.blogspot.it/2010/06/minty-water-valve-controller.html. It is actually way beyond my knowledge to understand all the steps but I guess could be useful for somebody here.
Changing valve and stepping up to 24v seems too complex for my requirements but adding a big capacitor could be something worth trying also here.
-
Yet another quick update on this. I think I was able to mitigate somehow the few issues I had:
- Regarding the abnormal battery consumption, I placed two 330uF capacitor between gnd and Vcc of the H-bridge powering the valve and they seem to help. After a few on and off the battery went from 4.70V to 4.68V so it was not affected at all. Not sure if it is a good idea or not but I thought could help the valve to be more gentle against the battery. I've also added a sleep of two seconds just after the digitalOutput pulse so to allow the board not to suffer of the voltage drop before sending the ack back to the controller (it was sometimes lost before).
- Regarding the pressure lost at the valve, I was able to gain this pressure somewhere else. First of all I bought new, high quality irrigation sprinklers and they cover with exactly the same pressure almost 50% more ground than the old one. Then I removed a few junctions which were losing additional pressure. Now at least it is usable since I have full coverage of the garden (about 100 square meters) with a single sprinkler.
- Regarding the safeguard, I've added a very simple timer to my sketch. When a valve is turned on, the time starts (it just counts the number of cycles to make it simple). If too many cycles have passed by and the valve is still on, turns it off automatically.
Bottom line, I was about to give up with this but now I'm back on track
-
@user2684 said in Battery-powered irrigation controller:
Regarding the abnormal battery consumption, I placed two 330uF capacitor between gnd and Vcc of the H-bridge powering the valve and they seem to help. After a few on and off the battery went from 4.70V to 4.68V so it was not affected at all. Not sure if it is a good idea or not but I thought could help the valve to be more gentle against the battery. I've also added a sleep of two seconds just after the digitalOutput pulse so to allow the board not to suffer of the voltage drop before sending the ack back to the controller (it was sometimes lost before).
AA bateries can't handle much current. You are feeding an solenoid (coil) that probably requires 1A for switch state and it drains too much from aa battery. Buy a 12v /7a battery from chinese brand for 10€ and use a voltage regulator from ebay and you have you problems gone.
-
@Tmaster thanks, I'll give it a try as well! regarding the voltage regulator, is there anything able to provide >1A as output as far as you know? Thanks
-
Hi all, I just wan't to share with You my idea about controlling bi-stable solenoids (let it be valves or latching relay, doesn't matter). And I wonder why nowbody considering this solution. I'm talking about this kind of circuit http://www.avrfreaks.net/sites/default/files/Latching relay driver.jpg. And those two transistors that have to be controlled with two pins may be replaced with a push-pull driver like L293 (or L203DD which has built-in clamping diodes) which can be cotrolled with just one pin (HIGH - open; LOW - closed). This L293 will make the hardware interface the same as with monostable relays.
So pros are:- simple circuit (relay, capacitor, L293 IC and additional capacitor for power supply filtering)
- simple interface (use it like normal relay)
- safe - bi-stable solenoids have maximum pulse with, with this circuit there is no possibility to cross that requirement (the pulse width is defined by the RC constant of the capacitor and solenoid)
Cons are:
- the capacitor between relay and the ground has to be quite large about 1-2mF so its size is significant
- the l293 ic maybe not very cheap
-
Hi, just to spend a final word on this project. Despite the battery consumption is not that great (even if I believe by better sizing the capacitor the result would be much better), three AA battery lasted for more than two months powering the valve on and off twice a day and checking in with the controller every minute. I've changed the battery recently just because the valve operates at 3.6v and I was unsure there was enough power to still perform in a good shape for long. Below the battery discharging trend:
-
@user2684 How is your project going now? I am trying to use the same valves and diver board but I can not seem to get it to work. Could you answer some questions for me in order to help me get it to work.
Am i right in saying that if I connect the power leads of the valve to a + source (Li 18650 4.1v 2500ma) it should open the valve and the if I reverse the the leads it should close the valve?
-
@ionu very sorry for missing your reply for more than 6 months but I didn't get any notification 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.
My project has evolved over the time, let me share a picture below:
- 1: is the amazing EasyPCB from @sundberg84 RFM69 version
- 2: since the valve works at 3.7v I'm powering the project with 3 AA batteries. I've noticed the valve works just fine with 4.5v when full, till down to around 3v
- 3: this is a step down regulator for providing 3.3v to the arduino and the radio. I've soldered it there on the EasyPCB (where a booster is supposed to be soldered) since I needed to use the voltage divider which is not available when using the voltage regulator spot. For this reason the battery is connected to the "<=3.3" plug
- 4: this is the voltage divider for measuring the battery, since we have 4.5v I've coupled the 1M with a 300k
- 5: this is the bi-stable valve. Can be found on amazon for 5 euros. Ships from china of course
- 6: this is a 2200uF capacitor placed between the + and the - of the H bridge controlling the valve. Without it, the huge current drain would destroy the battery shortly
- 7: this is an analog rain sensor. It is powered on by an arduino pin so to save battery while sleeping
- 8: this is an analog soil moisture. It is powered on by an arduino pin so to save battery while sleeping
- 9: this is a button to manually turn the valve on or off. It is connected to the arduino pin 3
- 10: this is the H-bridge capable of controlling the valve since rated at 2A
The code I'm using, based on NodeManager, is the following:
/********************************** * MySensors node configuration */ // General settings #define SKETCH_NAME "Irrigation" #define SKETCH_VERSION "2.0" #define MY_NODE_ID 6 // RFM69 radio settings #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_NEW_DRIVER // Advanced settings #define MY_BAUD_RATE 9600 #define MY_SMART_SLEEP_WAIT_DURATION_MS 1000 #define MY_SPLASH_SCREEN_DISABLED /*********************************** * NodeManager modules for supported sensors */ #define USE_BATTERY #define USE_SIGNAL #define USE_CONFIGURATION #define USE_ANALOG_INPUT #define USE_DIGITAL_OUTPUT #define USE_INTERRUPT /*********************************** * NodeManager built-in features */ // Enable/disable NodeManager's features #define FEATURE_DEBUG ON #define FEATURE_POWER_MANAGER ON #define FEATURE_INTERRUPTS ON #define FEATURE_CONDITIONAL_REPORT OFF #define FEATURE_EEPROM OFF #define FEATURE_SLEEP ON #define FEATURE_RECEIVE ON #define FEATURE_TIME OFF #define FEATURE_RTC OFF #define FEATURE_SD OFF #define FEATURE_HOOKING ON /*********************************** * Load NodeManager Library */ #include "NodeManagerLibrary.h" NodeManager node; /*********************************** * Add your sensors below */ // built-in sensors SensorBattery battery(node); SensorConfiguration configuration(node); SensorSignal signal(node); PowerManager power(-1,A1,300); // Attached sensors SensorRain rain(node,A4); SensorSoilMoisture soil(node,A5); SensorInterrupt button(node,3); SensorLatchingRelay2Pins valve(node,5,6); /*********************************** * Main Sketch */ void toggleValve(Sensor* sensor) { valve.toggleStatus(); } // before void before() { // setup the serial port baud rate Serial.begin(MY_BAUD_RATE); /* * Configure your sensors below */ // 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); // valve valve.setSafeguard(60); valve.setWaitAfterSet(2000); valve.setLegacyMode(true); // button button.setInterruptHook(&toggleValve); button.setInitialValue(HIGH); button.setInterruptMode(FALLING); button.setInvertValueToReport(true); node.setInterruptDebounce(1000); // rain sensor rain.setPowerManager(power); rain.setReportIntervalMinutes(10); rain.setRangeMin(300); rain.setReverse(true); // soil moisture sensor soil.setPowerManager(power); soil.setReportIntervalMinutes(10); soil.setRangeMin(500); // node configuration node.setSleepSeconds(60); /* * Configure your sensors above */ node.before(); } // presentation void presentation() { // call NodeManager presentation routine node.presentation(); } // setup void setup() { // call NodeManager setup routine node.setup(); } // loop void loop() { // call NodeManager loop routine node.loop(); } #if FEATURE_RECEIVE == ON // receive void receive(const MyMessage &message) { // call NodeManager receive routine node.receive(message); } #endif #if FEATURE_TIME == ON // receiveTime void receiveTime(unsigned long ts) { // call NodeManager receiveTime routine node.receiveTime(ts); } #endif
Rain and soil moisture are connected to A4 and A5, reports every 10 minutes and are powered on just before taking the measure through pin A1. The button through the hooking function toggles the valve, when pressed. The valve (or better the H-bridge) is connected through pin 5 and 6 (off and on). The node wakes up every minute to pick up from the controller new orders (using smart sleep). There is also a safeguard of 60 minutes (if something goes wrong with the communication, irrigation is turned off regardless after 60 minutes).
-
@user2684 hi,
Thank you for sharing your project here!!! I've been looking quite a long time until I found itI have a question regarding safety problem. In case the battery drops after opening below the voltage needed to close it again the water would not stop. Do you have an idea how to solve this problem?
Or do you just replace the batteries "early" enough?
-
@Andreas-Menzel That is an old thread, but my thoughts would be to send battery level back often enough so you have time to change it, or better yet send battery level and add solar panel to recharge battery. A lot will depend on usage frequency, temperature, levels of sunlight etc...
You could also add a flow sensor or pressure switch to alert you if the water does not turn off.
-
@Andreas-Menzel I personally tend to replace the batteries early enough. I also have at the controller level a couple of safety checks with are ensuring 1) the "close" message is acknowledged by the sensor and if not resend it again 2) a humidity sensor in the ground checking if it is still irrigating after e.g. 2-3 hours the valve is supposed to be closed.
I've noticed if the battery is almost over and unable to close the valve once, it will likely succeed when retrying. Then of course batteries have to be changed.
Over the years I've refined this old project over and over mainly making the capacitor bigger since the valve would otherwise drain so much current to dramatically shorten the battery's life. But this is still border line for the capability of a battery powered sensor I believe.
-
@user2684 I am also planning to build latching valve controller. But my valve is 2" to 4" and Its coil specifications are as follow:
V: 6-20Volt DC (optimal is above 9volt)
Capacitance Required: 4700uF
Coil inductance: 90mH
Pulse duration: 20 to 200mili seconds.Do you think h-bridge will work or do you have a better suggestion for this? My goal is also to run the controller on battery and place in farm so it must be waterproof.
-
-
@chamroeun-ou If you need to reverse polarity then a H bridge would be good - I would aim for 12V (maybe a lead acid battery with solar panel and small charge controler). This assumes a coil pules reversal to change over the relay, if it is dual coil relay then it will be different, but we don't have that info. Also note the coil resistance and therefore current needed. A 6681FNG H bridge would be good as it is rated up to 15V and handles 1A with ease...
-
@chamroeun-ou said in Battery-powered irrigation controller:
@user2684 I am also planning to build latching valve controller. But my valve is 2" to 4" and Its coil specifications are as follow:
V: 6-20Volt DC (optimal is above 9volt)
Capacitance Required: 4700uF
Coil inductance: 90mH
Pulse duration: 20 to 200mili seconds.Do you think h-bridge will work or do you have a better suggestion for this? My goal is also to run the controller on battery and place in farm so it must be waterproof.
HI,
I'm doing quite the same project at the moment; I ordered H bridge and also some flow detectors to check if the bistable valve is really in the desired position ( open not to see a desert, closed not to flood everything)
Powered by 1 solar panel + 9v batteries + load controler + step down converters for Arduino and radio.
-
@user2684 I've just been tinkering on a project like this, so happy to find this and learn from you. Wondering if you've made any significant changes to your circuit and code that you could share so we can learn from your updated experience. How long at you getting from 3AA batteries typically? Love the project.
-
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
-
Hi,
I have already done all the same plus a flow control to check whether the valve is open or not and... it works perfectly.
++
-
Thanks for sharing the code, it would be nice to have a video demo.
Suggested Topics
-
Welcome
Announcements • 23 Mar 2014, 08:24 • hek 2 Apr 2014, 14:39 -
A low cost energy meter
My Project • 25 Jan 2024, 01:03 • OldSurferDude 12 Aug 2024, 06:03 -
Water Meter or "How to get Home Assistant to send saved data to an Arduino"
My Project • 18 Oct 2024, 02:19 • OldSurferDude 18 Oct 2024, 02:19 -
Powering ESP8266 / NRF24L01 repeater through USB (improvement)
My Project • 12 Oct 2022, 21:21 • Kokosnoot 21 May 2023, 20:32 -
Auxiliary Loads and Mains Charger Controller for my Smart Mobile Home
My Project • 6 Jan 2024, 13:32 • fsgraz 6 Jan 2024, 13:32 -
nRF24Doctor
My Project • 27 Mar 2018, 18:46 • Technovation 25 Aug 2023, 10:53