Created
June 8, 2019 13:12
-
-
Save keflavich/e2352ac5f5f1a87babe02546241bd4e6 to your computer and use it in GitHub Desktop.
co2 monitor script, based on https://github.com/vfilimonov/co2meter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/Users/adam/anaconda/envs/astropy35/bin/python | |
| import os | |
| import datetime | |
| import co2meter.co2meter | |
| import pylab as pl | |
| mon = co2meter.co2meter.CO2monitor() | |
| mon.start_monitoring(interval=10) | |
| pl.pause(11) | |
| while 1: | |
| pl.figure(1) | |
| pl.clf() | |
| ax=pl.figure(1).gca() | |
| ax.set_ylabel("CO$_2$ [ppm]") | |
| ax.set_xlabel("Local Time") | |
| try: | |
| mon.data.plot(secondary_y='temp', ax=ax) | |
| today = datetime.datetime.strftime(datetime.datetime.today(), '%Y-%m-%d') | |
| pl.xlabel("Local Time") | |
| pl.ylabel("Temperature [$^\circ$C]") | |
| pl.savefig(os.path.expanduser('~/co2monitor/{0}.png'.format(today))) | |
| #print(mon.data.tail(1)) | |
| pl.pause(10) | |
| except Exception as ex: | |
| print(ex) | |
| continue | |
| mon.log_data_to_csv(os.path.expanduser('~/co2monitor/{0}.csv'.format(today))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment