DS1NMA Blog

https://cago-young.tistory.com/79

 

Raspberry pi Web(flask) LED 제어 on/off

라즈베리 파이 웹으로 LED 제어 하는법 예제 (on/off ) python에 Flask 로 web 구현 아래의 주소 에서 참고 하시면 좋을듯 https://inbearblog.blogspot.com/2018/10/diy-led.html https://m.blog.naver.com/PostView.nhn?blogId=cosmosjs

cago-young.tistory.com

[목표]

1. GPIO 포트로 릴레이를 제어한다.

2. 릴레이를 멀티탭에 연결한다.

3. 웹페이지에서 전원포트를 제어한다.

    - 굳이 TAPO의 전원기기를 사용할 필요가 없다.

 

4. 온도계 장착

5. FAN 제어 장착

6. Raspberry Pi를 VPN 또는 SSH 터널링으로 연결, IC-FR5000 IP Programming을 가능하게 한다.

    --> 이론상 가능

7. Raspberry Pi의 TCP Port를 Virtual Serial Port로 사용, VXR-7000/VXR-9000의 프로그래밍을 가능하게 한다.

    --> 실현가능성 거의 없을듯..

705 Opening Screen Template.zip
0.33MB
openingpics705.zip
2.67MB

IC-705 Opening Screen을 만들어 SD메모리의 /IC-705/OpeningScreen 디렉토리에 넣고

무전기에서 부팅화면을 설정할 수 있음. (Advanced manual 참고)

 

템플릿을 사용하여 Photoshop으로 이미지를 만든 경우,

 1) 24bit BMP로 저장하고 나서

 2) 반드시, 윈도우 "그림판" (mspaint.exe)에서 열고 다시한번 저장할 것!

     - 이것 안하면 Illegral Error 발생함.

2022.05.17 작성

CS-705에서 각 항목에서 CSV파일을 로딩하여 Import 가능.

ICF 파일에는 모두 적용되어 있으며, 본인의 IC-705 세팅까지도 포함됨.

 

705_J_Rpt_211113_2.csv
0.25MB
705_Radio_List.csv
0.01MB
705_J_GPS_20220517.csv
0.01MB
Set20220517_02.icf
0.56MB

You can always check the ZUMspot/MMDVM_HS firmware releases on Andy's juribeparada / MMDVM_HS GitHub releases page: https://github.com/juribeparada/MMDVM_HS/releases. Version 1.4.12 was released earlier this week, I think on Nov 4th.

And just for reference, here are the Pi-Star commands for the scripts to update various devices via Pi-Star SSH access:

ZUMspot board connected to GPIO:

Code: Select all

sudo pistar-zumspotflash rpi

ZUMspot duplex board connected to GPIO:

Code: Select all

sudo pistar-zumspotflash rpi_duplex

ZUMspot USB key:

Code: Select all

sudo pistar-zumspotflash usb

USB-connected Libre Modem:

Code: Select all

sudo pistar-zumspotflash libre

MMDVM_HS_Hat board with 14.7456 MHz TCXO1 connected to GPIO:

Code: Select all

sudo pistar-mmdvmhshatflash hs_hat

MMDVM_HS_Hat board with 12.288 MHz TCXO connected to GPIO:

Code: Select all

sudo pistar-mmdvmhshatflash hs_hat-12mhz

MMDVM_HS_DUAL_Hat board with 14.7456 MHz TCXO connected to GPIO:

Code: Select all

sudo pistar-mmdvmhshatflash hs_dual_hat

MMDVM_HS_DUAL_Hat board with 12.288 MHz TCXO connected to GPIO:

Code: Select all

sudo pistar-mmdvmhshatflash hs_dual_hat-12mhz

Nano Hat board connected to GPIO:

Code: Select all

sudo pistar-nanohsflash nano_hs

NanoDV NPi board:

Code: Select all

sudo pistar-nanodvflash pi

NanoDV USB board:

Code: Select all

sudo pistar-nanodvflash usb

