Page 1 of 1

Designing automatic watering system

Posted: 19 Feb 2020, 21:32
by mrwee
Hi Guys,

I've begun designing an automatic watering system for our garden, based on ESPEasy (of course :D :D )

The overall design will include:
1 x Wemos D1 Mini Pro 2.0
2 x https://www.alibaba.com/product-detail/ ... 58258.html Water Flow sensors for measuring consumption
2 x https://www.aliexpress.com/item/4000208 ... web201603_ Solenoid Valves controlled by 2 x relays
2 x push buttons (to manually control each valve)
2 x https://www.aliexpress.com/i/32858273308.html Soil Moisture v1.2 sensors (Maybe just one, since ESP8266 only has one analog port)
2 x LED's (Valve status)
1 x MCP23017 for easy connection of components
I've started designing my own PCB in EasyEDA, to keep it as clean as possible. But I'm not an electronic expert, so I want to make sure that the design is correct.

So, a "couple" of questions:
1) Any restrictions to which GPIO's the two flow sensors are connected? From what I understand the MCP23017 cannot handle pulses.
2) For the flow sensors, do I need to do anything circuit-wise else than power it, and connect them to a ESP8266 GPIO?
3) Does ESPEasy support any way of adding an analog port for the second soil moisture sensor?

Re: Designing automatic watering system

Posted: 19 Feb 2020, 22:16
by ThomasB
1: Consult the pin mapping guide: https://www.letscontrolit.com/wiki/inde ... figuration

2: No experience with those flow sensors, but I noticed they are 5V logic output devices. The ESP8266 is 3.3V logic; Therefore you'll need to level convert to 3.3V. Sometimes a resistor divider can be used. However I would suggest a simple transistor inverter circuit to do it. Example:
Inverter / level translator
Inverter / level translator
inverter.jpg (45.56 KiB) Viewed 21012 times
(Enable the GPIO internal pull-up and omit the external 4.7K pull-up.)


3: ESPEasy supports the ADS1115 4-channel ADC module. https://www.letscontrolit.com/wiki/index.php/ADS1115
Or you could use i2c connected moisture sensors (note: i2c wire leads to the ESPEasy need to be short).

Extra credit answer: A mains powered solenoid valve is not a safe choice for your home garden application; So be sure to choose the 12V or 24V model. BTW, I highly recommend using a common 24VAC sprinkler valve. They are very low current and have silent operation. Available at your garden supply or hardware store. For example, something like this: https://www.amazon.com/Orbit-57280-Fema ... B01MG1VV2M

- Thomas

Re: Designing automatic watering system

Posted: 19 Feb 2020, 23:06
by mrwee
Thanks for your reply ThomasB,

1) I did consult the pin mapping guide, but I lack a clear explanation of which "applications" are suitable for each GPIO. But your suggestion to use ADS1115 is the way to go, so I've added that.
2) For the voltage converter, I've chosen a BC547, again based on your input. That looks like it can do the trick. Just so I understand it correctly. If I enable the internal pull-up, then I don't need the 4.7K resistor?

For the extra credit answer, I'm planning on using A 12V variant, but need to find a way of providing 12V ~2A and 5V ~2A within a box, placed in the garden (Will have 230V as source). The one you linked to, is also a possibility.

Thanks for your valuable input, I'm getting closer :)

Re: Designing automatic watering system

Posted: 20 Feb 2020, 16:54
by ThomasB
1) I did consult the pin mapping guide, but I lack a clear explanation of which "applications" are suitable for each GPIO.
Your flow sensor should use a GPIO that does not have any precautions listed on the mapping guide. That means GPIO D5, D6, or D7.
2) Just so I understand it correctly. If I enable the internal pull-up, then I don't need the 4.7K resistor?
Correct.

- Thomas

Re: Designing automatic watering system

Posted: 20 Feb 2020, 19:03
by mrwee
Thank you Thomas. I think I've got the circuit layed out as per your suggestions. Now I need to sleep on it, just in case new ideas come up :D

