Bme280 temp dashboard

Hi all

Im new to this, i havd a raspberry pi 4 and piicodev bme280
I can run some code and see temps pressures rolling over every sec, is there a way to have a dashboard or something to display temp in a nice way like a guage so its not just a massive line of code ?

Thanks karl

4 Likes

If you are using Python then have a look at “pygame”.
It is a library that allows for graphical display on the screen.

I used it on a few small projects, happy with the results.

Cheers
Jim

5 Likes

Hi Karl,

Welcome to the forum!!

I’d take a look at combining the output with matplotlib to make a real time graph on your Pi’s screen or using Flask to host a local webserver.

There are plenty of options out there!

4 Likes

For something simple, checkout Tkinter

4 Likes

so i have been playing round with the temp sensoor and rpi4,
i have been uploading to weather underground dont know if any one uses this but the code will run for about 2 days then have an error and stop uploading, can restart code then all good again for 2 days,
not sure this issue,

another questin is there some filtering i can use for this sensor?
i am using temp, hum, press aswell as a formula for dew point,
data is uploaded every 3 mins also

1 Like

Hi Karl,

Neat project!!

Could you please send through your code so we can take a look - alongside this what hardware are you using?

Since the sensor uses I2C rather than an analog, filtering has to be done in software. There are some super simple filters that you could implement such as a moving average(MA) filter, each filter has some drawbacks (MA has a time delay but noise suppression)

Liam.

ok sorry for delayed reply, so i have as raspberry pi4 and a piicodev bme280 and an adaptor board
i have this code now i wasn’t the designer of this but i have moded this to work with this sensor, added a 3min refresh and am able to calculate due point, i removed station id and password,
after about 2 days it stops uploading as says connection error and the code stops i can start it again and its fine again for about 2 days then same thing happens,
i have this = sensor = PiicoDev_BME280(t_mode=2, p_mode=5, h_mode=1, iir=2)
and i think it is filtering but not realy sure
all this work on weather underground

version = “1.51”
import requests
import time
from PiicoDev_BME280 import PiicoDev_BME280
from PiicoDev_Unified import sleep_ms
from datetime import datetime

Station ID

station_ID =

Auth key

station_KEY =

interval = 60*3 #Time between sends in seconds

Execution below this line, no need to edit

#-----------------------------------------------------------------------#

Base URL

base_URL = “https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php”

while True:
software_type = “WU_Upload-v” + version

print("Reading sensor...")

sensor = PiicoDev_BME280(t_mode=2, p_mode=5, h_mode=1, iir=2)

tempC, presPa, humRH = sensor.values()

#Convert temp to degF
tempF = tempC*(9/5) + 32

#Convert pressure to inches of mercury
inchMerc = presPa*0.0002953

#Put dew point stuff here

c = tempF
x = 1 - 0.01 * humRH;

dewpoint = (14.55 + 0.114 * c) * x;
dewpoint = dewpoint + ((2.5 + 0.007 * c) * x) ** 3;
dewpoint = dewpoint + (15.9 + 0.117 * c) * x ** 14;
dewpoint = c - dewpoint;


# Build first half of POST
post_URL = base_URL+"?ID="+station_ID+"&PASSWORD="+station_KEY+"&dateutc=now"

# Fill dictionary with variables
payload = {"tempf": tempF, "humidity": humRH, "baromin": inchMerc,\
    "dewptf": dewpoint,"softwaretype": software_type, "version": version,\
    "action": "updateraw"}

# Push data, exit on error
print("Connecting to Weather Underground...")
try:
    wu_push = requests.get(post_URL, params=payload, timeout=15)
except requests.exceptions.Timeout:
    print("Timeout!")
    exit()
except requests.exceptions.ConnectionError:
    print("Network Error!")
    exit()
except requests.exceptions.RequestException as e:
    print("Unknown Error!")
    exit()

# See if there was a good connection
if wu_push.status_code != 200:
    print("Error communicating with server")
    exit()

# Check response
if "success" in wu_push.text:
    # Print status message and write conditions to log
    print("Upload OK!")

elif "Password" in wu_push.text:
    print("Station ID or password error!")
else:
    print("Invalid response!")

# Close file and print message
print("Done")

#Wait interval until next data send
time.sleep(interval)

EOF

Is this the error you get ?
How is the Pi4 connected to the internet, Wifi or Ethernet Cable ?

If it is “Error communicating with server”.
Exiting the program because the server cannot be communicated with just once, is not good programming. Internet communications are far from perfect. If anything the program should print the error message and continue, one reading lost.

You could try removing the exit() in the above code and see what happens.

Of course it may be something else.
You could try printing the readings to the Pi4 screen and not send to the URL and see if it runs for more than 2 days. If not it is something in the Pi4 that is stopping the program. If it runs ok then it could be the internet connection to the Pi4.

The aim is to find what it causing the program to exit.

Regards
Jim

1 Like

Yes that might do it ill get rid of it and see what happens but still weird that it does it after 2 days

I guess i will change it and wait

1 Like

see this project he has used BME280 to show and declear the dashboard to show temperature.
this will help you in this regard, clearing the issue of guage and dashboard.

1 Like