Irrigation control using battery powered valve

I would like to create device which will be able to control irrigation based on soil moisture. I also want to measure soil moisture and check water flow. All these features in one device. I guess it is not problem to connect soil moisture sensor to One wire bus ( and some 1 wire device to read water flow - both connected to one bus. Then, probably by realy module (, control the water valve. At this moment I am using something like this: It work over the year using two AA batteries. But it is independentely controlled by digital timer. I analyzed one valve and there is “stupid” motor which works in one direction for valve opening and in another direction for valve closing. When I will be able to change direction of motor spinning it should work. But it is no so nice resolution. Does someone have better idea? Some solenoid or something like that? My goal is to use the valve without 230V - only using battery. AA batteries or some Li-on (solar powered) battery…

Thanks for sharing your ideas…

I’ve been playgin with the same idea. Our modules and soil sensor are battery operated and adding some solenoid valve would create interesting combo.

I came to bistable solenoid valves like this one

Combined with some rechargable batteries it could also charge itself during watering with similar generator.

It then depends on the use-case, but theoretically you can use some supercapacitor and when the voltage goes low, then it opens the valve for 10-20 seconds and recharges itself for another few days.

It looks interresting… Have you implemeted some of these devices with BC modules? Solenoid valve (probably) should be controlled by Relay module. But there is also needed some power for operating solenoid valve (4 AA batteries?). Hydro generator is for me next-level feature :thinking: At this moment I just want to know if water is flowing or not. This should be sufficient:
I am not sure if is needed to use Sensor module to connect these sensors (Soil moisture + water flow) or if it is needed something more?

Thanks for your help

Right now the Li-Po module is being developed, which could be used later for charging with a water turbine.

The Sensor Module would be ok for Soil Moisture and counting pulses. The newer one with 5 pin connector is preferrable, because it has new 5th pin with separate VCC for Soil Sensor (Vcc, Channel B for 1wire and GND). Then the A channel is free for count pulses from water flow sensor. But it can be used also with older one and connect the flow sensor to any GPIO.


OK, Is it possible to buy new type of sensor module? Photo of module (in e-shop) have only 4 pins. Using this module is possible to resolve soil moisture and water flow. SDK should be ready for these devices if I know correctly.

Then I need to resolve how to operate with solenoid valve. The one which you mentioned, can be operated by 4,5V, but BC battery module gives only 3V. I am not sure if it is enough to control the valve. (Have you tried it?) If not, I it is needed to use another batteries just for powering the valve. Then using relay module switch on or off the circuit. Do I understand correctly, that for opening and closing is needed to switch + a - wires? If yes, It can be operated by relay module and nothing more is needed.

Do you thing that I missed something?

Just write to the order note that you would like the latest 5 pin Sensor Module, we still have some stock of old ones.
Here’s the schematics of the 5 pin type.

It has also optional channel C by rewiring the 0R resistor. Otherwise the channel C is also the ground.

I don’t have that bistable solenoid. It would need some experimentation and bit of electrical skill to connect it to the Bigclown. I would definetely add more power, so the 6V battery module should be used. You can get 4.5V by tapping the positive voltage from the first 3 batteries.
You need to change the polarity to switch the valve. You would need some full H bridge module.

These are the options:

a) You can hack the Relay Module which has full H bridge to toggle the bistable relay. But you have to rewire also Vcc from 3V to 4.5V. The valve could then be soldered to the Relay Module relay’s coil pins. And I’m not sure that the high FETs will be fully opened because you are powering them with 4.5V but control signals would be 3V. This should be tested first.

b) Maybe you can combine a) and just connect the Relay Module I2C and GND to the Core Module with wires, and the VCC pin not ot 3V but to to the batteries or 4.5V tap. The TCA9534A chip can work up to 5.5V. Now the issue with controlling 4.5V with 3V signal from I2C expander goes away. You have votlage difference just on the I2C bus between modules which should work fine.

