-
Batteries
04/09/2017 at 19:18 • 0 commentsSo, I measured the battery capacity. I figured that since I use all of them in series in my application the most interesting measurement would be to discharge them in series. First I charged them up in parallell to about 1,4V.
I screwed up the measurement, I discharged the batteries through 421,7 Ohms, but measured voltage over a 384 Ohm resistor, so voltage is a bit off.
Anyway, the batteries showed a not-so-impressive capacity of about 10mAh. I think its only one battery that is really bad. After the measurement I measured individual cells and all but one had 1,2 - 1,3 Volts. One battery had 1,0 V.
The graph below shows the discharge. Discharge current is about 20mA (depending on the voltage). When I reached 6V the accumulated capacity was 11,0mAh.
Still, if my system draws 0,1uA the batteries would last 100h minus the capacity used for opening and closing the valve. I only need 4-6 hours or so since night time in sweden is very short during the summer. I think I will stick them back in and see what happens. If I see resets in the logfile I can always change them later.
-
Schematics and source code
04/06/2017 at 19:30 • 0 commentsJust a short update to log that I have uploaded the source code for the PIC. The schematic just a handdrawn one that has been uploaded as a picture.
I had to add some functionality while I was tidying up the code. This summer I want to know which days the watering occurred. If everything works as I intend the log will be printed to the uart at dusk every day. Its probably not easy to capture it, I will have to attach a laptop to the system for a couple of hours at dusk in order to see it, but I think it will add some fun to the whole thing to be able to see what has been done. I log the maximum output from the solar panel, the time since the last watering and if today was a "watering day". I use the EEPROM as a rotating log on the pic, every entry is three bytes and I use 250 bytes, giving around 80 days worth of logging in total.
I also investigated the system and found that it was in full working order, but the batteries were flat. After I charged them everything seemed to run fine. I will do a capacity test on the batteries to see how much they have degraded.. I also measured current consumption again. I only measured the sleep current and it was 105uA this time. I think the last time I measured the current consumption I did something wrong...
Anyway, I have uploaded the source code and will write another entry when I have checked the battery capacity.
-
After-winter update
04/04/2017 at 20:17 • 0 commentsSo I pretty much finished this project up last spring and had it running during the summer. I had some trouble figuring out if the thing was working or not, when I checked it seemed as it was always wet outside (meaning it wouldnt open the watering valve) or I had forgotten the waterlevel since my last visit. It was always something that kept me from figuring out if it was working:-)
Anyways, here's what I ended up doing to finish the thing: After fiddling with the garden light and trying to figure out how to best connect everything I finally decided to just connect all 6 solars panel in series and connect them straight to all 6 batteries in series through a diode. I figured the solar panel would give such a small current that the batteries should not overcharge (I read somewhere that ni-mh batteries can handle a bit of over-charging if the current is low, they dissipate the extra power as heat in some way, thus protecting itself).
I also connected the positive of the solar panels through a voltage divider to an analog pin of the pic (so that I could mesure the voltage of the solar panels). Since i didnt want a current to flow at all times I connected the "ground" of the voltage divider to an input pin of the pic. When I measured the voltage of the solar panel I would reconfigure the pin as a low output, then measure the voltage through the voltage divider and when that was done I would configure the pin as an input again. This way the current only flowed when I did the measurement. I took the same approach to the moisture sensor, but this time I had the positive of the voltage divider connected to a gpio pin that was configured as a high output when I measured the moisture.
I had to fiddle a bit to get the ultra-low-power to work, but after some swearing and testing I managed to put the pic mcu to sleep. I had it wake up once every 20 seconds, increment a timer variable, write a dot to the uart to show that its alive and then go to sleep again. Looking at the code now I realise that I measure the voltage of the solar panels every time the pic wakes up. That might be a bit unnecessary, but a measurement is very fast, so I guess it doesnt matter that much.
Anyway, in the main loop the PIC checks if it has been more than 15 hours since the last watering. If it has been more than 15 hours and the sun panels read 0V (meaning its dark outside) it measures the moisture level. If the "moisture sensor" is dry it opens the valve for 5 minutes and then goes back to sleep.
When I measured the current consumption I noticed that the H-bridge had quite a high quiescent current. I solved this by sticking a MOSFET between the GND of the H-bridge chip and the "real" GND, so that I could "turn on" the H-bridge from the PIC mcu only when I was using it to run the motor in the valve.
When I was all done I measured the current consumption to 4uA in sleep and 400uA in full running (using the LFINTOSC at 32Khz). Thats not much. In fact, it seems too low, shouldnt just the voltage regulator quiescent current be higher than that? But thats what I have written in my notes. Hmm... I think I will have to measure that again, I might have screwed up the measurement somehow. I also measured the motorised ball valve current and when run at 5V it only consumed 50mA (that also seems low, it will be mesured again as well!).
Anyway, (maybe) I had the thing running all summer. Somehow the summer ended and the autumn came. I planned on bringing it inside all winter long and finally, last weekend, I came around to pick it up. It has been out all winter, maybe thats not so good. My next entry will be about how the thing is doing after the winter, I will do function tests and see what parts (if any) has failed and how I can improve on the design this summer.
I will also upload the schematic and the source code for the PIC microcontroller. I should have done that in this entry, but I dont have a schematic written down yet and the source code for the PIC looks like shit:-)
-
Housing
05/16/2016 at 20:20 • 0 commentsThe housing for the electronics will be an ugly thing. I will go for low cost and the whole thing will be built out of an upside down bucket and a single 45mmx45mm wooden plank that I have lying around. The really ugly sketch below is my first thoughts on the mechanical implementation: There will be the rain water barrel, a garden hose that connects to the ball valve, the solar garden lights fixed to a piece of wood with holes drilled to it and a place to attach the PCB with the electronics. I think the upside-down bucket thing will have the solar lights, the PCB and the ball valve all grouped together somehow.
I have been thinking about if this approach to weather-proofing the electronics is the way to go. I could have purchased or try to make a watertight container or just sticking it into a glob of resin, but in my experience moisture always find its way into everything. I think the solution with the upside-down bucket will cause the electronics to be in very humid conditions from time to time and there will probably even be condensing moisture. However, if I clean off any flux residues, make the board hang vertical so that moisture will drip off and have proper ventilation I might be able to avoid corrosion and misbehavior of the electronics. The circuitry for the ultra-low-power-wake-up will be sensitive to moisture, so maybe that will need extra protection. I am not at all sure it this is the way to go, but I will try it and see what happens. I wonder if morning dew will be a problem inside an upside-down bucket?
Anyway, I went ahead and started building the housing yesterday and it worked out kind of OK. The pink bucket adds a beautiful shine to the whole thing!
-
Electronics part 1
05/16/2016 at 20:14 • 0 commentsThe project is coming along nicely. I have decided to add a “water sensor” (two nails with fabric in between) to my project. I decided to do that because I plan to run the watering from a rain water barrel and if it has been raining I won’t water the plants and thus save some water. I will use the output from one solar panel as an analogue input for my microcontroller and use the information to know when dusk has arrived. Later I might add some sampling of the solar panel during the day and a temp sensor and use the information from them to adjust the watering time, but that will be a later project. To figure out how to wire everything up I “reversed engineered” the garden solar light. It was based on a chip marked YX8018, but more on that later. When I tried to figure out the circuit in the garden solar light I realized that just sticking the positive of the solar panel to an analogue pin wasn’t going to work. Damnit!
I did some testing with the “water sensor” and my multimeter yesterday. When I measured resistance I found that dry fabric showed up as open circuit on the multimeter on the 20k range. When I made it wet using water from my sink it had 6-7KOhms between the nails. A voltage divider with 15kOhms connected to V+ and an analogue pin will surely make me figure out if the water sensor is wet.
I got my electrically operated ball valve in the mail the other day and it looks good. I tried it at home using just a couple of batteries and it opened and closed fine with just three AAA alkaline cells (total of 4,5V) I found in a drawer. I haven’t decided if I will boost the voltage up to 12V (it is said to operated at 12V) or if I am going to operate it out-of-spec with just the raw solar cell battery voltage. I think I will go for the out-of-spec solution for now and throw in a 12V booster circuit if it doesnt work reliably. It one similar to this:
I also bought a L293E H-bridge to be able to operate the motor for the valve. I would have preferred a L293D since it has protection diodes (I don’t think 293E has them?) and no sense-inputs (which I don’t plan to use), but the L293E was available over the counter in my local parts shop, so it will have to do. I don’t have any diodes lying around at home, though. I wonder if I will damage something over time if I don’t use any protection. For now I think I will just stick a 1nF-ish capacitor across the power leads for the motor and hope for the best.
I was thinking about etching a PCB for everything, but I have decided to just use some perf-board. I really hate soldering wires to perf-board, but the build will consist of just a couple of IC’s and some passives, so I think an etched PCB will be a bit overkill.
-
First thoughts
05/10/2016 at 12:55 • 0 commentsI have been looking at cheap garden solar lights for power. These things are amazing value. For 3 swedish crowns you get a small solar cell, a 2/3AAA 60mAh battery, an led and a housing. A couple of those should be enough to open and close a valve once a day or so.
For a valve I have discarded all solenoid valves, partly because they use a lot of power and some of them seem to rely on water pressure and water free from particles. And to be honest I dont really understand exactly how they work and what to look for. I have found a motorized ball valve on eBay for approx 120 swedish crowns. I have decided to use this since I understand how it works and there is a big, nice hole for water and particles to go through. The downside is that I will need an H-bridge to open and close the valve and more components mean more money. Did I mention that I am a cheap bastard? :-)
For the brains of the project I will be using a pic microcontroller since they are cheap, can be in low power modes (drawing less current than I can measure) and I frequently use them in my hobby projects. The particulat controller that will be used for this project will be a pic16f886. The reason for this is that it is relatively cheap and I have experimented with low power modes on that mcu earlier and I'd like to reuse the code I wrote.