Re: Designing automatic watering system

Posted: 20 Feb 2020, 19:18
by mrwee
@ThomasB: You seem to have a good insight into designing the electronics. If I power some DS18B20's with 5V, I assume that I also need a level converter for the GPIO?

Re: Designing automatic watering system

Posted: 20 Feb 2020, 19:55
by ThomasB
If I power some DS18B20's with 5V, I assume that I also need a level converter for the GPIO?
Don't use 5V. The DS18B20 will tolerate voltages as low as 3.0V and requires less than 2mA current. So that means you can power it from the ESP8266's 3.3V supply.

- Thomas

Re: Designing automatic watering system

Posted: 20 Feb 2020, 21:09
by mrwee
Got it! Thanks :)

To be on the (future expansions) safe side, I'm considering powering the circuit with 12V (the solinoid valve runs on 12V), and having 5V and 3.3V step-downs, each capable of ~2A to supply e.g. D1 Mini pro, ADS1115, sensors/relays etc..
I've searched on Aliexpress for applicable ready-made step-down circuits, but can't decide if that's the way to go. Any suggestions?

Re: Designing automatic watering system

Posted: 20 Feb 2020, 21:13
by Jedrunia
There is no problem to power DS from 5V and connect data line directly to ESP GPIO port with pullup resistor to ESP power line (3.3V).

Re: Designing automatic watering system

Posted: 24 Feb 2020, 20:13
by mrwee
Google can sometime be a pain in the ...
I read that some make it work, some don't. So I'll keep to the 3.3V for DS18S20's.
Attached is my design for the automatic watering. Suggestions / comments are very welcome :D
I'm trying to prepare for expansion, hence the additional bus / connectors.
Schematic_water_Sheet_1_20200224200727.png
Schematic_water_Sheet_1_20200224200727.png (188.48 KiB) Viewed 20742 times

Re: Designing automatic watering system

Posted: 25 Feb 2020, 10:12
by Shardan
Hello mrwee,

some things missing or wrong.

The flow sensors (Hall sensors) give pulses, they should be connected to the ESP.
If i read the schematic right they are connected to the ADS1115 atm.
The transistor at the flow sensor is "wrong direction". The 10KOhm Resistor R3 should be connected to the plug's pin2.
R8 should be connected to 3V3. The connection R8/Q3 should be connected to GPIO, preferred GPIO12,13,14 (D5,D7,D6).
When configuring please remember: These pulse counters must be configured in ESPeasy's tasks 1...4!
I don't know the flow sensor you use. It might be necessary to add a 10KOhm resistor between pin1 and pin2 of the plug.
Better reserve a pad on the PCB for it, easier to leave off the resistor on the board then putting one in if needed
and no free space for it.

The ADS1115 should take the moisture sensor's output - I miss the moisture sensors in the schematic.

Some thoughts about your I²C connect.

I2C by design needs pull up resistors.
There might be pull up resistors on the ADS1115 board - or not.

If so they are connected to 5V - not good for the ESP8266!

