I've got a balcony, tomatoes and a micro controller
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Inspired by @Joey Pongallo, I started researching pre-made relay boards instead of creating my own MOSFET-based switches. It turns out that most of these boards are made for the Arduino eco system and thus require 5V levels to switch. Some people report that their relay boards work with 3.3V logic levels, but that typically requires a separate 5V supply for the relay coils. Even then, the logic levels may be too low to drive the switching transistor to saturation. This results in a very hot transistor.
During my research, I stumbled upon cheap Arduino clones. These boards provide 5V logic levels and the entire Arduino eco system is built around them, except for some oddball Arduinos running on 3.3V.
I've ordered an Arduino Nano V3 clone and a 4-relay module for 13€ total including shipping. This is a much better option than spending another several hours designing and soldering the MOSFET-based switch.
As a plus, the board can run on supply voltages up to 20V as it has a built-in voltage regulator. I could - theoretically - run the relay coils off that regulator. I will have to see about that once the board arrives and I can determine the particular type of regulator used. I would have preferred a 12V relay, but these are quite rare and also more expensive.
If the built-in regulator can't supply enough current (70mA per coil), I still have my LM2596 based converter.
For some reason, my valve never worked. I disassembled it and found it would only close, but not open anymore. I found a blown trace on the PCB which I repaired, but it's still short-circuited somewhere. I believe either the reverse-voltage protection diode or the relay coil are blown and now permanently conducting. Both are easy fixes, but still very annoying.
The CR-02 valve is actually nicely built and probably good value for your money. The PCB is sufficiently well made and the gear box looks solid. Of course, some gears are plastic although it's advertised as a brass gear box. I just wish they had added a proper fuse to the PCB instead of just letting some traces burn out.
Edit: I just did some further test and it is indeed the diode that's burnt out and now conducts in both directions. I know that diodes are used in this way to protect against wrong polarity. In this case, all current flows through the diode and back to the battery. The key ingredient here is a fuse which prevents further damage to the circuit. The manufacturer didn't include that fuse, so the PCB trace blew up. I'm reasonably sure I did not reverse the polarity, but you can never know afterwards. It's also possible that the diode is simply supposed to act as a suppressor diode for the motor.
Edit2: It's likely a suppressor diode for the relay coil.
Anyways, I have (badly) drawn up a schematic which will hopefully help other netizens.
The blue (CLOSE) wire is connected to the NC pin of the relay. This is kind of the default action for the valve. The red wire (OPEN) fires up the relay coil which changes the turn direction of the motor. There are two end switches (green wires and red wires) which disconnect GND once the respective end range of motion has been reached. These switches are conductive by default and turn off the motor when press.
For your amusement, here is the burnt out trace:
Spring is coming and the seeds are planted. I've made some changes to the project. Mainly, the MMM is now powered by a 12V lead-acid battery as that's the voltage required by the motorized ball valve. At 7.2Ah, the battery likely is large enough to last all of summer. I have yet to do the math on that. I choose the battery size mainly because it was cheap. Smaller batteries at 2Ah cost around 10€. There seems to be a sweet spot at 7Ah -- I got mine for 15€.
I can easily charge the battery from a battery panel since it's 12V. Amazon.de lists some very affordable solar panels, e.g. 10W at 25€. Cheap chinese charging controllers like the CMP12 start at 8€so this would be an inexpensive, fun experiment.
Unfortunately, these are cheaply made and I read somewhere that they don't even use PWM to adjust the charging voltage. For 15€, you can get better controllers like the CMTP01 or CMTP02 which -- on paper -- do the right thing. Even for those, you can find lots of complaints on your favorite search engine. The original plan was to get a solar charge controller and feed it from one of the random 19V PSUs I have lying around. Since none of the offering seemed good enough, I decided to buy a decidated lead battery charger, the AL-800. I suppose it's better to buy stuff that does one thing well instead of not doing two things at all.
To finally make some progress, I also ordered a DC-DC buck converter based on the LM2596. These can be had for 2€ from China or, in my case, from a German (re-)seller via Amazon for 5€. Along with some fuses, diodes, opto-couplers and transistors, I should be able to prototype the interface for the ball valve soon.
The valve requires a two-way switch to flip from "water go" to "water stop". Additionally, I would like to turn the valve off completely to prevent battery drain. Here's the schematic again:
I found a guide to use aTIP120 transistor to control a motor with an Arduino. Based on this guide, I added three transistors. The first transistor controls GND. This essentially dictactes whether the valve is powered at all. The second and third transistor make up the actual switch shown in the diagram above. Here's the current breadboard sketch:
Here, the valve is represented by two DC motors because I didn't have the correct part handy. What's missing is (likely) proper protection for the transistors. I'd also like to prevent both transistors from allowing current to pass at the same time. Perhaps I will drive both second and third transistor from a single pin with a logic inverter.
FWIW, I also added a proper Fritzing part for the ESP8266 which I found on GitHub.
My master's thesis is finished and now I can get back to work. Two parts arrived: the ESP8266 and a motorized ball valve. The valve requires 12V, so I'll see how that goes.
I just finished a preliminary mockup of the circuit in Fritzing. A couple of things are still missing. I'm likely going to add a couple of switches (mosfets?) to turn off the servo and ESP8266 when not in use. Of course, the moisture sensor is just some random I2C part I re-used. The MSP430G2 will also go into a DIP socket. No need for the Launchpad.
The ESP8266 is not represented correctly. I stole the idea and the wiring from http://robinsonia.com/wp/?p=378. The retro browser project seems to have an ESP8266 schematic. Maybe they're going to release that one day.
I'll also add some connectors so I can disconnect the moisture sensor and the battery pack. Also some LEDs and test pins so I can see/check if the components are powered.
...or keeping the magic smoke in.
The MSP430 runs at 1.8V-3.3V. The servo, on the other hand, requires 4.8-6V.
I plan on using a 4 cell AA battery pack. With Eneloop batteries, this will result in 4.8V input voltage. Optionally, it should work with five cells. Higher voltage will result in more torque for the servo.
Although the MSP430 can go as low as 1.8V, the DHT22 humidity sensor requires 3.3V-6V. I am not sure so sure about the Voltage for the Chirp moisture sensor. The chirp uses an ATTINY85 which comes in a high-voltage and a low-voltage version. In any case, given the DHT22 and the ESP8266, I will have to come up with a way to generate 3.3V for the logic. The servo will be powered directly from the battery pack.
Several voltage regulars are available. After all, I am not the first person to connect some chips to a battery pack. How do I select the appropriate regulator? Easy, just use the first thing that's available in the Fritzing library: a 7803. Looking at the 7803 datasheet, we can see that it will deliver 3.3V just fine. It also only requires two additional capacitors, which makes it very easy to integrate. Unfortunately, the minimum required input voltage Vin is 5.8V. 4 AA cells won't cut it here.
Another popular option is the LM317, which is an adjustable linear regulator. It also requires that Vin is 3V over Vout. Another possible problem of linear regulators is that can be very inefficient. Wikipedia says:
Linear regulators inherently draw as much current as they supply. When this current is multiplied by the voltage difference between input and output, a significant amount of power is wasted as heat.
The current drawn by the circuit is not very high. I assume that the ESP8266 is the biggest consumer, which, at peak times, draws up to ~300mA if my memory serves me right. So a 500mA regulator should be fine.
A last consideration is the minimum power draw. If the circuit does not draw enough power, the voltage regulator ceases to function properly. For the LM317, the "minimum load required to maintain regulation" is 3.5mA. If I configure the MSP430 properly and disable all peripherals, I should be able to go below that. At least I hope I'll be able to maintain low power consumption in standby. I'm still wondering what happens with the regulator if current draw goes below 3.5mA. Even at 3.5mA, the batteries would only last 24 days.
What we need is a Low Drop-Out (LDO) voltage regulator. LDO means that the regulator does not drop much voltage. Thus, Vout can be very close to Vin.
The LD1117A is a good alternative. Depending on the current draw, the voltage drop is only 1V to 1.2V. This will work fine for the 4.8V supplied by the battery pack, even if the battery is almost discharged. It also requires two capacitors at 10µF and 100nF. I can't find the minimum power draw in the data sheet, unfortunately. The power consumed by the regulator itself, the quiescent current, is 5mA. That's a lot - but I'm running out of power regulators in Fritzing ;)
For now, I will design the circuit around the LD1117A. I will add a diode to protect against polarity reversal and possibly a fuse.
TI has some helpful blog posts on voltage regulators for the MSP430:
I finally got the moisture sensor up and running.
The DHT22 makes this extremely easy once it compiles. Just install the lib into energia, copy the example into a new sketch (else it won't compile) and hit upload.
I am still looking for a nice valve and an usable servo. For the valve, I went to local DIY stores and was surprised that they're so expensive. I had finally settled on a small 1/2" valve with internal female threading. I still needed some hose fittings for that which where nowhere to be found. Great.
So it's back to eBay.. where I ended up buying an ESP8266 serial-to-wifi interface. Wait, what?
Read more »I'm going to need a valve to control water flow. I assume the plants will be watered once or at most twice a day if they're thirsty. I've looked around a bit and found quite some different valve implementations in the hobbyist community.
Here are my requirements:
The nice folks at 43oh had some good suggestions and I found some more on instructables. Let's get started:
Read more »
Create an account to leave a comment. Already have an account? Log In.
I have programmed everything on I2C. I2C is pretty much the only communication line I use, as SPI is only limited to 2 devices ( in my knowledge). I am still new here, only took one course on electronics. School brought more work than fun, so my lack of detailed professional knowledge is small.
I plan on using lcd touchscreen on the pi, so my SPI ports will most likely be used up. Same with most of the GPIO's.
I purchased a desktop DC power supply for about ~35 bucks and I use that to regulate all the power in my components. Since I have a lot of components, I power them all up to full power(all relays on) and adjust voltage till it can handle all the components.
Right now I run a GPIO extender (MCP3008 I think) for my soil moisture sensors. But I just picked up some new chips (forgot name) that are GPIO extenders that run on I2C. The moisture sensors I use are the common cheap ones that you most likely are using.
I have written my own library/class for controlling an 8 port relay board on I2C using the cheap PCF8754AP chip. This library can easily be extended for 16port relay boards. I am an OOP programmer, so the library is class/object based, making it ready to go after you initiate the object in code (Python).
If you are trying to drive the valve when the soil moisture is at a certain percent, there is a digital pin that triggers when it is reached on the sensor. Perhaps hooking this up to the valve somehow with mosfet is a solution, if not the one your already using.
I am going to look into that board your using. I just restriped my project and starting from scratch, as it took up my whole desk. I'll shoot pics next week for you.
PS. If you are using gravity controlled water, just place the valves beneath your bucket/resevouir. As the water goes down the main hose, it will stop when it reaches the solenoids. When you open a solenoid, water will flow through it. Just make sure you have everything leveled if your using splitters with multiple solenoids. This will come in handy when using many solenoids!
That's very impressive. I'm looking forward to seeing some pictures.
My desk is completely cluttered as well. It's a thing you just have to live with. I'm off to the gardening store to buy some more plants ;)
By the way, I use a i2c-based soil moisture sensor:
https://www.tindie.com/products/miceuz/chirp-plant-watering-alarm/
Great, now you got me researching ready-made relay boards. These are super cheap from China. The problem is that I only have 3.3V and 12V, so the majority of these won't work ;) I'll probably buy a 12V which takes 5V logic levels and try if it works.
They use 3.3v high/low logic for toggling the relays. But I believe to power the relay you need 12 volts. This is why I bought a DC desktop power supply. Buy one know if you don't have it, you will always need it in the future! Here is a link to the one I bought, which does the job:
http://www.ebay.com/itm/321214987873?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
You may want to just use solenoids instead of the motors for closing hoses.
http://www.ebay.com/itm/221663246081?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
hey, thanks for your input. The two motors just represent a single Three-wire valve. The solenoids often (depending on the type) require a minimum pressure to operate. My watering system is gravity-fed. I am currently working on a control circuit for that - maybe you have some ideas? I see you are currently studying EE. If you have time, let me know. Can't post the link.right now.
I built a gravity controlled water system for my hydroponic system. Was proud after I finished :). But it didn't require any electronics, as gravity took care of all the work.
Look into those solenoids I sent you the link to. I bought two and they fit perfect for aquarium hosing, which is what my water pump hosing is also. I took one water pump and put a 16way hose splitter with each splitter running through a solenoid. The solenoids are controlled by a relay. No pressure is needed to toggle the solenoids! I really think you should try it as it would remove some manual work and free up some components. Plus they are cheap.
I will try to take picture tonight of my setup. I have my father, a design engineer, working on prints for my system. Hopefully when I have it finished, I can send you a prototype for you to use in your setup. It hooks up to your PI through I2C. I think this is what you want, as it will control which plants receive water. Hook it up to moisture sensors, and have them water themselves!
Since you are using a water pump, you likely have some pressure beyond a simple 1m height difference?
I really like your suggestion as I did not such small solenoid valves. They're also quite cheap. You probably haven't seen it, but I have already bought a motorized ball valve for 26€. I only have one single valve and one single moisture sensor for all plants. I plan to regulate water flow to individual plants with a drip irrigation system where the flow can be regulated per dripper. So I won't need one valve per plant.
By the way, I don't have a raspberry PI. I use a TI launchpad with Energia for an Arduino-like environment.
I'm looking forward to a picture of your setup. Some questions:
* How do you control all 16 valves + sensors with a single Raspberry PI? Does your I2C-based solution provide the required 32 pins? How does that work?
* What type of moisture sensors are you using?
* How do you power the system?
My main problem right now (which I have almost figured out) is how to drive the valve. After reading up on MOSFETs, I think I've got it - almost ;)
Become a member to follow this project and never miss any updates
I have exactly this CMP12 regulator in my garden house solar system with 50Wp panel and 2 old car batteries. It does basically a hysteretic PWM. The solar panel has ~19V OC and something like 3,5A short circuit current. It connects the panel until the voltage gets too high.
The unit does it's job, but I had to repair it already once. I found a hand drawn schematic on the net, although from a slightly different version, perhaps before a transition to SMD components. The 40106 and 1-2 BC817 like BJTs were defective. There was not any bypass capacitor used for the chip, so I added one to protect it from spikes. It's now working since 1-2 years.