Arvand Tabatabaie
Published

DHT monitoring using RPI with python and HTTP to uBeac

In this tutorial we are using DHT sensor and Python on a Raspberry Pi, in which sending data to uBeac IoT platform using HTTP protocol

IntermediateProtip24 minutes1,768
DHT monitoring using RPI with python and HTTP to uBeac

Things used in this project

Hardware components

Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1

Software apps and online services

Free Subscription
uBeac IoT Platform Free Subscription

Story

Read more

Code

send DHT data to uBeac IoT platform

Python
import time
import json
import requests
import Adafruit_DHT

sensor = Adafruit_DHT.DHT22
sensor_gpio = 4
url = "http://arash77.hub.ubeac.io/arash1377"
uid = "rpi_arash"

try:
    while True:
        humidity, temperature = Adafruit_DHT.read_retry(sensor, sensor_gpio)
        data = {
                "id": uid,
                "sensors":[{
                  'id': 'Temperature',
                  'data': temperature
                },
                {
                  'id': 'humidity',
                  'data': humidity
                }]
            }
        
        r = requests.post(url, verify=False, json=data)
        print(r.status_code)
        time.sleep(5)
 
except KeyboardInterrupt:
    pass

Credits

Arvand Tabatabaie

Arvand Tabatabaie

10 projects • 8 followers
My real life is stitch to IoT hardware and Platforms. everyday i find something new to work with and enjoy. some of my projects will be here

Comments