The Smart Shoe: a Raspberry Pi Sunlight Sensor


After growing vegetable seedlings the last two years, I felt compelled to try for a third. Living in an apartment presented a new set of question like, “where should I put the seedlings to get the best sunlight?”, or “how much space can I take up before my roommates start killing the plants?”

While I haven’t quite figured out how to answer the second question, I decided to take a scientific approach in answering the first. After some Googling, I pieced together a solution for attaching a sunlight sensor to an old Raspberry Pi I had laying around.

In doing so, I unwittingly created the world’s first Smart Shoe, and used it to track how much sunlight different areas of our apartment got on a daily basis.

With the Raspberry Pi and connectors tucked neatly into the shoe, the sunlight sensor is secured on the outside using the laces. The Raspberry Pi executes a simple Python script that polls the light sensor every 4 minutes and records the measurements in a CSV file.

The Materials

While I had some of the vital components already (e.g. the shoe), I did have to order a few things off of Amazon. The complete list of materials used is as follows:

  • Raspberry Pi 3, model B (and USB micro power charger)
  • Grove SI1145 Sunlight Sensor, ordered from Amazon
  • Pi2Grover adapter to allow the Sensor to talk to the RaspPi, from Amazon
  • Grover Connector Cables, also from Amazon
  • Five Ten Mountain Biking Shoe, found in the closet upstairs

The Configuration

Now we get into the technical stuff.. for those without the stomach for this, quickly scroll down and there are some more pictures at the bottom.

Updating the Raspberry Pi Software

Since I had just pulled my Raspberry Pi out for the first time in over a year, I needed to update the software to make sure it was running the latest and greatest (after all, it would be a catastrophe if the Smart Shoe were hacked).

Since I am running the standard Raspian / Debian distribution, I was able to take care of this with two simple aptitude commands:

apt-get update && apt-get upgrade

Hooking up the Components

After about an hour of updates, I powered down the Raspberry Pi and connected the Pi2Grover adapter. It fit snugly on top of the Raspberry Pi’s pins without issue. Next I used one of the Grover connector cables to attach the sunlight sensor to the Pi2Grover adapter.

Enabling the I2C Interface

Next it was time to enable the I2C interface on the Raspberry Pi (it is disabled by default). I found an easy-to-follow guide that included installing a few aptitude packages, and detailed how to use the raspi-config to enable the I2C interface.

After following the steps in the guide and restarting the Raspberry Pi, I confirm the I2C components were hooked up properly by executing:

sudo i2cdetect -y 1

My terminal readout was as follows, with the sunlight sensor successfully being discovered at the 0x60 address:

The Collection (Python Script)

After scouring the Internet I found two Python libraries that were required to interface with the Grove sunlight sensor via Python. Please keep in mind that I used these libraries with Python 2, and am not sure about their Python 3 compatibility. The libraries required were:

  1. Python Pure IO library – lower level functions that provided I/O access to I2C and SPI connected devices.
  2. SunIOT library – python API provided by the sunlight sensor’s manufacture that enables capturing readings from the sensor.

The first library does require an “installation”, which can be done by executing the following command inside of the library root:

sudo python install

The second library can simply be placed inside your project and imported via a relative path (which is what I did in my project).

The code I ended up using is posted on Github, and makes a great place to start since it already includes the two required libraries mentioned above. After checking out the code, simply modify the to execute whichever custom logic you require (and don’t forget about the installation step for the Pure IO library).

Once I had to script configured and tested, I scheduled it to run every 4 minutes with cron. I made sure the include a shebang at the top of the file, and took some steps to set the python working to keep things compact. Here was the result crontab entry:

*/4 * * * * /home/pi/Documents/dev/sunny-rasp/

The Results

After capturing for 2 days, I was able to clearly see how much direct sunlight the railing received each day (around 5ish hours). The Grove sensor also recorded UV and IR intensity, however I was only interested in its measurement of “sunlight intensity”.

Happily Ever After

While the peppers, eggplants, and tomatoes I am growing called for 8 hours of full sun, I figured 5/6 hours was worth a shot. The vegetables are now out resting safely on the railing.

It may be fun to take more measurements in a few months to see how the trajectory of the sun changes throughout the season.. Regardless the smart shoe was a fun little project that led to some solid data collection, and a whole lot of jokes about the future of footwear.

Update: August 2019

The plants have enjoyed this spot despite constant exposure to the heat and breeze. Looks like 5/6 hours of sunshine is plenty for a slow and steady grow. The tomatoes are still showing up, with the eggplant and peppers almost ready for harvest.

Subscribe by Email

Enter your email address below to be notified about updates and new posts.


Loading comments..

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *