RailsConf 2014

Saving the World (Literally) with Ruby on Rails

Saving the World (Literally) with Ruby on Rails

by Sean Marcia

The video titled "Saving the World (Literally) with Ruby on Rails" features Sean Marcia discussing an innovative project aimed at monitoring honeybee hives to address the alarming decline in bee populations. As a software developer at George Mason University and a co-organizer of the Arlington Ruby meetup group, Sean shares his enthusiasm for technology and its potential impact on environmental issues. Throughout the talk, he details:

  • Introduction to Bees and Their Importance: Sean explains the crucial role bees play in pollination and food production, highlighting that 60-70% of our food relies on bees for pollination. He shares alarming statistics about honeybee hive losses, notably in Virginia, where two-thirds of the wild bee populations have vanished due to Colony Collapse Disorder.

  • Project Motivation and Development: Inspired by a talk on bees, Sean collaborates with a researcher, Hermann, who operates beehives on campus. They decide to build a monitoring system to track hive conditions, focusing on temperature, humidity, and hive weight to gather insights into bee health.

  • Technical Implementation: The project utilizes Raspberry Pi devices powered by solar panels to ensure they can operate off-grid with a minimal budget. Sean discusses the technical set up including:

    • Using sensors to collect data on hive conditions.
    • Employing Ruby and Sinatra along with the Dashing gem to create a simple dashboard for real-time data reporting.
    • The significance of using social media to engage the community and raise awareness about the plight of bees, leading to increased interest and funding.
  • Community Engagement and Results: Through strategic use of social media and crowdfunding campaigns, the project gained traction, culminating in raised funds exceeding their initial goals. The initiative captured public interest, resulting in collaborations with educational organizations and increased visibility for the importance of bee conservation efforts.

  • Call to Action: Sean emphasizes the importance of developers getting involved in socially beneficial projects. He encourages attendees to leverage their technical skills to contribute to open source initiatives, particularly those aimed at solving real-world problems.

Sean concludes with an invitation to participate in an upcoming conference, "Ruby for Good", aimed at fostering an environment for developers to contribute to projects that benefit society. He underscores that with the right attitude and resources, anyone can make an impactful difference in the world, particularly in supporting the crucial role bees play in our ecosystem.

