Would you like to have the RPI tell you more about your house?
Need to know about barometric pressure or humidity?
Stay tuned and I will show you how to use your RPI and the Sense hat to get this information
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-flask
sudo apt-get install sense-hat
nano weather.py
from flask import Flask, render_template
from sense_hat import SenseHat
app = Flask(__name__)
@app.route(‘/’)
def index():
sense = SenseHat()
celcius = round(sense.get_temperature(), 1)
fahrenheit = round(1.8 * celcius + 32, 1)
return render_template(‘weather.html’, celcius=celcius, fahrenheit=fahrenheit)
if __name__ == ‘__main__’:
app.run(debug=True, host=’0.0.0.0′)
Ctrl x to save file
mkdir templates
nano templates/weather.html
Raspberry Pi Weather Station
Temperature
Celcius: {{ celcius }}
Fahrenheit: {{ fahrenheit }}
! Start web server
python3 weather.py
! Goto ip address of RPI:5000
! You should see a page showing temp in C and F
!! Add humidity and barometric pressure
nano weather.py
Below the line fahrenheit = round(1.8 * celcius + 32, 1), add the following lines:
humidity = round(sense.get_humidity(), 1)
pressure = round(sense.get_pressure(), 1)
Change return line to look like this –
return render_template(‘weather.html’, celcius=celcius, fahrenheit=fahrenheit, humidity=humidity, pressure=pressure)
Modify the html template to look like this
nano templates/weather.html
Raspberry Pi Weather Station
Temperature
Celcius: {{ celcius }}
Fahrenheit: {{ fahrenheit }}
Humidity
{{ humidity }}
Pressure
{{ pressure }}
! Install screen command to allow you to detatch and still be running
sudo apt-get install screen
! Start a screen session that you can disconnect from
screen bash
! Reconnect to screen when you reconnect to rpi
screen -r
!Sense hat temperature discussion
https://www.raspberrypi.org/forums/viewtopic.php?t=152498
How to Set up Raspberry Pi Weather Station Using the Sense HAT?
⏱️TIMESTAMPS⏱️
0:00 – Intro
================================================
*** Show Notes, Links and Resources ****
Here are the items mentioned in this video –
RPI 2GB
CanaKit Raspberry Pi 4 Basic Kit (2GB RAM)
https://amzn.to/3vLHqjo
CanaKit Raspberry Pi 4 4GB Basic Kit with PiSwitch (4GB RAM)
https://amzn.to/3eWsDMR
Raspberry Pi RASPBERRYPI-SENSEHAT Sense HAT
https://amzn.to/3v6yd3J
Geekworm Raspberry Pi 4 Case, Raspberry Pi 4 Model B CNC Ultra-Thin Aluminum Alloy Metal Passive Cooling Case
https://amzn.to/32q9awx
———————————–
Click on this link to get the
SmartHome Account Creation Checklist
http://eepurl.com/go4fVP
➥➥➥ SUBSCRIBE FOR MORE VIDEOS ➥➥➥
Never miss a video about creating your own smart home
Subscribe ⇢ http://ronaldnutter.com/subscribe
To listen to an audio version of this episode while driving, TechBytes with Ron Nutter is available on iTunes, Google Podcasts, Stitcher and TuneIn. Go to TechByteswithRonNutter.com to subscribe today!
To subscribe to the TechbytesRN newsletter, click here – http://ronaldnutter.com/sample1
In return for subscribing to the newsletter, I will send you a chapter from my first DIY Smart Home Guide Book.
Visit http://www.ronaldnutter.com to see all the books Ron has written
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This helps support the channel and allows me to continue to make videos like this. Thank you for the support!
*===============================*
Become a Patreon supporter
https://www.patreon.com/techbytesrn
*===============================*
#TechBytesRN #smarthome #RaspberryPi #Sense #Weather
Podcast: Play in new window | Download
Subscribe: Apple Podcasts | TuneIn | RSS