• Home
  • Examples
  • Send Temperature and Humidity Data to Adafruit IO with Python

Send Temperature and Humidity Data to Adafruit IO with Python

Example Description
Learn how to connect a DHT sensor to PictoBlox and use the Adafruit IO cloud service to send temperature and humidity data to the cloud. Create a dashboard to visualize the temperature and humidity data with the help of line chart and gauge elements.

We will use the Adafruit IO cloud service to send data from a humidity and temperature sensor to the cloud in the Python Coding Environment of PictoBlox. Adafruit IO is a cloud service that allows you to send data from sensors and other devices to the cloud, where it can be stored and analyzed.

Adafruit IO Key

You can find the information about your account once you log in from here:

Note: Make sure you are login on Adafruit IO: https://io.adafruit.com/

DHT Sensor Connection to Quarky

DHT sensors have 3 pins: GND, VCC, and Signal. You have to connect the following 3 pins to the Quarky Expansion Board:

  1. GND to Ground Pin of Quarky Expansion Board
  2. VCC to 3.3V or VCC Pin of Quarky Expansion Board
  3. Signal to the D3 (Digital Pin) of the Quarky Expansion Board

Code for Stage Mode

# This code is used to connect to the internet and measure the temperature and humidity of the house.
# First, the Quarky object  are created.
quarky = Quarky()

# Time module is imported.
import time

# AdaIO object is created.
adaio = AdaIO()

# IoTHouse object is created.
house = IoTHouse()

# Then, the connection to Adafruit IO is made.
adaio.connecttoadafruitio("STEMNerd", "aio_UZBB56f7VTIDWyIyHX1BCEO1kWEd")

# The feeds for temperature and humidity are created.
adaio.createfeed("Temperature")
adaio.createfeed("Humidity")

# A while loop is used to measure the temperature and humidity continously.
while True:
  # Temperature is measured using the dhtmeasure function.
  adaio.createdata("Temperature", house.dhtmeasure(1, "D3"))
  # The loop pauses for 1 second.
  time.sleep(1)

  # Humidity is measured using the dhtmeasure function.
  adaio.createdata("Humidity", house.dhtmeasure(2, "D3"))
  # The loop pauses for 5 seconds.
  time.sleep(5)

 

The following feeds are created:

Creating Dashboard

Follow the steps:

  1. Go to the dashboard and click on New Dashboard.
  2. Add the Dashboard Name and Description and click on Create.
  3. Open the New Dashboard. Click on the Setting icon in the top right corner and then click on Create New Block.
  4. From the options, click on the line chart.
  5. Select the Temperature Feed and click on Next Step.
  6. Add the Block Title and the Y-Axis Minimum – Maximum value. Click on Create Block.
  7. You will find the block added on the dashboard.
  8. Add a Humidity block as well. Also, add two gauge elements showing the current temperature and humidity value.
  9. Click on the Setting button and Edit Layout to align all the buttons.
Table of Contents