Sanity check on the wiring for a latching valve and a soil moisture sensor with a Photon

Hi,

based on the feedback I got yesterday on my relay issue (thread here, I decided to change my original plan and to use a N-Channel MOSFET as a switch and an H-Bridge to drive my latching water valve.
Here is the diagram:


and here is what I want to accomplish:

  • The soil moisture sensor needs to be powered on for a short period of time (90ns) prior to me taking a reading, so my idea there is to turn D3 to HIGH to power it on and then do a analogRead(A0) to get the value from the sensor. The sensor needs a minimum of 3.5V hence why it is connected to the 5.5V rail.

  • Once I have read the sensor value and sent it to my server, it will tell me whether I need to open the vale or not. If I need to open it, I will set D0 to HIGH to enable the H-Bridge and then set D1 to HIGH and D2 to LOW to open the valve. If I need to close it, I will set D1 to LOW and D2 to HIGH. The pink and purple wires will be connected to the valve and it will be powered through its own 6V battery.

Is my wiring somewhat correct? I thought it would be good to put a diode in parallel with the valve, but I am not sure I have put it the right way.
Thoughts on how I could improve this project?

Thanks a lot in advance,
B.

Your moisture sensor has no Vcc supply.
If you draw a schematic (similar to the one below) you can see why. A Fritzing schematic isn’t always that clear - especially when you are not familiar with the inner workings of the used components.

Your diode will “short” your desired driving current in one of the two desired directions. Usually H-bridges should deal with the kick-back internally unless the reference design/typical application schematics in the datasheets suggests otherwise.
Looking at the datasheets to learn how to use a device correctly is a good habit.

This is what the TI datasheet says about internal clamping diodes
http://www.ti.com/lit/ds/symlink/sn754410.pdf

@ScruffR: I thought the sensor would get its Vcc current from the MOSFET or should the Vcc be connected to the 5.5V rail and the GND on the sensor to the MOSFET, like this?

Good to know about H-Bridge. I have removed the diode from the diagram. I was looking at the datasheet, but I am still struggling to read schematics , hence why the use of the Fritzing diagram. :smiley:

Yup, that looks better. I’d add a 470Ohm resistor between D3 and the transistor base.

But for the H-Bridge you also need to supply powert to Vcc2

I don’t have a 470Ohm resistor, so instead, could I use 2 x 220Ohms in series, that would give me a resistance of 440Ohm?

I have reviewed the H-Bridge connections based on your comment and I think they were wrong, so I have changed them. Is this better?

A single 220 should do just fine (470 is just my habitual value :blush:)

Yup, that looks good.

Awesome!!! Thank you sooooo much for the help. Really appreciated.