BD7KLE/BG3MDO devices:

Code: Select all

sudo pistar-mdoflash

집에 설치된 라즈베리파이 서버가 SD카드로 OS 파티션을 구성하니 시간이 지나면 갑자기 메모리가 손상되는 일이 자주 있다. 1년에 4~5번꼴로 삭제와 포맷, 재설치가 반복이 되기 때문에 현재 라즈베리파이 서버에 D-STAR Hotspot 기능과 IP-PBX, Web server, NAS Storage Server가 구동되고 있어 이런 많은 구성을 두는 나로선 상당히 피곤하다.

 

라즈베리파이4 에서는 bootloader 차원에서 USB부팅이 가능하여 앞으로는 OS를 SD카드를 사용하지 않고 USB로 연결된 안정적인 1TB HDD를 사용하기로 하여 새로 구성을 하면서 설치과정을 정리해 보았다.

Destinate : Raspberry Pi 4 4GB + DVMega Board , after installed complete Asterisk 16 and FreePBX 15

 

● Initialize

# systemctl stop serial-getty@ttyAMA0.service
# systemctl disable serial-getty@ttyAMA0.service 

# nano /boot/cmdline.txt

‘console=serial0,115200’  삭제

 

# nano /boot/config.txt

dtoverlay=disable-bt 추가

 

● Install MMDVMHost with compile

# apt-get install git screen

 

# cd /tmp                                                                                                                        → if you use HD44780

# w get https://project-downloads.drogon.net/wiringpi-latest.deb     → if you use HD44780

# sudo dpkg -i wiringpi-latest.deb                                                                     → if you use HD44780

(Raspberry Pi4 기종이 apt repository의 WiringPi에서는 지원하지 않아 최신버전 2.52 패키지로 설치해야 HD44780 출력이 동작함, http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/)

 

# cd /opt
# git clone https://github.com/g4klx/MMDVMHost.git

# git clone https://github.com/g4klx/MMDVMCal.git

# cd /opt/MMDVMHost

 

# make                                                     → if you use HD44780, don't use make

# make -f Makefile.Pi.HD44780      → if you use HD44780, execuate this command.

 

# nano MMDVM.ini

[General]

Callsign=DS1NMA

Id=450371

#Timeout=180

Duplex=1

# ModeHang=10

RFModeHang=10

NetModeHang=3

Display=HD44780

Daemon=0

 

[Info]

RXFrequency=432380000

TXFrequency=437380000

Power=1

Latitude=0.0

Longitude=0.0

Height=0

Location=Seoul, Korea

Description=DS1NMA Repeater

URL=rep.kkit.kr

 

[Log]

# Logging levels, 0=No logging

DisplayLevel=1

FileLevel=2

FilePath=/var/log/MMDVM

FileRoot=MMDVM

 

[CW Id]

Enable=1

Time=10

# Callsign=

 

[DMR Id Lookup]

File=/opt/MMDVMHost/DMRIds.dat

Time=24

 

[NXDN Id Lookup]

File=NXDN.csv

Time=24

 

[Modem]

# Port=/dev/ttyACM0

Port=/dev/ttyAMA0

#Port=\\.\COM3

# Protocol=uart

# Address=0x22

TXInvert=1

RXInvert=0

PTTInvert=0

TXDelay=100

RXOffset=0

TXOffset=0

DMRDelay=0

RXLevel=50

TXLevel=50

RXDCOffset=0

TXDCOffset=0

RFLevel=100

# CWIdTXLevel=50

# D-StarTXLevel=50

# DMRTXLevel=50

# YSFTXLevel=50

# P25TXLevel=50

# NXDNTXLevel=50

# POCSAGTXLevel=50

# RSSIMappingFile=RSSI.dat

Trace=0

Debug=0

 

[Transparent Data]

Enable=0

RemoteAddress=127.0.0.1

RemotePort=40094

LocalPort=40095

# SendFrameType=0

 

[UMP]

Enable=0

# Port=\\.\COM4