00:00:16.640 Hi, my name is Sean Marcia. I'm going to be talking about saving the world with Ruby on Rails. You can find me on Twitter at @seanmarcia. Just for your reference, I'm an early adopter, which is how I was able to secure my own name. I thought that was funny. I work at George Mason University as a software developer, and I'd like to thank them for giving me this opportunity to be here and do this kind of cool stuff. I also want to thank my Ruby group for allowing me to practice this talk on them last week.
00:00:50.719 Today, I'm going to talk about the history of the project, the technology we used, and hopefully how you all can get involved. But really, I'm just going to tell you a story about bees. My personal story with bees began when I was about six years old, and for reference, that's me at six—kind of like an orange on a toothpick. When I was six, my good friend and I were wandering around and found a wild beehive. If you know six-year-old boys, you can probably guess what we did next: we started throwing rocks at it. My friend took off running, and I didn't know why. It wasn’t fun to throw rocks at the beehive by myself, and it turns out he got stung 20 to 30 times! I didn't get stung, so I feel like I owe the bees for leaving me alone.
00:01:43.759 Let's jump forward to today. I said I'm a software developer at George Mason University. One day, while wandering across campus, I saw a guy giving a talk. His name is Hermann Korea, and he was discussing Amazonian stingerless bees and the honey they collect. As a developer, I’m always in it for the swag—he was giving out honey samples, which is why I went. While listening to his talk, I learned fascinating facts about bees. For instance, there are 4,000 different varieties of bees in North America, and they are responsible for pollinating 90% of wild plants. One bee, in its lifetime, gathers just 1/12 of a teaspoon of honey but visits about 50,000 flowers to do so. About 60 to 70% of our food is due to the pollination of bees, as they pollinate the food that our food eats.
00:03:05.360 The unfortunate truth is that bees are dying and disappearing, and we don’t know why. This has become big news, with articles in publications like Time Magazine discussing a world without bees. Hermann is researching something called Colony Collapse Disorder (CCD). For those unfamiliar with it, CCD is the phenomenon where bee colonies suddenly collapse and disappear without any clear reason. This is serious news—about 35% of managed beehives, where a beekeeper is overseeing them, have died recently. For wild bees, the situation is much worse; in some areas of the country, 90% of wild bees are just gone. In Virginia, where I'm from, it's about two-thirds.
00:03:36.159 And it’s not just a local problem; it’s happening in Europe too. Predictions indicate that by 2018, all bees in England could be gone, and the situation in Asia, particularly India, is especially scary. In India, 90% of pollination and honey comes from a wild bee that cannot be domesticated. These wild bees are critically important, and with their decline, India faces devastating consequences.
00:05:00.640 Various theories attempt to explain the causes of Colony Collapse Disorder: pesticides, two types of mites that bees struggle to cleanse themselves of, diseases, genetic factors, or a combination of these issues. I have my theory as well, but unfortunately, it hasn't gained traction in the beekeeping community. After hearing all this from Hermann, I thought, 'What can I do to help?' While Hermann doesn’t have technical skills, he mentioned that he has some beehives up on top of a parking garage at George Mason—a five-story tall area where you can get a view of nearby buildings. Hermann expressed the need for insight into these hives, like tracking the hive temperature, as bees maintain a constant temperature year-round regardless of the season.
00:07:50.400 In recent years, researchers found that the holes in beehive combs aren't just empty; there’s a special drone bee that breaks its wings and crawls into those holes to vibrate all day long, generating heat. Hermann also wanted to monitor the hive’s weight to see how it changed over time and measure outside humidity and temperature as controls, since weather issues could affect the bees’ activities.
00:08:34.560 Looking at the overall situation, we faced several challenges: the hives were exposed to the elements, we had no power source, and our budget was extremely limited. This meant we needed something easy to repair and maintain because many involved aren't very technical. The first issue we tackled was power—this was the low-hanging fruit. We implemented solar panels and a deep-cycle battery to create an off-grid power solution. Our setup proved effective, powering the system for about seven to nine days without sunlight, so as long as we had sun at least once a week, we were in business.
00:10:14.720 Next was the budget, which was less than $200. We used Raspberry Pi devices mainly because we got the first three for free. Other components included SD cards, cables, and solar setups, which accounted for the bulk of our costs. What I brought to the table was a MacGyver-like ability to solve problems creatively. For instance, when we installed our first temperature probe, we needed to protect it. I ran to student health services, asking for condoms to cover the probe, and they were unfazed, handing over a large quantity. This experience highlights just how accustomed those in campus health services are to unusual requests.
00:12:01.040 Although our solution wasn't perfect, we had to start somewhere. I integrated Twitter to get social media involved, and soon our beehive was tweeting its conditions. One of the funny interactions on social media was when someone reached out asking how to stop their dog from eating bees. Before I continue, who here is familiar with the acronym TAT? It's something started by Brian Lyles a few years back, meaning ‘Test All the Fudging Time’—I always struggle with the last word. With due respect to Brian, he’s wrong; it should mean ‘Try Awesome Things’—forget testing! This philosophy has resulted in humorous outcomes such as tweets claiming it’s 501 degrees in the hive. Such amusing mistakes catch attention and lead to engagement, which helped spread awareness of our project.
00:14:48.640 Our accidental fame led to the attention of the Sweet Virginia Foundation—a non-profit focused on honeybee education. Even they didn’t know we were raising bees at George Mason. They offered us space, which was a significant help. We started a crowdfunding campaign as well because each student involved would require about $1,000. Remarkably, we raised $12,000, allowing a class of twelve students to participate with a waiting list of over a hundred! Our Indiegogo campaign also raised awareness, making bees incredibly popular at George Mason University.
00:18:34.400 As a result, various campus groups and magazines began focusing on our bee project. The president of George Mason even got involved, granting us a budget which allowed us to pursue advanced technology. For those unfamiliar, the Raspberry Pi is a credit card-sized computer. I encourage everyone to check one out; they are affordable and versatile. If you choose to work with Raspberry Pis, I recommend backing up your SD card often, avoiding traditional DevOps routes, as compiling on a Raspberry Pi is about 60 times slower than on a traditional computer. They feature GPIO pins for general purpose input/output, which are easy to connect to other devices.
00:20:39.680 We also used several Ruby gems: gpio for hardware control, PiPiper, and WiringPi are all excellent options. To clarify, while it’s called ‘saving the world with Ruby on Rails,’ I actually used Sinatra for this project. I initially started using Dashing Rails for the dashboard but found that the added complexity of Rails was unnecessary. Simplicity was key, as we wanted a solution accessible to other beekeepers. Creating a dashboard using Sinatra allows you to view real-time data like temperature and humidity.
00:22:27.200 Our dashboard displays internal and external temperature and humidity, with a wirelessly served interface for easy access. Users can connect to the hive and see all the current statistics, thanks to a series of cron jobs gathering data every few hours—these scripts maintain an organized collection of our data as CSV files. This is straightforward to do with Dashing; data is sent to the dashboard every thousand seconds effectively. As for scaling, we're exploring new solutions since our current scale, which utilizes Python, has had issues. However, we did establish a wireless access point enabling seamless interactions with our project.
00:24:59.759 It’s achievable for anyone here with a solid foundational knowledge of Ruby and Rails. The key takeaway is that you can get involved in such projects too. There’s a sense sometimes that we exist in a bubble, focusing on minor performance issues while many others struggle with basic tasks and technologies. The truth is, educators and the community at large need help to solve practical problems. I’ve personally engaged in several projects just by attending talks and asking questions. I encourage everyone to consider contributing to these types of causes, as they offer an easy gateway into the world of open source, building resumes and skills along the way.
00:26:44.720 As a final invitation, I’d love for you to check out Ruby for Good, a conference in the Washington DC area on the first weekend of August. It’s an opportunity to hack on socially good open source projects with a focus on community engagement. Thank you for your time, and are there any questions?