Get Humidity/Temperature from Web

LAN Bottle server that handles HTTP requests using Raspberry Pi 4, Adafruit DHT11 and a RGB LED.


The idea of ​​the project is very simple. After accessing the web page, you can see in real time what temperature and humidity is in the area of ​​the DHT11 sensor used by the Raspberry Pi.

Sending a request to the server will light up the LED in a certain color depending on the route of the request. Then the client will get a response with the requested value and he will also be able to see the color of the diode in the HTML L.E.D. element.

View of circuit implementation

Accesing the web page

Sending a GET request with ‘/' to the server will automatically light up the R LED attached to the board.

This is what happens on the board after the request.

After getting the response from the server, you will be able to check the temperature and humidity around the board using the blue(humidity) or green(temperature) buttons. Pressing one of the buttons will result in sending requests to the server once every second continuously until the stop button is pressed or until the page is closed/reloaded.

Pressing the blue button

Will change text and L.E.D. colors to blue and display the humidity around the sensor.

Pressing the green button

Will change text and L.E.D. colors to green and display the temperature around the sensor.

Pressing the red-stop button

Will change L.E.D. color to red, set the text value to default and will stop receiving updates about temperature/humidity.

Stop the server using Ctrl+C

After the server stops, the LED is turned off and the GPIO pins are cleaned.



from bottle import route, run, template, request
import RPi.GPIO as GPIO
import Adafruit_DHT

#setarea modului de citire a pinilor

#setare pin senzor umiditate/temperatura
type = Adafruit_DHT.DHT11
dht11 = 25
GPIO.setup(dht11, GPIO.IN)

#setare pini leduri
GPIO.setup(14, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)

#stabilirea rutelor
def index():
    return template('index.html')

def umiditate():
    umiditate,temperatura=, dht11)
    return {'umiditate':umiditate}

def temperatura():
    umidiate,temperatura =, dht11)
    return {'temperatura':temperatura}

def stop():
    return {'stop':'Nimic de afisat...'}

def setLedsOnLow():
#start server
run(host = '', port = '6789')
#la stop server, stinge leduri si curata pini

Source: Get Humidity/Temperature from Web

About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

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

Scroll to Top