Raspberry Pi ZeroにOLED をつけて、statusを表示する。
Raspberry Pi Zeroは、ネットワークi/fがないため、入手して大分時間がたちまして、棚上げ状態が続く。
USB WiFiを追加し、さらにOLEDでipアドレスなどのstatusが表示できれば、使い道が増えると考えた。
試行錯誤の末、下記のものができた。
オスのUSB追加で、PCに直挿入
(2は共存できないため、不要!)
USB WiFiでネットワークに接続
シリアル接続ための端子を用意
OLEDでstatusの表示
BMP280で環境温度と気圧を収集
開発環境構築
まず、オスのUSB追加で、PCに直挿入できるように。
(参考: Raspberry Pi (8) USB to PC)
PCに直挿入、sshで操作らくらくと調子がいいだけと、
しかしここで、MicroUSBにWiFiドングリをさして見たら、認識しない!共存できないと発見した。
仕方なくシリアル接続ための端子を追加した。
PIXEL (Raspberry OS)は、USBメモリに書き込んで、古いi386のPCでも活用でするもの。
静音PCでPIXELを動かすと、800×600の解像度になってしまう。ちと狭い。変更する方法はあるのかな…。 _PIXEL for PC and Mac – Raspberry Pi のコメント欄で、xrandr とやらを使って解像度を変更する例が紹介されてる。
pi@raspberrypi:~ $ sudo xrandr
Screen 0: minimum 320 x 200, current 640 x 480, maximum 2048 x 2048
LVDS1 connected 640x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
640x480 63.10*+ 59.94
VGA1 connected 640x480+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
1280x1024 60.02 + 75.02
1024x768 75.08 70.07 60.00
800x600 72.19 75.00 60.32
640x480 75.00 72.81 60.00*
720x400 70.08
pi@raspberrypi:~/Adafruit_Nokia_LCD $ cd examples/
pi@raspberrypi:~/Adafruit_Nokia_LCD/examples $ python shapes.py
Traceback (most recent call last):
File "shapes.py", line 60, in <module>
disp = LCD.PCD8544(DC, RST, spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE, max_speed_hz=4000000))
File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/SPI.py", line 42, in __init__
IOError: [Errno 2] No such file or directory
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.49.tar.gz
tar xf bcm2835-1.49.tar.gz
cd bcm2835-1.49
./configure
make
sudo make check
sudo make install
サンプルコード
サンプルコードの取得
cd ~
git clone https://github.com/leon-anavi/raspberrypi-matrix-led-max7219.git