Port=/dev/ttyACM1

 

[D-Star]

Enable=1

Module=B

SelfOnly=0

AckReply=1

AckTime=750

AckMessage=0

ErrorReply=1

RemoteGateway=0

# ModeHang=10

 

[DMR]

Enable=0

Beacons=0

BeaconInterval=60

BeaconDuration=3

ColorCode=1

SelfOnly=0

EmbeddedLCOnly=0

DumpTAData=1

# Prefixes=234,235

# Slot1TGWhiteList=

# Slot2TGWhiteList=

CallHang=3

TXHang=4

# ModeHang=10

 

[System Fusion]

Enable=0

LowDeviation=0

SelfOnly=0

TXHang=4

#DGID=1

RemoteGateway=0

# ModeHang=10

 

[P25]

Enable=0

NAC=293

SelfOnly=0

OverrideUIDCheck=0

RemoteGateway=0

# ModeHang=10

 

[NXDN]

Enable=0

RAN=1

SelfOnly=0

RemoteGateway=0

# ModeHang=10

 

[POCSAG]

Enable=0

Frequency=439987500

 

[D-Star Network]

Enable=1

GatewayAddress=127.0.0.1

GatewayPort=20010

LocalPort=20011

# ModeHang=3

Debug=0

 

[DMR Network]

Enable=0

Address=44.131.4.1

Port=62031

Jitter=360

# Local=62032

Password=PASSWORD

# Options=

Slot1=1

Slot2=1

# ModeHang=3

Debug=0

 

[System Fusion Network]

Enable=0

LocalAddress=127.0.0.1

LocalPort=3200

GatewayAddress=127.0.0.1

GatewayPort=4200

# ModeHang=3

Debug=0

 

[P25 Network]

Enable=0

GatewayAddress=127.0.0.1

GatewayPort=42020

LocalPort=32010

# ModeHang=3

Debug=0

 

[NXDN Network]

Enable=0

LocalAddress=127.0.0.1

LocalPort=14021

GatewayAddress=127.0.0.1

GatewayPort=14020

# ModeHang=3

Debug=0

 

[POCSAG Network]

Enable=0

LocalAddress=127.0.0.1

LocalPort=3800

GatewayAddress=127.0.0.1

GatewayPort=4800

# ModeHang=3

Debug=0

 

[TFT Serial]

# Port=modem

Port=/dev/ttyAMA0

Brightness=50

 

[HD44780]

Rows=2

Columns=16

 

# For basic HD44780 displays (4-bit connection)

# rs, strb, d0, d1, d2, d3

Pins=11,10,0,1,2,3

 

# Device address for I2C

I2CAddress=0x20

 

# PWM backlight

PWM=0

PWMPin=21

PWMBright=100

PWMDim=16

 

DisplayClock=1

UTC=1

 

[Nextion]

# Port=modem

Port=/dev/ttyAMA0

Brightness=50

DisplayClock=1

UTC=0

#Screen Layout: 0=G4KLX 2=ON7LDS

ScreenLayout=2

IdleBrightness=20

 

[OLED]

Type=3

Brightness=0

Invert=0

Scroll=1

Rotate=0

Cast=0

 

[LCDproc]

Address=localhost

Port=13666

#LocalPort=13667

DimOnIdle=0

DisplayClock=1

UTC=0

 

[Lock File]

Enable=0

File=/tmp/MMDVM_Active.lck

 

[Mobile GPS]

Enable=0

Address=127.0.0.1

Port=7834

 

[Remote Control]

Enable=0

Port=7642

 

 

# cd /opt/MMDVMCal   

# make

 

# nano /lib/systemd/system/mmdvmhost.service

[Unit]

Description=MMDVM Host Service

After=syslog.target network.target

 

[Service]

User=root

WorkingDirectory=/opt/MMDVMHost

ExecStart=/usr/bin/screen -S MMDVMHost -D -m /opt/MMDVMHost/MMDVMHost /opt/MMDVMHost/MMDVM.ini

