@Azazel wrote:
Hi Guys,
I’m sorry, I’m very new to the python and sensors game :)
I’ve recently purchased Enviro+ and would like to plot out the data. How are you guys plotting your sensors outputs?
I did some Googling and looks like you can try to use Plotly, Adafruit OI and more manual like this one Data Collection, Logging, Plotting & Serving - A Simple Guide
I have tried to adopt the python from examples and the guide but ran into issues in the exporting to CSV part:
#!/usr/bin/env python import time import csv from bme280 import BME280 from datetime import datetime try: from smbus2 import SMBus except ImportError: from smbus import SMBus dt = datetime.now() full_date = dt.strftime("%Y-%m-%d") full_time = dt.strftime("%H:%M:%S") full_day = dt.strftime("%A") year = dt.year month = dt.month date = dt.day hour = dt.hour bus = SMBus(1) bme280 = BME280(i2c_dev=bus) temperature = bme280.get_temperature() pressure = bme280.get_pressure() humidity = bme280.get_humidity() csvWrite = full_date, full_time, full_day, year, month, date, hour, temperature, pressure, humidity csvFile = open("/home/pi/enviroplot.csv", "a") while True: with csvFile: writer = csv.writer(csvFile) writer.writerow(csvWrite) time.sleep(1)
Errors:
Traceback (most recent call last): File "Weather_Plot_Test.py", line 35, in <module> with csvFile: ValueError: I/O operation on closed file
Posts: 1
Participants: 1