Enviroを使ってみたい

スポンサーリンク
スポンサーリンク

Enviro

Pimoroniにラズパイ用のEnviroという環境計があった。

Enviro for Raspberry Pi - Enviro + Air Quality
Monitor your world with Enviro and Enviro + Air Quality for Raspberry Pi! There's a whole bunch of fancy environmental sensors on these boards, and a gorgeous l...

ちょうど湿度計がほしいなと思っていたところだったので買ってみた。LCDもついてて表示もできるみたい。より高機能なEnviro+もあったけど空気汚染度はいらんかなーと思ったのでEnviroにした。

スポンサーリンク

準備

買った!

ハードウェア

差し込むだけ。電源入ったまま差し込むとラズパイが再起動する。

ソフトウェア

githubからクローンする。Enviro+用のライブラリに見えるけど多分無印でも使えるんだろーなと思う。自分はOSがLiteなのでgitのインストールから。ちなみにpythonはもとから入ってる。

sudo apt install git

そしたらライブラリをクローンしてインストール

git clone https://github.com/pimoroni/enviroplus-python
cd enviroplus-python
sudo ./install.sh

インストール終わったらいったん再起動

sudo reboot

では例を動かしてこー。

スポンサーリンク

計測

例を動かしてみる。

cd ./enviroplus-python/examples

移動したら

python weather.py

で実行したらエラー出た。

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/weather.py", line 4, in <module>
from bme280 import BME280
ModuleNotFoundError: No module named 'bme280'

うーむ?ライブラリがインポートできてないっぽい?

cd ./Pimoroni/enviroplus/examples

でこちらのやつ試してみても一緒。

Enviro+ No module named bme280
Same issue, I think something is messed up in the repository.

Enviro+ bme280 Library import in Weather.py
I have just received an Enviro+ and following the “Getting started” instructions. I am using a Pi Zero running Raspbian Jessie. When I try to run the weather.py...

とかで挙げられてる

pip install pimoroni-bme280==0.0.2

を試すもpip入ってなかった。

sudo apt install python3-pip

でインストールして再度bme280を入れると

i2cdevice-0.0.7

も一緒に入って成功。もっかい例実行しようとすると

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/weather.py", line 7, in <module>
from smbus2 import SMBus
ModuleNotFoundError: No module named 'smbus2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/weather.py", line 9, in <module>
from smbus import SMBus
ModuleNotFoundError: No module named 'smbus'

またエラー。なんか他のも入ってなさそうなんで

sudo apt install python3-numpy python3-smbus python3-pil python3-setuptools

としてインストール。いい加減動けと念じつつ再度実行すると

weather.py

2021-11-28 11:00:46.773 INFO weather.py - Print readings from the BME280 weather sensor.

Press Ctrl+C to exit!


2021-11-28 11:00:46.925 INFO Temperature: 26.08 *C
Pressure: 666.04 hPa
Relative humidity: 83.65 %

2021-11-28 11:00:47.937 INFO Temperature: 30.06 *C
Pressure: 1026.72 hPa
Relative humidity: 29.57 %

2021-11-28 11:00:48.950 INFO Temperature: 30.06 *C
Pressure: 1026.73 hPa
Relative humidity: 29.55 %

2021-11-28 11:00:49.962 INFO Temperature: 30.07 *C
Pressure: 1026.75 hPa
Relative humidity: 30.01 %

できた!一秒ごとに気温・気圧・湿度が表示される。Ctrl+Cで停止。こちらの温度はラズパイ本体の熱がプラスされてしまうのでちょっと高いらしい。

compensated-temperature.py

それを校正した温度を表示できるのが

python compensated-temperature.py

すると