ExecStop=/usr/bin/screen -S MMDVMHost -X quit

 

[Install]

WantedBy=multi-user.target

 

# chmod 755 /lib/systemd/system/mmdvmhost.service
# ln -s /lib/systemd/system/mmdvmhost.service /etc/systemd/system/mmdvmhost.service

# nano /lib/systemd/system/mmdvmhost.timer

[Timer]
OnStartupSec=60

[Install]

WantedBy=multi-user.target

 

# chmod 755 /lib/systemd/system/mmdvmhost.timer

 

# ln -s /lib/systemd/system/mmdvmhost.timer /etc/systemd/system/mmdvmhost.timer

# systemctl daemon-reload

# systemctl enable mmdvmhost.timer

# reboot

 

● Install ircDDBGateway (get github repository and compile)

 

# apt-get install libwxgtk3.0-dev git build-essential

# cd ~

# git clone --depth 1 https://github.com/g4klx/ircDDBGateway.git

# cd ~/ircDDBGateway

# make

# make install

 

데몬은 /usr/bin/ircddbgatewayd

설정파일은 nano /etc/ircddbgateway

language=6
gatewayCallsign=DS1NMA
latitude=0.0
longitude=0.0
description1=Seoul

description2=Korea

url=http://rep.kkit.kr

ircddbEnabled=1

ircddbHostname=rr.openquad.net

ircddbUsername=ds1nma

ircddbPassword=

aprsEnabled=1

aprsHostname=rotate.aprs2.net

aprsPort=14580

ccsEnabled=1

ccsHost=CCS704

dextraEnabled=1

dextraMaxDongles=3

dplusEnabled=1

dplusMaxDongles=3

dplusLogin=DS1NMA

dcsEnabled=1

remoteEnabled=1

remotePassword=1

remotePort=10022

infoEnabled=1

echoEnabled=1

logEnabled=0

dratsEnabled=1

dtmfEnabled=1

repeaterBand1=B

repeaterType1=0

repeaterAddress1=127.0.0.1

repeaterPort1=20011

frequency1=437.38

offset1=0.0000

rangeKms1=0.0000

agl1=0.000

reflector1=XRF076 B

atStartup1=1

reconnect1=0

latitude1=0.000000

longitude1=0.000000

데이터폴더는 /usr/share/ircddbgateway

로그는 /var/log/ircddbgateway

 

# nano /lib/systemd/system/ircddbgatewayd.service

[Unit]

Description=D-STAR Gateway Daemon

After=network.target

 

[Service]

User=root

ExecStart=/usr/bin/ircddbgatewayd

Restart=on-abort

 

[Install]

WantedBy=multi-user.target

# systemctl daemon-reload

# systemctl start ircddbgatewayd

# systemctl status ircddbgatewayd

 

 

 

 

몇 달 전, Hotspot 및 Service Server로 사용하던 Raspberry PI 3의 OS가 포함된 SD카드가 박살나는 사태가 벌어졌다. 

Raspbian streach 기반에다가 MMDVMHost, ircddbgateway를 어렵게 설치하고 apache2, php7.1, apache tomcat 8.5, samba 등 여러 서비스를 잘 돌리고 있었는데 결국은 그렇게 되었고 이 참에 H/W도 Raspberry Pi 4 4GB 모델로 교체 및 새로운 메모리에 OS를 올리고 다시 수동으로 설치하려 하였으나 MMDVMHost와 IRCDDBGateway, DstarRepeater 등 D-Star HotSpot에 필요한 S/W의 repository가 모두 죽어서 apt-get이나 deb 패키지로 설치할 수 없어졌다.

 



모 D-STAR 유저그룹 카페에 문의를 하였으나, 어떤 분이 어려운길을 갈려고 한다고 비아냥(?) 비슷한 댓글을 달아놓으시면서 본인이 가르쳐 주겠다고 메일주소를 보내라 하셔서 답신을 드렸으나 6개월째 깜깜 무소식이라는.....

