Home

Awesome

Smart Garden Ornaments

License: MIT Twitter: jimbobbennett

Ever wanted to track things happening in your garden, neighborhood or school using smart garden ornaments? Now you can using BBC micro:bits and a cloud-based IoT service.

A bird box in a tree with a micro bit visible inside

This is a fun week long project for those who want to take their first steps into the world of the Internet of Things (IoT) using devices that are popular with kids, and tools that make programming accessible to young developers. You'll use a Raspberry Pi along with some BBC micro:bits and any garden ornaments you have to hand to build a smart neighborhood, gathering data such as temperature and noise levels and displaying it in the cloud using Azure IoT Central.

This is great for families, groups of friends, or even in the classroom - gathering data around your school.

How it works

Each smart garden ornament is based around a BBC micro:bit, programmed using Microsoft MakeCode. These micro:bits sit inside whatever ornament you have, such as a bird box or garden gnome, and gather data about the outside world - also know as telemetry. This data can come from the built-in temperature sensor, or external sensors such as microphones, proximity senors or soil moisture sensors. These micro:bits will then send this data to other micro:bits via the built-in radio. Each micro:bit will forward on the message just like passing notes in class until it reaches a 'hub' micro:bit connected to a Raspberry Pi. This will then send the message on to the cloud to plot on a chart.

The hub

This project is not limited to one household - if you have neighbors they can also have smart garden ornaments as long as they are positioned close enough for the micro:bits to talk to each other. If you want to share data between households that are further apart, you can do this by using multiple hubs all connected to the same cloud service. It's also perfect to set up in a school, tracking data in classrooms or the playground.

What you'll need

Coding skills

Although this guide tries to be as easy to use as possible, you will still need some technology skills. The Pi-based hub should be built by someone confident setting up a Raspberry Pi and have a basic understanding of coding with Python. The micro:bits should be programmed by someone confident programming with block-based coding.

The following icons are used to indicate if a section covers the Azure IoT Central, using the Raspberry Pi or the micro:bit:

IconDescription
IoT Central logoAzure IoT Central - will need someone with an Azure account
Raspberry Pi LogoRaspberry Pi - will need someone confident setting up and programming a Raspberry Pi
The micro:bit logomicro:bit - will need someone confident using block based programming on a BBC micro:bit

If you have never set up a Pi before, you can find some great guides on the Raspberry Pi Help site.

To learn mode about coding a micro:bit with Microsoft MakeCode, check out all the tutorials at makecode.microbit.org.

The Hub

For the 'hub' that allows your micro:bits to connect to the cloud, you'll need the following:

The hub components

Smart garden ornaments

For each smart garden ornament you'll need the following:

The hub components

The micro:bits have a temperature sensor built in, so if you are just tracking temperature this is all you'll need. If you want to track other things then you'll need different sensors. Some need to be purchased as a sensor (such as a microphone to track noise levels or a proximity sensor), others such as a soil moisture sensor can be made yourself. This project will cover the following sensors:

If you want to use other sensors, check out the great kits from places like SparkFun and Kitronik.

Cost

The main cost to this project is the hardware. The project uses hardware that combines relatively low cost with ease of use - cheaper parts could be used with an added complexity.

The cloud service used may come with a small cost. It is free for the first 2 devices used, so if you want to use more smart ornaments then your Azure account will be billed. If you have signed up for a student or free account this can come from the credit you are given on sign up leading to no actual cost. The cost at the time of writing is US$0.70 per additional device per month. You can read more details on pricing on the Azure IoT Central pricing page.

How the project works

If you just want to get everything up and running, you can skip this part and dive into the setup.

The flow of messages in the project

The basic architecture is:

If you want to understand more about the architecture and how the code works, check out the following:

How this guide is structured

This guide is broken down into a number of days. For each day the project should take no more than about an hour and adds another part to the finished project. Each day will contain multiple parts, labelled as either beginner or advanced. The advanced parts should be done by someone with some experience, the beginner parts are ideal for those just getting started with block based programming. Older kids with some programming experience may be able to complete the entire project, but will require an adult to set up the Azure resources as these may require a credit card and require a sign up from someone over the age of 18.

Follow the links below to access the steps for each day:

All the code you need for the Pi is in the pi-hub folder. The code for the micro:bit portions is in separate GitHub repos that can be imported into MakeCode. The code for the micro:bit Hub is at github.com/jimbobbennett/smart-garden-ornaments-microbit-hub, and the device code is available at github.com/jimbobbennett/smart-garden-ornaments-microbit-device.

As new concepts are covered (such as setting up IoT Central, or using new blocks in MakeCode), full descriptions are given with detailed pictures. The next time the same concept is covered, there will be less pictures and description.

Contributing to this project

We'd LOVE you to contribute to this project! If you find mistakes in this guide please raise an issue or a PR. If you have additional ideas for ways to extend this project, or want to add instructions for more sensors or different ornaments please fork this repo and add them to the Additional ideas section in a PR. We'd also love it if you want to share your stories - how did you set this up, what ornaments did you use, what data did you gather. Please fork the repo raise a PR to add these to the Stories section. All contributions must follow our code of conduct.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Learn more, get certified

If you want to learn more about Azure IoT Services, then check out the following:

Once you have upskilled as an IoT developer, why not get certified with our upcoming AZ-220 Azure IoT Developer certification. Check out the details on our certification page