"Hack the Plants" — Five Lessons Learned from an IoT Adventure
Do a search on “IoT projects” and you’ll turn up endless pages of fantastic Internet of Things ideas and examples. Roll-your-own home security system! Track your cat’s movement! Build your own droid! With so many resources available, one might think all the problems are solved, all the answers just a few clicks away.
We found that to be…not quite the case. Those abundant resources are a great help, but there’s still a vast landscape to explore—with a lot of unexpected twists and turns.
For Metal Toad’s most recent IoT Hackathon, I joined a team of Toads seeking to build a cloud-hosted plant monitoring system in two days. The five of us on the team—Kalina Wilson, Corey Ledford, Lloyd Briggs, Josh Bench, and led by Marri Gamard—represented many years of tech industry experience across the board, from hardware to cloud to UI.
Our goal was to set up a houseplant with light, humidity, temperature, and moisture sensors that would stream to the cloud and be monitored through a web front end. For hardware, we selected an Arduino Uno with a Sparkfun ESP8266 wifi shield, with an Adafruit TSL2561 light sensor, Sparkfun RHT03 humidity and temperature sensor, and a Phantom YoYo moisture sensor.
While our project was ultimately successful and we accomplished *almost* all our goals, we also encountered many surprises, despite all our tech industry experience.
These are some of the lessons we took to heart over the course of our two-day sprint.
1. Start with more powerful hardware than you think you’ll need for your end product.
You probably don’t want to derail your rapid prototyping by getting bogged down with memory management right off the bat.
We started with an Arduino Uno, which has very little memory. Almost immediately we ran into memory usage warnings—so we not only had to stop adding sensor libraries, we had to spend time throwing out all non-essential code, even debug messages. We wished we’d selected a board with more wiggle room.
2. Choose hardware that will allow you to work in a familiar language/environment.
The language used to program Arduino is C++ (though there are some workarounds out there). We didn’t have a lot of C++ experience in our group and were surprised by how quickly we got caught up on minor details that were hard to resolve with quick internet searches. If we were to start this project again, we’d choose hardware that enabled development in Python or C#—or else start out with a crash course in reviewing C++ conventions.
On the bright side, we were able to develop our Arduino code in Visual Studio Code—an IDE we all knew well and enjoyed. This was made possible by way of the PlatformIO extension for VS Code, which worked great and was much more comfortable and familiar than Arduino IDE.
3. One of your team’s first steps should be learning about IoT’s unique demands and best practices.
Building for IoT isn’t the same as building for websites. Coming from mostly web development backgrounds, we started out using simple HTTP requests and supporting those in the same way we would for a website. We built our cloud platform on AWS with an API Gateway and a set of lambdas. Our web application was set up to ping those lambdas for updated information, as a series of individual requests.
This approach was our fastest path to a working prototype, and it was super satisfying to see those early results. However, this approach reduced the amount of time we had left to learn about, create, and troubleshoot the technologies that are more appropriate to IoT, such as AWS IoT Core, AWS Kinesis, and the MQTT protocol. We wished we’d made that transition earlier in the process.
4. When it comes to building a front end, ReactJS is a great option…with a caveat.
We chose ReactJS and leveraged create-react-app and stateless functional components to create a clean and strong foundation very quickly. Caveat: we also leveraged Lloyd, a highly experienced React developer.
React has a serious learning curve at the beginning, but once you’ve invested, it’s a great framework for building solid code, fast.
5. IoT is challenging…but worth it.
While we hit some roadblocks along the way, we iterated fast, saw results almost immediately, and tried a lot of new activities. Lloyd used a soldering iron for the first time, and I started to get the hang of MQTT. Marri got serious about sensors and sensor libraries. Corey and Josh learned how the AWS IoT offerings are set up and how they differ from other non-IoT options. We also tried out consuming Kinesis data and pushing it into DynamoDB. As a whole, the project served as a great context in which to learn about the AWS services we hadn’t experimented with before. And you should have seen our faces when the pieces came together and our React dashboard started showing sensor data received from the cloud!
When an IoT project ties together a physical object in space with the power of the cloud and the visualization possibilities of the web, that feels like magic. Our team had a lot of fun experiencing the IoT “wow” factor, and we can’t wait to try again.