(이상하게 뭐좀 잘 안다는 아마추어무선사는 .. 공유정신이 부족하다는 생각이 듬...)

 



Pi-Star는 내가 휴대용으로 쓰는 HotSpot의 전용OS로는 이미 쓰고 있었는데, 이건 본래 기능 외에 Samba, apache2 등 다른 기능은 일절 세팅이 어렵게 만들어져서 솔직히 내 입맛에는 맞지 않았었으나.. 

 

마침 심근경색 치료 및 퇴원 후 요양중 시간이 좀 남아서 PI-Star OS를 역으로 풀어내는 방법을 찾아보았고, 제작자인 MW0Andy Taylor (MW0MWZ)가 여기저기 modify를 하면서 lock 걸어놓은 것들을 하나하나 찾아 unlock 하고 그가 modify하면서 잘못 install된 부분도 debian repository standard로 교체하면서 내 입맛에 맞도록 사용하게 다시 Modify하게 되었다. 

 

참고로 Pi-Star를 500MHz 짜리의 Raspberry Pi Zero(ZumSpot과 쌍을 이루기 위한)에서 돌릴 때보다는 Raspberry PI 4 4GB 버전이 dashboard 및 setting change 후 refresh 하는 속도가 엄청 빠르다. (거의 바로바로, 서비스 재기동이 빨라서)

 



나는 raspberry pi 4를 raspbian base에 도메인과 DDNS를 이용한 연결이 필요하기 때문에 고정IP 세팅을 해야 하며, 속도로 인해 WiFi connection이 전혀 필요치 않고 Wired network이 필요하다. 또한 Samba를 이용한 NAS, apache2 및 php7.3으로의 웹서버, Pydio Disk server, postfix 및 roundcube를 사용한 Mail Server가 반드시 필요하다.

 

아래는 pi-star 4.1 버전 이상(buster based)에서 작업한 사항이다.

 

1. Image write to SD Card

2. Log-in pi-star account on SSH

3. sudo su - root

4. rpi-rw

 

[Static IP on eth0 - internal wired network]

/etc/dhcpcd.conf

insert this value

 

interface eth0
static ip_address=10.10.86.10/24
static routers=10.10.86.254
static domain_name_servers=10.10.86.254 8.8.8.8 8.8.4.4

 

[read only and temp partition disable]

1. sudo su - root

2. rpi-rw

3. nano /etc/fstab

4. /dev/mmcblk0p1 and /dev/mmcblk0p2 change option "ro" to "rw"

5. insert remark all mounted value "tmpfs".

6. save and reboot

 

[RAID Install]

1. sudo su - root

2. rpi-rw

3. apt-get update

4. apt-get install mdadm

5. mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sda /dev/sdb  - create raid partition.

6. mkdir /media/exDrive1

7. mount /dev/md0 /media/exDrive1

8. blkid - check UUID of created and mounted raid volume

9. insert UUID and mount directory to /etc/fstab

   ex) UUID="c593a5ec-c103-414a-b93b-e154527420b3"     /media/exDrive1         ext4    defaults,noatime,rw     0       0

10. reboot

 

[root enable]

1. sudo su - root

2. rpi-rw

3. passwd root --> input password

4. /etc/ssh/sshd.conf --> permitrootlogin NO to YES

 

[Samba install]

Must erase and purge installed samba service.

1. sudo su - root

2. rpi-rw

3. apt-get update

4. apt-get purge samba samba-common smbclient

5. rm -rf /etc/samba

6. apt-get upgrade

7. apt-get install samba samba-common smbclient

8. change /etc/samba/smb.conf

   insert this value

   [global]

    wins support = yes

   [NASData]
   path=/media/exDrive1/NASData
   browseable=Yes
   writeable=Yes
   only guest=no
   guest ok = no
   create mask=0777
   directory mask=0777
   public=no

   and another share directory disable.

9. systemctl restart smbd

 

[port change default Nginx webserver - pi-star dashboard]

