カテゴリー
お知らせ

備忘録 rpi-clone sd-mem 複製

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


git clone https://github.com/billw2/rpi-clone.git

cd rpi-clone/

[sdaかsdbか、デバイス名を確認]
lsblk

sudo ./rpi-clone sda -f
or
sudo ./rpi-clone sdb -f

参考文献

vogelbarsch.com/2020-08-27-140104/

カテゴリー
お知らせ

備忘録 DHT11 DHT22 3wire 温度湿度計 for RaspberryPI

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


[gitからライブラリーをダウンロードする]
sudo git clone https://github.com/adafruit/Adafruit_Python_DHT.git
[ライブラリーのドライバーをインストールする]
cd Adafruit_Python_DHT
sudo python setup.py install


余談

このライブラリーでは動作しなかった。
原因不明
https://github.com/szazo/DHT11_Python.git

参考文献

otoku-pc.com/raspberry-pi-tempcalc/

カテゴリー
お知らせ

備忘録 Flightradar on RaspberryPI

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


OSインストール

※1行づつ作業した方が良い
sudo apt update
sudo apt -y full-upgrade
sudo apt dist-upgrade -y
sudo rpi-update
sudo apt autoremove -y
sudo apt autoclean
sudo reboot

UARTシリアルコンソール

shutdonボタン

pi@raspberrypi:~ $ cat /boot/config.txt
#
#
[all]
enable_uart=1
dtoverlay=gpio-shutdown,gpio_pin=6,debounce=1000

SSD1306ディスプレイ

DHT22温度計

[I2Cを使用できるようにconfigを変更する]
$ sudo raspi-config nonint do_i2c 0

[OSにi2c関連toolをインストールする]
$ sudo apt-get install i2c-tools
$ i2cdetect -y 1

[python3用のSSD1306ライブラリーをpip3でインストール]
sudo apt-get install pip
sudo pip3 install adafruit-circuitpython-ssd1306

[gitからDHT温度センサーのライブラリーをダウンロードする]
sudo apt-get install git
sudo git clone https://github.com/adafruit/Adafruit_Python_DHT.git

[ライブラリーのドライバーをインストールする]
cd Adafruit_Python_DHT
sudo python setup.py install

[その他のライブラリーをインストール]
sudo pip3 install ipget

[RuntimeError: No access to /dev/memの対処]
sudo chown root.gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem

pi@raspberrypi:~ $ cat SSD1306output.py

import board
import digitalio
from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306
from time import sleep
import ipget
import Adafruit_DHT as DHT
SENSOR_TYPE = DHT.DHT22
DHT_GPIO = 26

DEVICE_ADR = 0x3C
DISP_WIDTH = 128
DISP_HEIGHT = 64

tempfile='/sys/class/thermal/thermal_zone0/temp'
loadfile='/proc/loadavg'


def getTemp():
    with open(tempfile, 'r') as f:
        rdata = f.readline()
        t = float(rdata)/ 1000.0
    return t

def getCpuload():
    with open(loadfile, 'r') as la:
        rdata = la.readline()
    return rdata



RESET_PIN = digitalio.DigitalInOut(board.D4)
i2c = board.I2C()
oled = adafruit_ssd1306.SSD1306_I2C(DISP_WIDTH, DISP_HEIGHT, i2c, addr=DEVICE_ADR, reset=RESET_PIN)
# Clear display.
oled.fill(0)
oled.show()


# Load a font in 2 different sizes.
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 28)
font2 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
font3 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 12)

def main():
    image = Image.new("1", (oled.width, oled.height))
    draw = ImageDraw.Draw(image)

    target_ip = ipget.ipget()
