I changed the code to be more like the examples:
Code: Select all
import time
# import adafruit library for SCD30 CO2 monitor.
import adafruit_scd30
# import Adafruit IO REST client.
from Adafruit_IO import Client, Feed
# Delay in-between sensor readings, in seconds.
SENSOR_READ_TIMEOUT = 5
# Set to your Adafruit IO key and username.
ADAFRUIT_IO_KEY = "YOUR_AIO_KEY"
ADAFRUIT_IO_USERNAME = "YOUR_AIO_USERNAME"
# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
# Set up SCD30 CO2 Monitor.
scd30 = adafruit_scd30.SCD30()
while True:
if scd30.data_available:
co2_ppm = scd30.CO2
print("CO2: {} ppm".format(co2_ppm))
# Send CO2 feed to Adafruit IO
aio.send("scd-30-co2-monitor", str(co2_ppm))
else:
print("Failed reading, trying again in {} seconds".format(SENSOR_READ_TIMEOUT))
time.sleep(SENSOR_READ_TIMEOUT)
But I still get the same error. I did try using the Adafruit_IO folder from Adafruit_IO_Python_master but instead I got:
File "/lib/Adafruit_IO/__init__.py", line 21, in <module>
File "/lib/Adafruit_IO/client.py", line 24, in <module>
ImportError: no module named 'platform'
The Adafruit_io folder I am using is the one from the CircuitPython 8 bundle.