# PyPortal IoT Plant Monitor with Microsoft Azure IoT and CircuitPython

## Overview

Danger: This project's code utilizes the Azure IoT Library which currently does not work with AirLift hardware, such as the Adafruit PyPortal. As a result, this project does not currently work (but may in the future).

For a more updated guide using CircuitPython and Microsoft Azure IoT, visit https://learn.adafruit.com/getting-started-with-microsoft-azure-and-circuitpython

![A rosemary plant connected to a PyPortal tracking temperature and soil moisture](https://cdn-learn.adafruit.com/assets/assets/000/091/580/medium800/sensors_IMG_3274.png?1591648748 A rosemary plant connected to a PyPortal tracking temperature and soil moisture)

_Keep forgetting to water your plants? Want to monitor the ambient temperature of the room your plant is located in from across the world?&nbsp;_

**In this guide, you will build an Internet-enabled plant monitoring display by combining [Azure IoT Central from Microsoft](https://azure.microsoft.com/services/iot-central/?WT.mc_id=iotcentral-adafruitlearningsystem-jabenn) and CircuitPython!&nbsp;**

**Using Azure with your CircuitPython IoT projects&nbsp;allows you to rapidly prototype** (and even mass-prototype) **advanced internet-of-things devices** and connect them to Microsoft Azure services.

Once your CircuitPython device's data is sent to [Azure IoT Central](https://azure.microsoft.com/services/iot-central/?WT.mc_id=iotcentral-adafruitlearningsystem-jabenn), you can visualize your data on a dashboard. From there you can connect other Azure services such as:

- [Azure Blob Storage](https://azure.microsoft.com/services/storage/blobs/?WT.mc_id=iotcentral-adafruitlearningsystem-jabenn): Blob storage for all your sensor data to analyze later
- [Event Hubs](https://azure.microsoft.com/services/event-hubs/?WT.mc_id=iotcentral-adafruitlearningsystem-jabenn): Real-time data pipelines capable of streaming millions of events per second between Azure services
- [Azure Stream Analytics](https://azure.microsoft.com/services/stream-analytics/?WT.mc_id=iotcentral-adafruitlearningsystem-jabenn): Real-time analytics pipeline allowing you to query data in real time
- [Azure Machine Learning](https://azure.microsoft.com/services/machine-learning/?WT.mc_id=iotcentral-adafruitlearningsystem-jabenn): Build machine learning models that can be used from Stream Analytics to provide real-time predictions over your data

You can get hands on with and learn more about the Azure IoT services on [Microsoft Learn](https://docs.microsoft.com/learn/browse/?term=iot&WT.mc_id=iotcentral-adafruitlearningsystem-jabenn).

![Azure IoT Central logo](https://cdn-learn.adafruit.com/assets/assets/000/091/584/medium640/sensors_IoTCentral.png?1591648101)

## CircuitPython Code

CircuitPython is **perfect** for building Internet-of-Things projects. This project uses the [ESP32SPI CircuitPython](https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI) library, which can use the ESP32 as a WiFi-coprocessor to send web requests.

**We've created a [CircuitPython Azure IoT helper module](https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT/)** to provide an API to interact with Azure IoT Central.

**You can rapidly update your code without having to compile** and store WiFi and API secret keys on the device. This means that there's no editing code and re-uploading whenever you move the PyPortal to another network - just update a file and you're set.&nbsp;

![Mu editor showing circuit python code](https://cdn-learn.adafruit.com/assets/assets/000/091/585/medium640/sensors_wireless_mu_ss.png?1591648134)

## Stemma Soil Sensor

This soil sensor uses&nbsp; **capacitive** &nbsp;measurement. Capacitive measurements use only one probe, don't have any exposed metal, and don't introduce any DC currents into your plants. We use the built in capacitive touch measurement system built into the ATSAMD10 chip, which will give you a reading ranging from about 200 (very dry) to 2000 (very wet).

As a bonus, we also give you the ambient temperature from the internal temperature sensor on the microcontroller, it's not high precision, maybe good to + or - 2 degrees Celsius.

![stemma soil sensor](https://cdn-learn.adafruit.com/assets/assets/000/091/586/medium640/sensors_wireless_4026-00.jpg.png?1591648144)

## PyPortal

Say hello to PyPortal! The easiest way to build your IoT projects with a touchscreen display!

[Make sure to walk through the PyPortal introduction guide and walkthrough the pages. It'll get you setup with CircuitPython and a handful of demo code to play with!](https://learn.adafruit.com/adafruit-pyportal)

![A PyPortal on a shelf next to a plant](https://cdn-learn.adafruit.com/assets/assets/000/091/587/medium640/sensors_wireless_circuitpython_internet_of_things___iot_3d_printing_hero_%281%29.png?1591648159)

## Prerequisite Guides

If you're new to CircuitPython, take a moment to walk through the following guides to get you started and up-to-speed:

- [Welcome to CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython)
- [PyPortal Introduction Guide](https://learn.adafruit.com/adafruit-pyportal)

## Parts
Featured
### Adafruit PyPortal - CircuitPython Powered Internet Display

[Adafruit PyPortal - CircuitPython Powered Internet Display](https://www.adafruit.com/product/4116)
 **PyPortal** , our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Make custom touch screen interface GUIs, all open-source, and Python-powered using&nbsp;tinyJSON / APIs to get news, stock, weather, cat photos,...

In Stock
[Buy Now](https://www.adafruit.com/product/4116)
[Related Guides to the Product](https://learn.adafruit.com/products/4116/guides)
![Front view of a Adafruit PyPortal - CircuitPython Powered Internet Display with a pyportal logo image on the display. ](https://cdn-shop.adafruit.com/640x480/4116-00.jpeg)

Featured
### Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor

[Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor](https://www.adafruit.com/product/4026)
Most low cost soil sensors are _resistive_ style, where there's two prongs and the sensor measures the conductivity between the two. These work OK at first, but eventually start to oxidize because of the exposed metal. Even if they're gold plated! The resistivity measurement...

In Stock
[Buy Now](https://www.adafruit.com/product/4026)
[Related Guides to the Product](https://learn.adafruit.com/products/4026/guides)
![Demo Shot of the Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor in a small potted plant, with wires connecting it to an Adafruit Metro.](https://cdn-shop.adafruit.com/640x480/4026-01.jpg)

Featured
### STEMMA Cable - 4 Pin JST-PH 2mm Cable–Female/Female

[STEMMA Cable - 4 Pin JST-PH 2mm Cable–Female/Female](https://www.adafruit.com/product/3568)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-PH female 4-pin connectors on each end. These types of JST cables are commonly found on small rechargeable battery packs, RC receivers and transmitters, tiny cameras, and other small electronic devices

We're...

In Stock
[Buy Now](https://www.adafruit.com/product/3568)
[Related Guides to the Product](https://learn.adafruit.com/products/3568/guides)
![Angled shot of 150mm/6" long 4-Pin JST-PH Cable](https://cdn-shop.adafruit.com/640x480/3568-05.jpg)

## Materials

You'll need some extra supplies to finish this project. If you do not have them already, pick some up from Adafruit.

### Adafruit PyPortal Desktop Stand Enclosure Kit

[Adafruit PyPortal Desktop Stand Enclosure Kit](https://www.adafruit.com/product/4146)
PyPortal is&nbsp;our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Create little pocket universes of joy that connect to something good.

And now that you've made a cool internet-connected project...

In Stock
[Buy Now](https://www.adafruit.com/product/4146)
[Related Guides to the Product](https://learn.adafruit.com/products/4146/guides)
![Demo Shot of the Assembled Adafruit PyPortal Desktop Stand Enclosure Kit.](https://cdn-shop.adafruit.com/640x480/4146-03.jpg)

- [Next Page](https://learn.adafruit.com/using-microsoft-azure-iot-with-circuitpython/pyportal-wiring.md)

## Guide Products

### Adafruit PyPortal - CircuitPython Powered Internet Display

[Adafruit PyPortal - CircuitPython Powered Internet Display](https://www.adafruit.com/product/4116)
 **PyPortal** , our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Make custom touch screen interface GUIs, all open-source, and Python-powered using&nbsp;tinyJSON / APIs to get news, stock, weather, cat photos,...

In Stock
[Buy Now](https://www.adafruit.com/product/4116)
[Related Guides to the Product](https://learn.adafruit.com/products/4116/guides)
### Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor

[Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor](https://www.adafruit.com/product/4026)
Most low cost soil sensors are _resistive_ style, where there's two prongs and the sensor measures the conductivity between the two. These work OK at first, but eventually start to oxidize because of the exposed metal. Even if they're gold plated! The resistivity measurement...

In Stock
[Buy Now](https://www.adafruit.com/product/4026)
[Related Guides to the Product](https://learn.adafruit.com/products/4026/guides)
### STEMMA Cable - 4 Pin JST-PH 2mm Cable–Female/Female

[STEMMA Cable - 4 Pin JST-PH 2mm Cable–Female/Female](https://www.adafruit.com/product/3568)
This 4-wire cable is a little over 150mm / 6" long and fitted with JST-PH female 4-pin connectors on each end. These types of JST cables are commonly found on small rechargeable battery packs, RC receivers and transmitters, tiny cameras, and other small electronic devices

We're...

In Stock
[Buy Now](https://www.adafruit.com/product/3568)
[Related Guides to the Product](https://learn.adafruit.com/products/3568/guides)
### Adafruit PyPortal Desktop Stand Enclosure Kit

[Adafruit PyPortal Desktop Stand Enclosure Kit](https://www.adafruit.com/product/4146)
PyPortal is&nbsp;our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Create little pocket universes of joy that connect to something good.

And now that you've made a cool internet-connected project...

In Stock
[Buy Now](https://www.adafruit.com/product/4146)
[Related Guides to the Product](https://learn.adafruit.com/products/4146/guides)
### Pink and Purple Braided USB A to Micro B Cable - 2 meter long

[Pink and Purple Braided USB A to Micro B Cable - 2 meter long](https://www.adafruit.com/product/4148)
This cable is&nbsp;super-fashionable&nbsp;with a woven pink and purple Blinka-like pattern!

First let's talk about the cover and over-molding. We got these in custom colors, and if you&nbsp;_have_&nbsp;to have visible cables, then you might as well have the nicest fabric-bound...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4148)
[Related Guides to the Product](https://learn.adafruit.com/products/4148/guides)

## Related Guides

- [Adafruit STEMMA Soil Sensor - I2C Capacitive Moisture Sensor](https://learn.adafruit.com/adafruit-stemma-soil-sensor-i2c-capacitive-moisture-sensor.md)
- [Adafruit PyPortal - IoT for CircuitPython](https://learn.adafruit.com/adafruit-pyportal.md)
- [Easter Egg Light Stand](https://learn.adafruit.com/easter-egg-light-stand.md)
- [PyPortal Adafruit Quote Book](https://learn.adafruit.com/pyportal-adafruit-quote-board.md)
- [Twin Peaks Light Reactive Picture Frame](https://learn.adafruit.com/twin-peaks-light-reactive-pyportal-picture-frame.md)
- [Electronic History of the Day with PyPortal](https://learn.adafruit.com/electronic-history-of-the-day-with-pyportal.md)
- [PyPortal Event Countdown Clock](https://learn.adafruit.com/pyportal-event-countdown-clock.md)
- [Next Level MakeCode Arcade Games](https://learn.adafruit.com/next-level-makecode-arcade-games.md)
- [Custom Controllers for MakeCode Arcade](https://learn.adafruit.com/custom-controllers-for-makecode-arcade.md)
- [Blinka Jump PyBadge Game](https://learn.adafruit.com/blinka-jump-pybadge-game.md)
- [PyPortal LIFX Lighting Controller ](https://learn.adafruit.com/pyportal-lifx-lighting-controller.md)
- [Upgrading AirLift ESP32 Firmware](https://learn.adafruit.com/upgrading-esp32-firmware.md)
- [Snow Globe with Circuit Playground Bluefruit](https://learn.adafruit.com/snow-globe-bluefruit-cpb.md)
- [PyPortal Email Display with Zapier and Adafruit IO](https://learn.adafruit.com/pyportal-email-display.md)
- [PyPortal Discord Online Counter](https://learn.adafruit.com/pyportal-discord-online-count.md)
- [PyPortal New New New Product Viewer](https://learn.adafruit.com/pyportal-new-new-new-product-viewer.md)
- [How to Make Animated Graphics for Hologram Displays](https://learn.adafruit.com/how-to-make-animated-graphics-for-hologram-displays.md)
