SEN-CCS811
ラズパイとの接続
$ i2cdetect -y 10123456789abcdef00: -- -- -- -- -- -- -- -- -- -- -- -- --10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --50: -- -- -- -- -- -- -- -- -- -- 5a -- -- -- -- --60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --70: -- -- -- -- -- -- -- --
$ sudo apt update$ sudo apt upgrade -y
$ cd ~$ sudo pip3 install --upgrade adafruit-python-shell$ wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py$ sudo python3 raspi-blinka.py
$ ls /dev/i2c* /dev/spi*
/dev/i2c-1 /dev/spidev0.0 /dev/spidev0.1
#!/usr/bin/env python# -*- coding: utf-8 -*-import boardimport digitalioimport busioprint("Hello blinka!")# Try to great a Digital inputpin = digitalio.DigitalInOut(board.D4)print("Digital IO ok!")# Try to create an I2C devicei2c = busio.I2C(board.SCL, board.SDA)print("I2C ok!")# Try to create an SPI devicespi = busio.SPI(board.SCLK, board.MOSI, board.MISO)print("SPI ok!")print("done!")blinkatest.py
$ python blinkatest.py
Hello blinka!Digital IO ok!I2C ok!SPI ok!done!
$ sudo pip3 install adafruit-circuitpython-ccs811
core_freq=500core_freq_min=500i2c_arm_baudrate=10000
#!/usr/bin/env python# -*- coding: utf-8 -*-import timeimport boardimport adafruit_ccs811i2c = board.I2C()# uses board.SCL and board.SDAccs811 = adafruit_ccs811.CCS811(i2c)# Wait for the sensor to be readywhile not ccs811.data_ready: passwhile True: print("CO2: {} PPM, TVOC: {} PPB".format(ccs811.eco2, ccs811.tvoc)) time.sleep(1)ccs811test.py
$ sudo python3 ccs811test.py
CO2: 400 PPM, TVOC: 0 PPBCO2: 400 PPM, TVOC: 128 PPBCO2: 405 PPM, TVOC: 128 PPBCO2: 408 PPM, TVOC: 1 PPBCO2: 33173 PPM, TVOC: 0 PPBCO2: 405 PPM, TVOC: 0 PPBCO2: 33254 PPM, TVOC: 13 PPBCO2: 33206 PPM, TVOC: 5 PPBCO2: 425 PPM, TVOC: 33023 PPBCO2: 417 PPM, TVOC: 2 PPBCO2: 422 PPM, TVOC: 3 PPBCO2: 33216 PPM, TVOC: 7 PPBCO2: 518 PPM, TVOC: 17 PPBCO2: 33254 PPM, TVOC: 13 PPBCO2: 33224 PPM, TVOC: 8 PPBCO2: 443 PPM, TVOC: 6 PPBCO2: 438 PPM, TVOC: 130 PPBCO2: 438 PPM, TVOC: 5 PPB……
続きを読むには、コメントの利用規約に同意し「アイティメディアID」および「ITmedia NEWS アンカーデスクマガジン」の登録が必要です
カテゴリー
関連記事
ホット記事