#    print(target_ip.ipaddr("wlan0"))
    wlan_ip = target_ip.ipaddr("wlan0")

    la = getCpuload()
    la_list = la.split()
    cpuload = 'loadave=' + la_list[0] + ' ' + la_list[1]
    #cpuload = 'loadave=' + la_list[0] + ' ' + la_list[1] + ' ' + la_list[2]

    t = getTemp()
    cputemp = 'cputemp = %.2f c' % (t)

    h,t = DHT.read_retry(SENSOR_TYPE, DHT_GPIO)
    Temp = "{0:0.1f}c" .format(t)
    #Temp = "Temp = {0:0.1f} deg C" .format(t)
    Humidity = "{0:0.1f}%" .format(h)
    #Humidity = "Humidity = {0:0.1f} %" .format(h)
    message = "DHT22=" + Temp + " " + Humidity
    #message = Temp + "\n" + Humidity

    draw.text((0, 0), wlan_ip, font=font3, fill=255)
    draw.text((0, 15), cputemp, font=font3, fill=255)
    draw.text((0, 30), cpuload, font=font3, fill=255)
    draw.text((0, 45), message, font=font3, fill=255)

    # Display image
    oled.image(image)
    oled.show()

    sleep(30)

    return


sleep(2)
h,t = DHT.read_retry(SENSOR_TYPE, DHT_GPIO)
sleep(2)
if __name__ == "__main__":
    while True:
        main()



pi@raspberrypi:~ $ cat displayoutput.py
from time import sleep
import ipget
import Adafruit_DHT as DHT
SENSOR_TYPE = DHT.DHT22
DHT_GPIO = 26


tempfile='/sys/class/thermal/thermal_zone0/temp'
loadfile='/proc/loadavg'


def getTemp():
    with open(tempfile, 'r') as f:
        rdata = f.readline()
        t = float(rdata)/ 1000.0
    return t

def getCpuload():
    with open(loadfile, 'r') as la:
        rdata = la.readline()
    return rdata


def main():

    target_ip = ipget.ipget()
    wlan_ip = target_ip.ipaddr("wlan0")

    la = getCpuload()
    la_list = la.split()
    cpuload = 'loadave=' + la_list[0] + ' ' + la_list[1]

    t = getTemp()
    cputemp = 'cputemp = %.2f c' % (t)

    h,t = DHT.read_retry(SENSOR_TYPE, DHT_GPIO)
    Temp = "{0:0.1f}c" .format(t)
    Humidity = "{0:0.1f}%" .format(h)
    message = "DHT22=" + Temp + " " + Humidity


    print (wlan_ip)
    print (cputemp)
    print (cpuload)
    print (message)
    print ("\r")

    sleep(10)

    return


sleep(2)
h,t = DHT.read_retry(SENSOR_TYPE, DHT_GPIO)
sleep(2)
if __name__ == "__main__":
    while True:
        main()

[cronで自動起動させる]
pi@raspberrypi:~ $ crontab -e
@reboot sleep 30 ; cd /home/pi ; /usr/bin/sudo /usr/bin/python3 SSD1306output.py



FlightAware

本家サイトに従ってインストールする

[piAwareのインストール]
pi@raspberrypi:~ $ wget https://ja.flightaware.com/adsb/piaware/files/packages/pool/piaware/f/flightaware-apt-repository/flightaware-apt-repository_1.1_all.deb
pi@raspberrypi:~ $ sudo dpkg -i flightaware-apt-repository_1.1_all.deb

pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install piaware

pi@raspberrypi:~ $ sudo piaware-config allow-auto-updates yes
pi@raspberrypi:~ $ sudo piaware-config allow-manual-updates yes

pi@raspberrypi:~ $ sudo apt-get install dump1090-fa

pi@raspberrypi:~ $ sudo reboot



[feederIDを調べる]
pi@raspberrypi:~ $ sudo piaware-status
PiAware master process (piaware) is running with pid 668.
PiAware ADS-B client (faup1090) is running with pid 701.
PiAware ADS-B UAT client (faup978) is not running (disabled by configuration settings)
PiAware mlat client (fa-mlat-client) is not running.
Local ADS-B receiver (dump1090-fa) is running with pid 403.

dump1090-fa (pid 403) is listening for ES connections on port 30005.
faup1090 is connected to the ADS-B receiver.
piaware is connected to FlightAware.

dump1090 is producing data on localhost:30005.

Your feeder ID is nnnnn-nnnn-nnnn-nnnn-nnnn (from /var/cache/piaware/feeder_id)

[パソコンのブラウザから紐付ける]
https://flightaware.com/adsb/piaware/claim/nnnnn-nnnn-nnnn-nnnn-nnnn

flightradar24