c) Other option is to use two Relay Modules, use one hacked to do the H bridge and the other to just momentarilly turn on the power. This way you could apply whatever voltage you wan’t.

How skilled are you and would you like to rewire and hack some Relay Modules? :slight_smile:

Great! First of all, thank you for your suggestions of solution.

option a) is for me more hazardous as I want. I am not so familiar with soldering of little things. When it will not work, I afraid, that I am not able to find where exactly is the problem.

option b) looks good… It probably should work, but whole module will look as arduino (lot of mess and cables)…

option c) unfortunately the most expensive choice, but for me it is clean and straightforward. When I have these two relay modules, I am also able to try option b)

Just for clarity - why is not possible to use two bistable relays (instead of hacked relay module) as it is shown on video which you shared? On that video they have two relays (as I am possible to have), two “buttons” (as I am possible to control relays using SDK), 12V power supply (I will have 4,5V).

If it is really needed to hack Relay module I am afraid, I am not able to do it using schematic image and soldering… I understand how it works theoretically (I hope)… You are able to help me with this soldering issue? When I will know what to exactly physically change, it is possible that next time I will be able to do by myself.

I’m thinking about connecting an external power supply just for controling solenoid valve or to take the power from BC battery module.

Thank you very much!

It is completely fine to use two separate bistable relays. I was not sure whether you would like use spearate relays and what your skills are.

With two relays, and they do not to be bistable, you can control the pulse length and polarity for the bistable valve.
So you can connect two relays to core module somehow (use some module with transistors, because Core Module does not give enough power on GPIO to power 3V relay directly), or you can use two relay modules. You have to change address of one module, this is done by resoldering the zero ohm resitor under the BIGCLOWN.COM label on the PCB to the empty position to the right. We can do that for you if you like.

It would also be possible to use Power Module’s relay and also the 5 V DC adapter to power the modules and also get the voltage for solenoid. But only if you do not need battery operated device.

I quickly did this very lame schematics in inkscape. I should find better tool next time :slight_smile:

It is great! Your schematic Inkscape picture is better than hundreds of words :slight_smile: :+1: Thank you! I will order everything, what is needed and I will be very happy if you can resolder that resistor.

I need to buy:
1 x core module
1 x sensor module (5pin)
1 x soil moisture sensor
2 x relay module (1 with modified resistor)
1 x battery module - here I am not sure if is enough to use mini battery module or not. In the battery module, there are 4 batteries but I think the batteries are connected in such a way that the output voltage is 3V. Or they are connected serial and output voltage is adjusted in the battery module? In this case I can use batteries to control the valve. But as I wrote, I haven’t problem with some external case with three batteries…

1 x water flow sensor (ebay…)
1 x bistable solenoid valve (ebay…)

I need to create:
1 x custom enclosure - it will be very funny, because I need to create something bigger for all these modules… I will deal with it this, after whole device will work. I have never designed anything for 3D printer, but I i think It will be OK.

I think that it is for this moment all. Sice this time, it is up to me. I will be happy If you can write me, how are batteries connected in the battery module - if I need to use (large) battery module or I can use mini battery module and if it is possible to take power directly from battery case (3 batteries = 4,5V).

Thank you!

Hi, the I2C address of the unmodified Relay Module is “default” and the modified board with 0R resistor it “alternate”

So in the bc_module_relay_init you pass 0x3b for unmodified Relay Module and 0x3f for “Hacked” one.


Great!! Thank you. I checked battery module scheme and It should be possible to use batteries for valve control. It is the reason why (I think) is better to use this battery module (not mini battery module).

I was trying to find more info on the valve. It could be bought in czech arduino-shop and they have a small note regarding the pressure.
You have to have the water under some pressure, the gravity itself would not help. Thanks to the water pressure it is possible to have the bi-stable operation of this valve.

Just wanted to point that out so you know this.

Funkční jen s potřebným tlakem tj. minimálně s čerpadlem
Na samospádovou vodu nelze použít, chybí tlak pro otevření, ventil jen prokapává.