change value /etc/nginx/sites-enabled/pi-star

1. root login

2. nano /etc/nginx/sites-enabled/pi-star

    server {
        listen 80 default_server;  --> listen 8080 default_server;

3. nano /etc/nginx/sites-enabled/capidate-portal

    server {
        listen 80; -->  listen 8080;

4. change port number you want

5. systemctl restart nginx

6. check connect modified port.

 

[Expand root partition]

※ pi-star is made only 2GB of root partition size. As default, You can't expand root partition.

   If the root partition free space is shortage, You can't install any program. apt-get can't install it.

1. root login

2. check the space. (more space 3MB)

3. apt-get update

4. apt-get install raspi-config

5. raspi-config

6. ask account, please input pi-star. It's not pi.

7. select "7. Advanced Option"

8. select "A1.Expand Filesystem"

9. quit raspi-config

10. reboot

11. after reboot, type "df -h". You will be look expanded root patition.

 

[install apache2]

1. root login

2. apt-get install apache2

3. ps -ef | grep apache2

   root@ds1nma-dstar(rw):~# ps -ef | grep apache2
    root      4772     1  0 20:35 ?        00:00:00 /usr/sbin/apache2 -k start
    www-data  4773  4772  0 20:35 ?        00:00:00 /usr/sbin/apache2 -k start
    www-data  4774  4772  0 20:35 ?        00:00:00 /usr/sbin/apache2 -k start
    root      5036  3654  0 20:36 pts/0    00:00:00 grep --color=auto apache2

4. It's ok.

 

[upgrade php7.0 to php7.3]

* pi-star is already installed php7.0. But I need php 7.3

1. root login

2. apt-get purge php*

3. apt-get update && apt-get upgrade

4. apt-get install php php-common

5. apt-get install php-cli php-fpm php-json php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath

6. nano /etc/nginx/default.d/php.conf

   fastcgi_pass  unix:/var/run/php/php7.0-fpm.sock --> php7.3-fpm.sock

7. apt -y install libapache2-mod-php

8. a2enmod php7.3

9. systemctl restart apache2

 

[Install MariaDB]

1. root login

2. apt -y install mariadb-server mariadb-client

 

[change account and password of pi-star dashboard]

1. /var/www/.htpasswd - account id : password

2. password change only dashboard. encoded.

3. show id on dashboard - configure.php

       <form id="adminPassForm" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
    <table>
    <tr><th width="200"><?php echo $lang['user'];?></th><th colspan="3"><?php echo $lang['password'];?></th></tr>
    <tr>
    <td align="left"><b>naraymm</b></td>
    <td align="left"><label for="pass1">Password:</label><input type="password" name="adminPassword" id="pass1" onkeyup="checkPass(); return false;" size="20" />
    <label for="pass2">Confirm Password:</label><input type="password" name="adminPassword" id="pass2" onkeyup="checkPass(); return false;" />
    <br /><span id="confirmMessage" class="confirmMessage"></span></td>
    <td align="right"><input type="button" id="submitpwd" value="<?php echo $lang['set_password'];?>" onclick="submitPassform()" disabled="disabled" /></td>
    </tr>
    <tr><td colspan="3"><b>WARNING:</b> This changes the password for this admin page<br />AND the "pi-star" SSH account</td></tr>
    </table>
    </form>

 

[MMDVM recompile for solve HD44780 LCD not show]

* pi-star에 포함된 MMDVMHost를 사용해서는 HD44780 LCD가 동작하지 않는다. 새로 컴파일 하고 실행파일을 교체해야 한다.

replaced the MMDVMHost file wit a new one made like this.
1. cd ~
2. git clone https://github.com/g4klx/MMDVMHost.git
3. cd MMDVMHost
4. make clean
5. make -f Makefile.Pi.HD44780
6. rm /usr/local/bin/MMDVMHost

7. cp ./MMDVMHost /usr/local/bin/MMDVMHost (replace complied MMDVMHost)

8. reboot