pi@raspberrypi:~ $ sudo bash -c "$(wget -O - https://repo-feed.flightradar24.com/install_fr24_rpi.sh)"
--2023-11-01 21:33:23--  https://repo-feed.flightradar24.com/install_fr24_rpi.sh
Resolving repo-feed.flightradar24.com (repo-feed.flightradar24.com)... nnnn:nnnn::nnnn:3nnnn, nnnn:nnnn::nnnn:nnnn, nnnn:nnnn::nnnn:nnnn, ...
Connecting to repo-feed.flightradar24.com (repo-feed.flightradar24.com)|nnnn:nnnn::nnnn:nnnn|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1349 (1.3K) [application/x-sh]
Saving to: ‘STDOUT’

-                   100%[===================>]   1.32K  --.-KB/s    in 0.001s

2023-11-01 21:33:25 (1.85 MB/s) - written to stdout [1349/1349]

Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:1 http://www.flightaware.com/adsb/piaware/files/packages bullseye InRelease
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Get:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Fetched 13.2 MB in 1min 2s (212 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
dirmngr is already the newest version (2.2.27-2+deb11u2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.TvNy1AKa4F/gpg.1.sh --recv-key --keyserver keyserver.ubuntu.com nnnn
gpg: key nnnn: public key "Flightradar24 <support@fr24.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
Get:2 http://repo.feed.flightradar24.com flightradar24 InRelease [17.0 kB]
Hit:3 http://archive.raspberrypi.org/debian bullseye InRelease
Hit:1 http://www.flightaware.com/adsb/piaware/files/packages bullseye InRelease
Hit:4 http://raspbian.raspberrypi.org/raspbian bullseye InRelease
Get:5 http://repo.feed.flightradar24.com flightradar24/raspberrypi-stable armhf Packages [482 B]
Fetched 17.5 kB in 10s (1,672 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  fr24feed
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,785 kB of archives.
After this operation, 5,120 kB of additional disk space will be used.
Get:1 http://repo.feed.flightradar24.com flightradar24/raspberrypi-stable armhf fr24feed armhf 1.0.41-0 [3,785 kB]
Fetched 3,785 kB in 5s (766 kB/s)
Selecting previously unselected package fr24feed.
(Reading database ... 50183 files and directories currently installed.)
Preparing to unpack .../fr24feed_1.0.41-0_armhf.deb ...
Unpacking fr24feed (1.0.41-0) ...
Setting up fr24feed (1.0.41-0) ...
You don't seem to have any dump1090 installed. On the fr24feed start it will automatically install dump1090-mutability.
Created symlink /etc/systemd/system/multi-user.target.wants/fr24feed.service → /etc/systemd/system/fr24feed.service.
error | Local time: 2023-11-01 21:37:29 +0900
error | GMT+0 time: 2023-11-01 12:37:29 +0900
______  _  _         _      _                    _              _____    ___
|  ___|| |(_)       | |    | |                  | |            / __  \  /   |
| |_   | | _   __ _ | |__  | |_  _ __  __ _   __| |  __ _  _ __`' / /' / /| |
|  _|  | || | / _` || '_ \ | __|| '__|/ _` | / _` | / _` || '__| / /  / /_| |
| |    | || || (_| || | | || |_ | |  | (_| || (_| || (_| || |  ./ /___\___  |
\_|    |_||_| \__, ||_| |_| \__||_|   \__,_| \__,_| \__,_||_|  \_____/    |_/
               __/ |
              |___/
error | Your machine should be set as GMT+0 time zone!
warning | Time zone is not set to GMT+0
[main][i]FR24 Feeder/Decoder
[main][i]Version: 1.0.41-0/generic
[main][i]Built on Oct  9 2023 12:17:06 (T202310091212/Linux/static_armel)
[main][i]Running on: raspbian="11"
[main][i]Local IP(s): 192.168.11.7,nnnn
[main][i]Copyright 2012-2023 Flightradar24 AB
[main][i]https://www.flightradar24.com
[main][i]DNS mode: PING

Welcome to the FR24 Decoder/Feeder sign up wizard!

Before you continue please make sure that:

 1 - Your ADS-B receiver is connected to this computer or is accessible over network
 2 - You know your antenna's latitude/longitude up to 4 decimal points and the altitude in feet
 3 - You have a working email address that will be used to contact you
 4 - fr24feed service is stopped. If not, please run: sudo systemctl stop fr24feed

To terminate - press Ctrl+C at any point


Step 1.1 - Enter your email address (username@domain.tld)
$:nnnn@gmail.com

Step 1.2 - If you used to feed FR24 with ADS-B data before, enter your sharing key.
If you don't remember your sharing key, you can find it in your account on the website under "My data sharing".
https://www.flightradar24.com/account/data-sharing

Otherwise leave this field empty and continue.
$:[エンター]

Step 1.3 - Would you like to participate in MLAT calculations? (yes/no)$:yes

IMPORTANT: For MLAT calculations the antenna's location should be entered very precise!

Step 3.A - Enter antenna's latitude (DD.DDDD)
$:dd.dddd

Step 3.B - Enter antenna's longitude (DDD.DDDD)
$:ddd.dddd

Step 3.C - Enter antenna's altitude above the sea level (in feet)
$:700

Using latitude: 34.6596, longitude: 136.1306, altitude: 700ft above sea level

Validating email/location information...OK

The closest airport found is ICAO:RJOO IATA:ITM near Osaka.

Latitude: dd.dddd
Longitude: ddd.dddd
Country: Japan

Flightradar24 may, if needed, use your email address to contact you regarding your data feed.

Would you like to continue using these settings?

Enter your choice (yes/no)$:yes

We have detected that you already have a dump1090 instance running. We can therefore automatically configure the FR24 feeder to use existing receiver configuration, or you can manually configure all the parameters.

Would you like to use autoconfig (*yes*/no)$:yes

Submitting form data...OK

Congratulations! You are now registered and ready to share ADS-B data with Flightradar24.
+ Your sharing key (nnnnnnn) has been configured and emailed to you for backup purposes.
+ Your radar id is nnnn, please include it in all email communication with us.
+ Please make sure to start sharing data within one month from now as otherwise your ID/KEY will be deleted.

Thank you for supporting Flightradar24! We hope that you will enjoy our Premium services that will be available to you when you become an active feeder.

To start sending data now please execute:
sudo systemctl start fr24feed

Saving settings to /etc/fr24feed.ini...OK
Installation and configuration completed!
pi@raspberrypi:~ $ sudo systemctl start fr24feed
pi@raspberrypi:~ $

ROM化

[ROM化を有効にする]
sudo raspi-config nonint enable_overlayfs
sudo raspi-config nonint enable_bootro
sudo reboot

[ROM化を無効にする]
sudo raspi-config nonint disable_overlayfs
sudo reboot
sudo raspi-config nonint disable_bootro
sudo reboot

不要なサービス停止

$ sudo systemctl stop alsa-restore.service
$ sudo systemctl stop bluetooth.service
$ sudo systemctl stop bthelper@hci0.service
$ sudo systemctl stop ModemManager.service
$ sudo systemctl stop triggerhappy.service
Warning: Stopping triggerhappy.service, but it can still be activated by:
  triggerhappy.socket
$ sudo systemctl stop triggerhappy.socket


$ sudo systemctl disable alsa-restore.service
$ sudo systemctl disable bluetooth.service
$ sudo systemctl disable bthelper@hci0.service
$ sudo systemctl disable ModemManager.service
$ sudo systemctl disable triggerhappy.service

負荷の観測

while true
do
  uptime
  sleep 300
done


while true; do   uptime ; cat /sys/class/thermal/thermal_zone0/temp;    sleep 300; done

googleスプレッドシートへのデータアップ

pi@raspberrypi:~ $ cat sendgoogle.py
from time import sleep
import ipget
import Adafruit_DHT as DHT
import requests
SENSOR_TYPE = DHT.DHT22
DHT_GPIO = 26


tempfile='/sys/class/thermal/thermal_zone0/temp'
loadfile='/proc/loadavg'


def getTemp():
    with open(tempfile, 'r') as f:
        rdata = f.readline()
        t = float(rdata)/ 1000.0
    return t

def getCpuload():
    with open(loadfile, 'r') as la:
        rdata = la.readline()
    return rdata


def main():

    target_ip = ipget.ipget()
    wlan_ip = target_ip.ipaddr("wlan0")

    la = getCpuload()
    la_list = la.split()
    cpuload = 'loadave=' + la_list[0] + ' ' + la_list[1]

    t = getTemp()
    cputemp = 'cputemp = %.2f c' % (t)
    cputemp_str = '%.2f' % (t)

    h,t = DHT.read_retry(SENSOR_TYPE, DHT_GPIO)
    Temp = "{0:0.1f}c" .format(t)
    outtemp = "{0:0.1f}" .format(t)
    Humidity = "{0:0.1f}%" .format(h)
    outhumi = "{0:0.1f}" .format(h)
#    message = "DHT22=" + Temp + " " + Humidity


    ipaddr = wlan_ip.strip("/24")
    print (ipaddr)
    print (cputemp)
    print (cpuload)
#    print (message)
    print ("\r")

    url = 'https://script.google.com/macros/s/nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn/exec?data1=' + ipaddr + '&data2=' + cputemp_str + '&data3=' + la_list[0] + '&data4=' + outtemp + '&data5=' + outhumi
    requests.get(url)
#    sleep(600)

    return


sleep(2)
h,t = DHT.read_retry(SENSOR_TYPE, DHT_GPIO)

if __name__ == "__main__":
#    while True:
    main()

[crontab編集]
*/10 * * * * cd /home/pi ; /usr/bin/sudo /usr/bin/python3 sendgoogle.py

参考文献

b.urpn.net/2020/05/31/625

bitstar.jp/blog/2021/06/02/34570/

www.momobro.com/rasbro/tips-rp-raspberry-pi-stop-service/

カテゴリー
お知らせ

備忘録 0.96inch SSD1306 I2C Display

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


[I2Cを使用できるようにconfigを変更する]
sudo raspi-config nonint do_i2c 0

[OSにi2c関連toolをインストールする]
sudo apt-get install i2c-tools

[python3用のSSD1306ライブラリーをpip3でインストール]
sudo pip3 install Adafruit-SSD1306
sudo pip3 install adafruit-circuitpython-ssd1306

[必要に応じSSD1306のサンプルプログラムをダウンロード]
git clone https://github.com/adafruit/Adafruit_Python_SSD1306


pi@raspberrypi:~ $ cat ssd1306test.py
import board
import digitalio
from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306
from time import sleep
import ipget

DEVICE_ADR = 0x3C
DISP_WIDTH = 128
DISP_HEIGHT = 64

tempfile='/sys/class/thermal/thermal_zone0/temp'


def getTemp():
    with open(tempfile, 'r') as f:
        rdata = f.readline()
        t = float(rdata)/ 1000.0
    return t



RESET_PIN = digitalio.DigitalInOut(board.D4)
i2c = board.I2C()
oled = adafruit_ssd1306.SSD1306_I2C(DISP_WIDTH, DISP_HEIGHT, i2c, addr=DEVICE_ADR, reset=RESET_PIN)
# Clear display.
oled.fill(0)
oled.show()


# Load a font in 2 different sizes.
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 28)
font2 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 14)
font3 = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 12)

def main():
    image = Image.new("1", (oled.width, oled.height))
    draw = ImageDraw.Draw(image)

    target_ip = ipget.ipget()
#    print(target_ip.ipaddr("wlan0"))
    wlan_ip = target_ip.ipaddr("wlan0")

    t = getTemp()
    cputemp = 'cputemp = %.2f c' % (t)

    draw.text((0, 0), wlan_ip, font=font3, fill=255)
    draw.text((0, 15), cputemp, font=font3, fill=255)

    # Display image
    oled.image(image)
    oled.show()

    sleep(30)

    return

if __name__ == "__main__":
    while True:
        main()


カテゴリー
お知らせ

備忘録 1.44inch LCD HAT

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


www.waveshare.com/wiki/1.44inch_LCD_HAT

wikiに倣い、config.txtを修正する。

wikiに倣い、config.txtを修正する。

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on ← コメントアウトを外す
#dtparam=i2s=on
dtparam=spi=on ← コメントアウトを外す

check whether SPI is occupied. If the terminal outputs /dev/spidev0.1 and /dev/spidev0.1, SPI is not occupied.

$ls /dev/spi*


ライブラリーのインストール
BMC2835関係のみ必要。(wikiにあるWiringPiは不要)
ここで最新を確認する。

2023年9月22日時点で バージョン1.73

#Open the Raspberry Pi terminal and run the following command
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.73.tar.gz
tar zxvf bcm2835-1.73.tar.gz
cd bcm2835-1.73/
sudo ./configure && sudo make && sudo make check && sudo make install
# For more information, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/

Pythonのライブラリーをpipインストールする
#python3
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo pip3 install RPi.GPIO
sudo pip3 install spidev

waveshare提供のサンプルプログラムをダウンロード
sudo apt-get install p7zip-full -y
wget https://files.waveshare.com/upload/f/fa/1.44inch-LCD-HAT-Code.7z
7z x 1.44inch-LCD-HAT-Code.7z
sudo chmod 777 -R 1.44inch-LCD-HAT-Code
cd 1.44inch-LCD-HAT-Code/RaspberryPi/


pi@raspberrypi:~/1.44inch-LCD-HAT-Code/RaspberryPi/python $ cat test.py
import LCD_1in44
import LCD_Config
import time
import config
import traceback
import ipget

from PIL import Image,ImageDraw,ImageFont,ImageColor
tempfile='/sys/class/thermal/thermal_zone0/temp'

def getTemp():
    with open(tempfile, 'r') as f:
        rdata = f.readline()
        t = float(rdata)/ 1000.0
    return t

target_ip = ipget.ipget()
print(target_ip.ipaddr("wlan0"))
wlan_ip = target_ip.ipaddr("wlan0")

t = getTemp()
cputemp = 'cputemp=%2.2f C' % (t)



LCD = LCD_1in44.LCD()

Lcd_ScanDir = LCD_1in44.SCAN_DIR_DFT  #SCAN_DIR_DFT = D2U_L2R
LCD.LCD_Init(Lcd_ScanDir)
LCD.LCD_Clear()

image = Image.new("RGB", (LCD.width, LCD.height), "BLACK")
#image = Image.new("RGB", (LCD.width, LCD.height), "WHITE")
draw = ImageDraw.Draw(image)
#font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 16)

draw.text((0, 0), wlan_ip, fill = "WHITE")
draw.text((0, 20), cputemp, fill = "WHITE")


LCD.LCD_ShowImage(image,0,0)
カテゴリー
お知らせ

備忘録 Arduino sketchテクニック delay()無し

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。



参考文献

qiita.com/kohey0701/items/1bcc562aed8621d3856c

カテゴリー
お知らせ

備忘録 Raspberry PI Expand Filesystem

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


ファイルシステム領域をmicroSDカードの容量に合わせてコマンドラインで拡張する方法

$ raspi-config --expand-rootfs

参考文献

takeg.hatenadiary.jp/entry/2018/09/10/160126

カテゴリー
お知らせ

備忘録 Raspberry PI nonbrand 2.8inch Rpi display

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


nonbrand 2.4/2.8inchi Rpi Display

waveshareと勘違いして買ったと言うのは内緒!

SKU MPI2801
LCD Type TFT
LCD Interface SPI
Driver IC ILI9341
Touch Screen Type Resistive
Touch Screen Controller XPT2046
Colors 65536
Backlight LED
Resolution 320240 (Pixel) Aspect Ratio 8:5 Active Area 43.2×57.6(mm) Dimensions 51.53×76.68(mm) Power Dissipation 0.12A5V
Rough Weight(Package containing) 44(g)

PIN NO. SYMBOL DESCRIPTION
1, 17 3.3V Power positive (3.3V power input)
2, 4 5V Power positive (5V power input)
3, 5, 7, 8, 10, 22 NC NC
6, 9, 14, 20, 25 GND Ground
11 TP_IRQ Touch Panel interrupt, low level while the Touch Panel detects touching
12 KEY1 Key
13 RST Reset ※GPIO27
15 LCD_RS LCD instruction control, Instruction/Data Register selection ※GPIO22
16 KEY2 KEY
18 KEY3 KEY
19 LCD_SI / TP_SI SPI data input of LCD/Touch Panel
21 TP_SO SPI data output of Touch Panel
23 LCD_SCK / TP_SCK SPI clock of LCD/Touch Panel
24 LCD_CS LCD chip selection, low active
26 TP_CS Touch Panel chip selection, low active

pi@raspberrypi:~$ uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

/boot/config.txt
enable_uart=1
dtparam=spi=on
dtoverlay=fbtft,spi0-0,ili9341,bgr,dc_pin=22,reset_pin=27,width=240,height=320,r
otate=270


pi@raspberrypi:~$ dmesg|grep spi
[    6.741665] SPI driver fb_ili9341 has no spi_device_id for ilitek,ili9341
[    6.741839] fb_ili9341 spi0.0: fbtft_property_value: width = 240
[    6.741863] fb_ili9341 spi0.0: fbtft_property_value: height = 320
[    6.741885] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[    6.741912] fb_ili9341 spi0.0: fbtft_property_value: rotate = 270
[    6.741932] fb_ili9341 spi0.0: fbtft_property_value: fps = 30
[    7.131162] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=31, spi0.0 at 32 MHz

pi@raspberrypi:~$ dmesg|grep tft
[    6.689747] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    6.741839] fb_ili9341 spi0.0: fbtft_property_value: width = 240
[    6.741863] fb_ili9341 spi0.0: fbtft_property_value: height = 320
[    6.741885] fb_ili9341 spi0.0: fbtft_property_value: buswidth = 8
[    6.741912] fb_ili9341 spi0.0: fbtft_property_value: rotate = 270
[    6.741932] fb_ili9341 spi0.0: fbtft_property_value: fps = 30

ls -la /dev/fb*


pi@raspberrypi:~$ fbset -i -fb /dev/fb0

mode "320x240"
    geometry 320 240 320 240 16
    timings 0 0 0 0 0 0 0
    nonstd 1
    rgba 5/11,6/5,5/0,0/0
endmode

Frame buffer device information:
    Name        : fb_ili9341
    Address     : 0
    Size        : 153600
    Type        : PACKED PIXELS
    Visual      : TRUECOLOR
    XPanStep    : 0
    YPanStep    : 0
    YWrapStep   : 0
    LineLength  : 640
    Accelerator : No



fbset -i -fb /dev/fb1

sudo cat /dev/zero > /dev/fb0
sudo cat /dev/urandom > /dev/fb0

参考文献

arakan60.mydns.jp/04kousaku/31-0132lcdinst.html

tomosoft.jp/design/?p=4856

4oc.blogspot.com/2016/04/raspberry-pi24inch-lcd.html

bitset.jp/blog/raspi_framebuffer_1

corgi-lab.com/raspberrypi/raspberrypi-control-display/

qiita.com/Daigorian/items/96f865ace88d02236fcd

elchika.com/article/59b3c040-8254-4ecb-b89c-604447d00330/

カテゴリー
お知らせ

備忘録 Raspberry PI ROM化

 これは自分のためのメモです。
 この備忘録を見られて真似されても結構ですが、動作の保証は出来かねます。
 また、真似られたことで不測の不具合が発生しましても、私は一切の責任を負いません。


# ROM化を有効にする
sudo raspi-config nonint enable_overlayfs
#適宜 sudo raspi-config nonint enable_bootro
sudo reboot




# ROM化を無効にする
sudo raspi-config nonint disable_overlayfs
sudo reboot
#適宜sudo raspi-config nonint disable_bootro
sudo reboot
カテゴリー
お知らせ 部品セット頒布 電子工作

[頒布]JA1HHF日高OM設計 F2Aキーヤーアダプター

JA1HHF日高OMの設計です。

F2A キーヤー アダプターです。

ハンディトランシーバーのFMモードに対し、マイクへ低周波トーンを入れることでピーピーと伝送します。

写真は完成図ですが、頒布予定品は部品セットです。

取り急ぎで3台分の確認ができましたので、ご入用の方はお問い合わせください。

頒布価格は3,200円送料込み(クリックポスト)です。

反響があれば、追加で準備します。

※ JA1HHF日高OMには、許可を取っています。以前加入していた地元クラブでの製作会で使いましたが、部品を当方が準備したので余り部品が発生しました。