Hello, I'm Sarah Sharp. Come on. Hello, I'm Sarah Sharp. I'm a Linux kernel hacker as my day job. And I want to say upfront that I've never designed a GUI before, unless you count really bad ones in shell. I'm also a gardener. And some people might say, how can you be a hacker and also be a gardener? Isn't gardening like all these tedious, repetitious tasks over and over and over again? Hackers will agree that repetitious tasks are good if they're a mind clearing exercise, or you learn something from them, or the produce is somehow better of the repetitious tasks versus the actual automated tasks. Like maybe your tomatoes taste a whole lot better. So for me, gardening really is a chance to learn. I get to learn about plants and chemical reactions and photosynthesis and climate change, although if you've been in Queensland, you've probably had enough climate change in the last month. So for me, if I go on vacation to give a talk at a conference in France in summer, and my lettuce starts flowering, I don't get sad because I can't eat my lettuce. I say, holy crap, that's how lettuce reproduces. Isn't that freaking cool?  If I could find a way to actually automatically get rid of weeds, I would, although maybe that's a talk for next year. So instead, I'll talk about some tools that I have some projects I've been working on this year. One of the projects is an open source calendaring tool to help gardeners plan their plantings and transplantings and basically when to start their seedlings. The other project I've been working on is a small Android application called ColdSnap, and it actually will automatically let you know when there's going to be a cold spell or a frost in your area. The other project I'm going to talk about is the Garduino, which is an Arduino-based board to automatically water your plants based on soil moisture sensors. So the first problem that a lot of gardeners face is the scheduling problem. And contrary to popular belief, gardening doesn't begin in the spring when things start to get warm. It actually begins early in winter when you start to receive these nice glossy seed catalogs. And you start looking through the pages and saying, wouldn't it be cool if I could grow some purple carrots this year? And don't those orange cauliflower look really neat?  And by that time, you've got about 30 different plants that you want to plant. So the traditional gardener would sit down with their paper calendar and they'd figure out their last frost date in places of the world that are not tropical. We actually do have frost and in Oregon the last frost date is around April. So your seed packets say things like, start your seeds indoors six to eight weeks before your last frost date. So you mark that on your calendar and then it says things like, transplant your seeds indoors once the true leaves show up. So the seedling will come out of the ground and it will have little baby leaves and then it will grow leaves that look a little bit more well-formed and that's when you're supposed to transplant it. So you mark that on your calendar and then perhaps you mark the date where you want to start taking the seeds outside, getting them used to the temperature and then bringing them inside at night. That usually happens about three days before you plant them outside. So you've got this all planned out and then you discover your sister's birthday is on the last frost date and she wants to go away for the weekend and suddenly all of your planning is completely bogus in the air and a normal person would sit down and print out another paper calendar. So I wrote a garden tool instead. So it's about 900 lines of seed. It's kind of an object-oriented representation of plants. And I ran it through Valgrind. It doesn't leak memory or anything, which is cool for being a user-space tool written in C. And as I said, I'm not a GUI designer. So the tool currently takes a comma-separated value file as its input. And there's like 11 magic fields and I wanted to make it sort of versatile. So I wanted you to be able to say I want to start my plants indoors or maybe instead you want to just buy your plants from a nursery and then separate them later or maybe you want to directly sow your carrot seeds into the ground and then thin them out later. So basically the tool will take all of those three different use cases in and allow you to put all three of them on tasks onto your calendar. So I started this little calendaring tool right after the last LCA and I got it to output some nice plain text about March 7th, which was about a week before, a week after, I was supposed to start planting seeds. So it was maybe a little bit late, but not too late. It worked pretty well. I was able to actually start my nice tomato plants inside under my bro lamp and actually have an idea when I should start them so that they'll be ready to be transplanted outside. I did find out that on the seed packets it will say, you know, these seeds have an 85% chance of germination and so I kind of made the tool to say how many seeds you need to plant in order to get one plant and it turns out the seed germination rates are completely bogus and you should just plant like five for every one that you want to actually get. It gets even worse if the seeds are smaller. The problem with this nice plain text output was that I stuck it on a wall and I forgot about it. There was really no integration with other calendaring tools and I really wanted to be able to look at my calendar and say, oh, I need to plant things rather than go out drinking or whatever. So I decided that I wanted to have it integrate with Google Calendar and so I wanted the tool to output instead of plain text, output iCalendar. Now the problem is the iCal specification RFC 2445. It's a giant specification. There's not very good examples and all of the tools out there, all of the calendaring tools kind of accept a little bit munged inputs depending on what you give them. One of my friends in Portland who works on Caligator which is the open source tool that handles the Portland technical calendar, his quote about iCal was that it's like an old cranky cat that pees behind your sofa. So it's not very fun to work with iCal but I did finally get Google Calendar to actually take my iCal input. I put my iCal file up on my server and I imported the URL and I could actually see my task that I needed to do and so now I could see instead of going out to dinner with Fred I should actually go and plant some seeds instead. The problem with actually having Google Calendar look at the URL and this was a bug that I had actually discovered about two or three years ago and it's still not fixed. Google only updates iCalendar files once a day. So if you want to sit there and tweak your schedule you have to wait a whole day for it to update. You can kind of work around this by adding a little PHP script that like changes the URL name just slightly adds random numbers to the end and stuff like that but the user has to re-re-import the calendar every time. So it wasn't very good. It worked sort of worked but it wasn't ideal. And what I actually found was that instead of having the calendar you know, inputting into my calendar was good for initially planning my garden year and figuring out, oh I'm going to be at a conference then I don't want to have my broccoli start being ready to harvest because then it will just flower before I get back from the conference. But throughout the year what would happen is I would go off and hack on something forget about my garden completely and come back and say oh it's Saturday I was supposed to plant stuff on Wednesday I really want to shift all those dates. So I really felt like it should be more of a to-do list and perhaps integrate with some cloud tool like Remember the Milk instead. So that's kind of my to-do for the garden calendar. I'd also like to make some sort of nicer web front-end so people don't have to figure out magic CSV files. So this brings us to late July and the sun is shining and my garden is wonderful it's actually summer in the northern hemisphere in July and I see the LCA call for papers and I go hey wouldn't it be cool if I could talk about my open source gardening stuff and I go but you know the calendar nap is not sexy. You know what can I add to this and I get them to accept my paper and so I said well what if I made an Android application and what if I did an Arduino thing wouldn't that be cool and so I said I have plenty of time I can do this you know I got a whole lot of the projects and it was starting to get cold and so I decided to actually do the Android project that was the cold snap because I was starting to think about cold. So the problem with cold is that frosts come in Oregon when the temperature you know zero degrees Celsius and the problem with frost is that when the water and the plant cells freeze it actually expands and it ruins the walls of the plant cells so your plant can actually lose all the moisture in its cells after the frost and then it will die from dehydration even though there's plenty of water coming in through its root systems. So gardeners deal with frost by raising the temperature so plants are actually in. So they'll cover the plants up with plastic or maybe they'll stick them in a greenhouse and so that raises the air temperature so the plants don't freeze even though everything around them is freezing. Now the problem is is that you need to know ahead of time when a frost is going to happen and I don't want to sit there and pull the weather website and figure out when the frost is going to come that's just not a good use of my time. Instead I'd like to have some device like say my phone tell me when there's actually going to be a frost coming. So as I said polling versus interrupts I'd rather have my phone interrupt me rather than me have to poll the weather websites. So I looked around for the Android app because I didn't want to you know redo the wheel. I said that I needed to, my hard requirements were I needed to have an alert for frost which it could alert for like colder temperatures that would be fine and the alert needed to happen that at a good time that was would fit my needs so most frosts happen at night. So I wanted to be notified in the early afternoon that I needed to cover my plants and I also kind of really wanted it to be an open source application because I wanted to be able to go hack on it if I needed to. So I found an application and it's called Weather Checker. Unfortunately it's not open source and I said that's fine. What the idea of Weather Checker is is that they are trying to provide a way for when you wake up in the morning and you're like what do I wear today. It will tell you is it going to be warm or cold warmer than average or colder than average and it worked pretty well except it didn't quite meet some of the requirements that I had. The first problem was that it alerted too often for me. I didn't need to know every single morning what the weather was going to be like. I just needed to know if the temperature was going to be below a certain threshold. So I got really tired of waking up in the morning and going why is my phone beeping at me again? And it also alerted at the wrong time. It alerted in the morning since frosts at night by the time I got the alert my plants would be dead. And I also had no idea how calculated average temperature. So if I'm having a slightly warmer spring warmer than average is it going to tell me every morning it's warmer than average and then not tell me when the temperature drops below into frost which is normal for that time of year. So I didn't know its internal guts of how it calculated average temperature. So I decided that I was going to do it myself. Which you know the therapy dragons. So I started looking around for a good source of weather data and I really like weather underground because it shows history, it has international data and someone actually told me that you can actually have your own weather station and upload it to weather underground and have that information there and I thought okay that's really cool. It's got a well documented API except that the API had this little clause to it. So the data is there, it's just not fully open and I wasn't happy with that. So I turned to some nice open government data instead. In my country we have a government agency called the National Oceanic Atmospheric Administration or NOAA for short. And it will actually tell you the weather predictions. It doesn't tell you history, it only works through the United States and you have to enter your US postal zip code in order to get the information. They have an interface that uses SOAP that returns XML to you. I actually found later they have a restful interface but I swear it wasn't there when I first looked at it. And so I did finally build my little Android app and I have a movie that I can show you later if you're interested in of it. But basically you enter your zip code and you can fiddle with the minimum cold temperature that you want to be notified for. And then you hit okay and it will transfer you to the next activity which actually shows you the prediction for the next three days. So you can see I've set the minimum cold temperature to 45 degrees Fahrenheit which is warmer than freezing but maybe you've got something like say a banana tree that actually needs to get covered and is a little more delicate than some of your other plans. So we can see 45 was when we wanted to be notified 48 degrees is fine and 41 and 40 and the Monday and Tuesday 41 temperatures are showing that it's cold. Right now it doesn't actually give an alert I would like to change that but this is about as far as I got. It's showing real data and it actually is useful a little bit. So I have a brief code overview but I'm just going to scan through it. Basically the code is all up on GitHub if you search for GardenGeek so you can look around and maybe use the slide to figure out exactly what's going on. As I said I still have some to-dos. I want to add a background task. I'd also like it to notify for things like hail because if you have plants outside and they're little thin seedlings if the hail comes there it's going to completely break them in half. So I want to be notified for hail too and luckily NOAA will just give me that data and so I would like to expand this to other countries besides the United States so if anyone knows of good fully open data then weather data then please tell me afterwards. So at this point I know that a lot of people were really excited about the Arduino project because every time I talked with someone about my talk they were like oh yeah you're talking about the Arduino stuff so the Arduino is the Gardino, Gardening plus Arduino and it's supposed to automatically water your plants based on soil moisture and there's a really good tutorial on Instructables.com on how to do this with your Android and that picture is actually from Instructables.com too. So how it works is that it has a really really cheap soil moisture sensor. I mean this is dirt cheap. It's plaster of Paris and two galvanized nails and some wires and what actually happens is the plaster of Paris will absorb the moisture oh by the way this is all done in Inkscape thank you Donna for your lovely tutorial so the plaster of Paris actually absorbs the moisture and the soil that's around it and it actually changes resistance a little bit. As it gets more moist since water is a good conductor of electricity it will actually lower the resistance and the voltage drop across the wires will increase so if it's completely dry theoretically you have no current flowing through the nails resistance is infinite and therefore there's no voltage drop across it. So if it's dry the voltage is going to be low if it's wet the voltage is going to be high across the two nails and so I can hear you say that's awesome but did you build it? I'm actually quite sad to say that as of the end of 2010 I did not actually build the Gardrino that brings me to New Year's Eve 2010 and Jamie's family, my husband they like to have this little white elephant gift exchange every year a little gift and if you can't tell what that is that's a little fountain that's supposed to sit on your desk and I kind of took it as a sign I'm like I gotta get this done and a little pump it's a 3 volt battery pack and I said I have a 5 volt Arduino I can totally power this off the Arduino it'll totally work so the night before I was going to leave for Australia I started ripping it apart and so the first step was that I had to be able to tell when there was a voltage drop when the soil was getting dry you want the voltage will drop down so I had to be able to measure that and so I decided that I would ignore the soil moisture completely ignore the pump completely and build a really simple circuit that actually uses a variable resistor called a potentiometer affectionately known as and so when the voltage across the potentiometer dropped below a specific threshold I was going to turn on the light it's basically like the hello world of electronics I sat there and I took my little potentiometer meter and I turned it and as you turn it the resistance actually changes and as you it's hard to tell but you can actually see the LED is off in that picture and it's on in that picture over there so I was like yes I can blink some LEDs this is awesome and so next step was to actually instead of turning on an LED turn on the digital output so eventually that output would pump when the when the voltage drops and the soil is dry so you can see that actually the Arduino says that it will nominally put out 5 volts it's actually putting out 4.92 volts so the second step was that the Arduino will output that 5 volts but the pump will take 3 volts and so I said I need to convert that 5 volts to 3 volts and so in my simplistic electronics 101 knowledge I said oh I'll just build a voltage divider and what a voltage divider does is it divides the voltage across 2 resistors and depending on the value of those resistors you may have more voltage here or more voltage here so I sat down and I measured the voltage the resistance of the pump and I went 8 ohms seems a little bit low I sat down with it and yes I hear you electronics geek smuddering in there shh it's a surprise so I whipped out my electronics calculation and I said oh yeah series of equations and ohms law and I can figure this out and it'll be I'll figure out the exact resistances that I need and it was a complete failure I actually sat down and I had my nice little voltage divider in there and I went oh well the the light's on I can see the light so I must be outputting voltage but the pump's not turning on and I measured the voltage across the pump and I went why is that voltage 1.6 rather than 3 and I went okay maybe I did the resistors wrong so I stuck some pots in there and started fiddling with things and then I turned on the pump and measured the voltage actually coming out of the Arduino volts it was 2.43 volts oh that's weird because when the pump's not there I can measure the 5 volts coming out and I went okay that's strange but it was 4 in the morning and I just plugged it in and the pump just took the 4.3 volts just fine and turned on and at that point I was like hell yeah pack this and I can take it to LCA and I can work on it before LCA and so I very carefully put all my electronics in a little box and I wrote a little note to the TSA these are not bomb parts please don't confiscate these and prayed that my check baggage would actually make it through so on the plane when I probably should have been sleeping I sat and I thought about that weird voltage drop I thought why am I getting 2.43 volts instead of 5 volts and I started looking at the data sheets the thing is that the Arduino only can output a specific current so it can only drive the pump with so much power and the pump was actually trying to draw more current and Ohm's law says that voltage equals current times resistance since the resistance of the pump was constant and it wanted a specific amount of current it was actually making the voltage from that output drop down to 4.3 so I was basically forcing the Arduino to do things that it really really didn't want to do in order to run my pump so I didn't really want to damage the Arduino so I thought back to my basic electronics course and I'm like I need some sort of switch I need some sort of switch to turn it on I want to electrically separate the Arduino from the input so a relay is basically a switch and you can see the plus and minus there when the voltage on the plus side is positive there's a certain value in this case 5 volts then the switch on the other side between those two terminals on the right hand side will actually flip and it will be like it's connected if the voltage on that plus terminal is zero then that switches flipped open and those terminals are not connected so basically when the Arduino applies that 5 volts to the relay then the battery will actually turn on and power the pump and so it's a nice electrically separate thing it's like turning on an awful light switch basically now this was two days so I landed in Australia and I said okay I've got to find this relay and a lot of the electronics folks know that if you walk into an electronics store it's not they're there to sell cell phones they're not there to sell analog electronics and so I tried Dick Smith's and I tried JV Hi-Fi and they all said what the heck really what are you talking about it gave me that look like go look at jacar entered into jacar and I was like Portland I found some wacky USB devices and all sorts of other things that I probably shouldn't have bought but I bought them anyway because it was cool and so I also went and found an art store because to make my soya moisture sensors is plaster of Paris plaster of Paris is this lovely fine grey powder the thing you want to bring over in an airplane with you so I found an art store that wasn't underwater got my plaster of Paris I already had brought my galvanized nails over which I don't know how those made it through and so the next step was actually build my soya moisture sensors so I sat down and I propped up the legs of my rickety table on the balcony of the backpackers that I was staying at you can see the styrofoam in the bottom of the legs and I started to build my soya moisture sensors and basically you take a little a little tube and you can kind of see that on the picture over there it's a little plastic tube and you just pour the plaster of Paris mixture in there and then you just kind of slide the nails into it and the nails are sitting in some wax paper and they just kind of rest on the little tube and then the plaster of Paris dries and you can actually use that as your soya moisture sensor and it's like you know five cents to make so I did have to calibrate the system you know when I sat there with my little potentiometer and I twiddled it I was actually reacting well the problem is that the soya moisture sensor takes a while to absorb the moisture and so it's going to take a while to react so if you're trying to turn on when the voltage drops below a specific threshold and then wait until that voltage rises again you're going to actually sit there and water your plant for five minutes while the moisture gets absorbed into the plaster of Paris so I wrote a little Arduino code that actually just sits there and says okay you know it's time to water the plant because the voltage has dropped and I measure that and then it will water it for five seconds it will return out of that function and then it won't water it again for a specified amount of time so it will only water every say 30 seconds even if the pot is really dry and you could expand upon this you could say like you know you have a light sensor on your Arduino board and you only want to water during the evening or the morning hour so maybe you want to calibrate it so that it only waters then so that's sort of an application that you could actually do with this now I did have to munch it a little bit because the Arduino doesn't have a real-time clock it doesn't have an idea of you know like oh it's 6 p.m. on Saturday it only has an idea that it's so many milliseconds since it started so I kind of worked around that a little bit and it was a really simple code it's only about 80 lines and it's got comments so it's not that bad step 8 light things on fire I mean play with heat shrink on my balcony I was concerned about the connections between the battery system and the pump system because the pump is going to sit in water and when I ripped the pump out of the little fountain the wires were pretty short they were about like this short and I wanted to run longer wires so I had a connection so I wanted to secure that connection and heat shrink you basically slide it over the two wires on a little tube and then you apply a little heat and it shrinks down to the connection so I sat there with my little barbecue lighter that I'd gotten from the store and made heat shrink it was my first time doing it and I kind of burned the wires on either side of the heat shrink so it's not very secure at all but it was fun anyway lighting things on fire and the day before LCAA I went out to two stores and got the various things that I needed no not the dress the plants and I actually have a demo for you guys so I have the Arduino hooked up this is the final system so you can see the Arduino over here it's actually connected via USB to my computer if you had it in your garden you could just have batteries or a wall ward or something like that it doesn't have to be hooked up over USB and that big black bit is actually the relay that I got from Jaycar there's a resistor in there and basically it's just a bunch of wires that's the battery pack over there it's currently off because I didn't want it watering the plant while I was giving the talk so this is mini-com output and you can see that there's voltage over here the top part is 100 1023 so that voltage measured is actually half of that value so the plant is a little dry and that's a countdown so it's going to only water every 30 seconds so that's a the battery pack is currently off so it's not going to water right now but that can for you guys the blob that you see with the red and green wires coming out is actually the soil moisture sensor in that pot and that's what it's measuring over there that 589 and then that big blue thing is it's hard to see but it's actually a watering pot and I've got my little pump in there and I'm going to actually water the plant so let's see we got four seconds to go let's turn it on zero my lovely demo I hope that it demonstrates that you too can hack together electronics in a week thank you Sarah we have a fair bit of time for questions so put your hand up I'll bring the mic up to you afterwards it's hidden behind the podium because I wanted it to be a surprise Sarah I just hope you don't wear any of that stuff around you as you get back on the plane because that looked exactly like a symtext bomb to me I'll put everything in a little box I won't take it on with the on the plane with me oh yes if anyone wants to take a plant home with them I can't take that home either oh okay I'll bring it tonight to the geek dinner so someone can have the plant this evening I had a question actually it was about the plaster of Paris sensors how do they work with all different types of soils do you have to calibrate them differently for different types of soils right so the question was about the plaster of Paris soil the sensors does it work for all types of soil and you do have to calibrate it a bit so the soil may be more clay or maybe a little bit more sandy and so you have to figure out what voltage makes sense for that particular soil what's the baseline but it will work for all types of soil can you do little ones for seedling trays and things like that or do you have to really have a big plant on a pot like that I would think for seedling trays probably you know that they're going to be watered once a day I could just set up a timer for that yeah slightly more comment than question I think this is great for our usually drought affected country because you can be so careful with the water I think it's just awesome thank you Sarah just having a look at this you seem to have the update rate on that particularly high is there any reason that you've got it updating that fast or you're just doing it as fast as the Arduino can handle so I'm updating and I think it's every 100 milliseconds or so it was really just for the demo you could update say once an hour if you wanted to you know even set a timer and make the whole system go to sleep this was just for the demo what does the future hold for the project what's next next I you know it's been so fun to come to LCA because I get to talk with so many people that are like oh have you done this or I've actually done some automation myself and so for the project I would actually like to incorporate a little bit more sensors into the system so I'd like to have a light sensor so that I can actually track the light in my backyard I'd like to have a soil temperature sensor on there so it can say oh the soils reached 50 degrees Fahrenheit it's time to plant your carrot seeds and so I'd actually like to make a little custom Arduino shield that actually has those sensors on it and sell it as a project but we'll see how that goes I'll talk with John about that. Do they have a PH sensor? Oh yeah maybe a PH sensor would be good too after the talk people can come up and have a little look I'll just so let's thank you Sarah for the talk today this is a small gift made out of macadamia recycled macadamia that you might see already. I'll probably plant something in it. Very good Thank you. Thank you!