Hi, I have received first of water flow sensors and I tried example to read some values from the sensor. Sensor is connected to channel A (left pin on the sensor module) and GND + VCC. I also simplified the example (attached) to just read the pulses, but without success.
I am not sure about voltage level (the sensor needs 5V -> ). When I tried to change “bc_pulse_counter_init(BC_MODULE_SENSOR_CHANNEL_A, BC_PULSE_COUNTER_EDGE_FALL);” to “RISE” or “RISE_FALL” the application looks like stucked.

Do you see something what can be wrong? Or do have any idea what to check or what to modify?

Thank you very much for any idea

application.c (1.9 KB)


if they say the hall sensor needs 5V, it’s better to believe them. Temporary solution could be using the Battery Module and get 4.5 V from the three batteries from series. Or 6V from all 4 batteries but add one or two diodes to lower voltage (0.7V voltage drop per diode, do not use shottky diodes, they have only 0.3V voltage drop across them).

I briefly looked in the code, seems ok. I don’t see the sending of the pairing packet in the application_init(). Are the MQTT messages from the button press working?

You can test pulse counter completely without the flow sensor. Can you measure the voltage between the A and the GND on the Sensor Module? There should be enabled pull-up so you should see arout 3V there. When you short these two pins you generate a pulse and you should see the counted pulses.

If you have the 5pin sensor then do not use the VCC pin on it, it is most probably disabled because the code does not know this newer Sensor Module.

Let me know and if you still have issues I try your code on my hardware.


thank you very much for your ideas. So the best starting point at this moment can be to start with measuring pulses without the flow sensor.

I have measured voltage between A and GND and there is 0V. When I short these pins whole application freezes. I have receive no more MQTT messages since that time.

I am also attaching more wiring situations which I have measured.

I don’t know why there is 0V between A pin and GND. Can (Should) I control the voltage?

I hope, the pictures help you to understand the situation.

I’ll test your code tomorrow.

Can you test this official pusle counter firmware?

Disconnect everthing from the connector and make a few pulses with a wire between A and GND.
Also make sure you are masuring inside the screw terminal. Do not use screws for measurement or test, when the screws are loose there might not be a electric contact.

The counter sends pulses every 5 minutes, so it may take a while until you receive data.


Thank you! I made a new test with original firmware.

I disconnected everything from the connector. There was 0V between A and GND. I have measured all values inside the connector (not on the screws). I also tried to made a pulse by shortening A and GND, but without success. Message value was still 0. Just for one time, it counted 12 pulses. I don’t know why. Because I made still same things. After that I was not able to reproduce it. :face_with_raised_eyebrow:

Should I unplug the relay modules? Probably it is only the thing which can be different.


did the Sensor Module worked previously? I uplaoded release firmware from Playground

Measured the voltage between:
GND and A - 3V
GND and B - 3V

Then I shorted GND - A few times - this code sends counted data every 5 minutes, see the MQTT messages in teh image below.

Also when I short B and GND, then this behaves like a button and it immediatelly sends the counter value for channel B.

Also button press generates the message

Can you check the hardware? Is it possible the hardware gets somehow damaged? The 3V you should see on the A input is generated by Core Module MCUs internal pull-up. If you use the same firmware then the input can be damaged. Can you use other Core Module?


1 Like

thanks a lot, It works!!! I don’t know why, but when I switched the core modules it started to work and when I placed it back it still worked with your example. At this moment I know, that there must be 3V betwen A and GND (B and GND). When there is 0 it can’t work. At this moment I have 3,2V between both pins.

I think it is up to me to make it work in my firmware. Thank you again for your ideas!

1 Like

Hello again :slight_smile:
I found interresting thing during counting pulses in official pulse counter firmware ( I have one core module, two relay modules (for switching 4,5V for water valve) and one new sensor module (5pin). When I am switching relays, then BC_MODULE_SENSOR_CHANNEL_A counts pulses. Why? Is it possible to do something for counting just pulses from sensor module?
Thanks for any ideas…