2021-11-28 11:05:47.132 INFO Compensated temperature: 20.82 *C
2021-11-28 11:05:48.139 INFO Compensated temperature: 26.11 *C
2021-11-28 11:05:49.146 INFO Compensated temperature: 26.16 *C
2021-11-28 11:05:50.154 INFO Compensated temperature: 26.25 *C
2021-11-28 11:05:51.161 INFO Compensated temperature: 26.24 *C
2021-11-28 11:05:52.168 INFO Compensated temperature: 26.24 *C
2021-11-28 11:05:53.176 INFO Compensated temperature: 26.23 *C
2021-11-28 11:05:54.183 INFO Compensated temperature: 26.23 *C
2021-11-28 11:05:55.190 INFO Compensated temperature: 26.12 *C
2021-11-28 11:05:56.198 INFO Compensated temperature: 26.16 *C

おー。合ってるのか分からんが現実的な数字に変わった。

light.py

光センサーの例を実行する。

python light.py

だがしかし、またエラーが出る。

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/light.py", line 7, in <module>
from ltr559 import LTR559
ModuleNotFoundError: No module named 'ltr559'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/light.py", line 10, in <module>
import ltr559
ModuleNotFoundError: No module named 'ltr559'

これ多分、各種センサーの全ライブラリが入ってない気がする。ぐぐると

Enviro+ bme280 Library import in Weather.py
Just a quick add as I have just hacked my new Enviro+ into existance and in case any other newbies are struggling. Don’t use the git clone approach that is in ...

No Module error
Just pushed an attempted fix. In your enviroplus-python github folder run: git pull origin master sudo ./install.sh And see if that fixes the missing requirem...

python3 -m pip install pimoroni-bme280 pms5003 ltr559 st7735 ads1015

とか

sudo pip install pimoroni-bme280 pms5003 ltr559 st7735 ads1015

な感じでインストールする。そんでもっかい例を実行すると

2021-11-28 11:22:45.990 INFO Light: 72.89 Lux
Proximity: 00.00

2021-11-28 11:22:47.000 INFO Light: 73.18 Lux
Proximity: 00.00

2021-11-28 11:22:48.010 INFO Light: 72.89 Lux
Proximity: 00.00

2021-11-28 11:22:49.020 INFO Light: 13.39 Lux
Proximity: 23.00

2021-11-28 11:22:50.030 INFO Light: 12.21 Lux
Proximity: 30.00

光の値と、その値から近接性を計算してくれる。

LCD

Enviroには0.96インチのLCDがついている。これにいろんな値を表示できるみたい。

python lcd.py

とやると

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/lcd.py", line 5, in <module>
from fonts.ttf import RobotoMedium as UserFont
ModuleNotFoundError: No module named 'fonts'

またエラー。いい加減にしてくれやと思いつつ

pip3 install font-roboto

してまた実行すると

できたー!

all-in-one.py

LCD使って全部表示できるようにする。

python all-in-one.py

例によってエラーが出る。

Traceback (most recent call last):
File "/home/pi/Pimoroni/enviroplus/examples/all-in-one.py", line 16, in <module>
from enviroplus import gas
ModuleNotFoundError: No module named 'enviroplus'

そもそも俺が間違っとるんか、チュートリアルのママやってんだけどなぁ。

pip install enviroplus

表示された!光センサーをタッチすると表示が変わる。ただガスセンサーはついてないのでその表示になると動作が停止する。つーことで

python all-in-one-enviro-mini.py

とすることで

できた。

noise~

ついでに。PortAudio入ってないエラーは

sudo apt-get install portaudio19-dev

そんで

python noise-profile.py

だと

noise-profile.py – Get a simple noise profile.

This example grabs a basic 3-bin noise profile of low, medium and high frequency noise, plotting the noise characteristics as coloured bars.

そんで

python noise-amps-at-freqs.py

だと

noise-amps-at-freqs.py – Measure amplitude from specific frequency bins

This example retrieves the median amplitude from 3 user-specified frequency ranges and plots them in Blue, Green and Red on the Enviro+ display.

As you play a continuous rising tone on your phone, you should notice peaks that correspond to the frequency entering each range.

だって。dbでグラフになるのかと思ってたらそうじゃないようです。

enviro-monitorの使い方が分からんので、とりまここまで!

コメント

タイトルとURLをコピーしました