The built-in pull ups inside the ESP8266 might be enough...
I wouldn't rely on that, reserve pads for pullups on the PCB
(See https://letscontrolit.com/wiki/index.ph ... he_I²C_Bus for more info on I²C)

The I²C in your design runs on 3.3V.
The MCP should take that - the ADS1115 has a minimum "High" level 0f 0,7VDD, 5V * 0,7 = 3.5V
That might work or not, or give unstable results.
I urgently suggest to use a level shifter. Needs neither witchcraft nor rocket science to integrate it on the PCB.
Two small FETs (2N7002 or if you don't want to handle SMD parts, 2N7000) and four resistors should do the job.
See https://letscontrolit.com/wiki/index.ph ... _Converter , section "Bi-directional level converter).
If using level conversion as described in the wiki, the pull up resistors for I²C are in the level shifter circuit,
no additional resistors needed.

A hint: Break out both sides (3.3V and 5V) of the I²C for further extension, might make extending more easy.

Another 2N7000/7002 circuit would be nice for the DS18B20. They work well on 3.3V near the ESP.
With a longer line between ESP and DS187B20 this runs into problems often. I've got some
really bad experiences with that.

Power Supply:
No and never use the 3.3V output of the WeMos or other boards for a lot of components!
The voltage regulators on these boards usually are not very powerfull, just good for
powering some smal sensors.
If you want to use 12V for supply, I'd suggest you use a "fat" 5V regulator (7805 with heat sink or even bigger)
to get 5V out of 12V. Then use a LM1117-3.3 or even better a LF-33 to reduce 5V to 3.3V.

I'd prefer to use 12V-relays in this case - takes load from the 5V-regulator and gives more
stability and less noise to the 5V- and 3.3V lines.

Another hint:
MCP23017 is well known for giving "spikes" on the power line, other parts do that too.
I'd suggest to place a small keramic capacitor of 100 nF as close as possible to the
VDD-pins of ADS1115 and the MCP23017. Other pin of capacitor to ground.

PCB Design:
I'm using KiCAD, so I don't know EasyEDA - if possible use copper areas for ground instead of tracks.
Ground is critical, small tracks might cause difficult to find problems.

Last but not least:
Prefer to do some breadboard testing before ordering PCB's.
I know, breadboards are somewhat unreliable etc, anyways it's cheaper to use a breadboard
then dumping a populated PCB due to errors.

Re: Designing automatic watering system

Posted: 25 Feb 2020, 19:52
by mrwee
Thanks Shardan for your extensive (and overwhelming) comments & observations. Very appreciated!

I'll implement your suggestions (plus add the Soil Moisture Sensors which I had forgot :oops:), hope you have the time to review it again.

Re: Designing automatic watering system

Posted: 08 Mar 2020, 23:26
by mrwee
Does anyone know of an easy solution to providing a 5V pulse from an ESP8266 either as + / - or - / + to a solenoid valve like this one? https://www.aliexpress.com/item/3281219 ... web201603_.
I'm assuming that sending a pulse draws less current that constant on.

Re: Designing automatic watering system

Posted: 09 Mar 2020, 03:29
by ThomasB
Does anyone know of an easy solution to providing a 5V pulse from an ESP8266 either as + / - or - / + to a solenoid valve
You can use an Arduino H-Bridge Motor controller. Two ESP8266 GPIO are needed to control it. One output pin for polarity direction (DIR), and another output pin for the signal pulse (ENB). Many choices out there, just search AliExp or eBay.
I'm assuming that sending a pulse draws less current that constant on
The specs suggest that this specialty valve is for low-flow applications. Such as water purifier or ice maker.

It's an interesting valve. But I recommend a purpose made valve for outdoor irrigation applications. They typically require 24VAC at about 300mA continuous.

- Thomas

Re: Designing automatic watering system

Posted: 14 Apr 2020, 20:26
by stefannetzer
Hi Thomas,

I am using:
A logic level converters to convert the 3.3 to 5 Volts to control my relais.
A PCF8574 board to get 8 ports for my relais. I have not found a 8 relais board with I2C communication.
Make sure, that you have a reasonable size transformator. You may easily kill it, if undersized. I have good experience with the Vemer Brand
I am using valves from Hunter which are rated with 24 Volts
I assembled everything in a DIN Rail Box with IP65 Protection
I used several hall sensors to control waterflow. Works as described in the ESPEasy documentation.
https://www.ebay.de/itm/1-60L-min-G1-In ... 2749.l2649


I hope that helps

Stefan

Re: Designing automatic watering system

Posted: 14 Apr 2020, 20:28
by stefannetzer
I guess Din Rail is nothing for you since you are located in the U.S.
By the way where are you from? I lived for 3 years in Hockessin DE

Re: Designing automatic watering system

Posted: 15 Apr 2020, 13:03
by mrwee
Just on update on the original projekt: I've reverted to using solenoid vales in one central place, and only have soil sensors de-centrally.