jeudi 21 décembre 2023

Orange Pi 5 + Serial port UART1

Place the file rockchip-rk3588-uart1-m1.dtbo in /boot/dtb/rockchip/overlay

~$sudo cp rockchip-rk3588-uart1-m1.dtbo /boot/dtb/rockchip/overlay

Edit armbianEnv.txt

~$sudo nano /boot/armbianEnv.txt

verbosity=1
bootlogo=false
overlay_prefix=rockchip-rk3588
overlays=uart1-m1

fdtfile=rockchip/rk3588s-orangepi-5.dtb

....

~$sudo reboot

~$ls /dev/ttyS*

/dev/ttyS1  /dev/ttyS9

~$screen /dev/ttyS1 1200

You should see teleinfo stream

(Ctrl A k y to exit from screen)


You can also add a link in /dev/serial/by-id to allow some software like domoticz to "view" the port:

~sudo ln -s /dev/ttyS1 /dev/serial/by-id/ttyS1_GPIO

mardi 19 décembre 2023

Orange Pi 5 + GPIO + Domoticz

I want to use GPIO's to manage relays with Domoticz and my Orange Pi 5:

Orange Pi 5 GPIO:



Below the outputs I want to manage:

Warning: wiringPi use wPi# but sysfs use GPIO#

That's the trick...


Go to domoticz home directory /home/domoticz or pi or dietpi etc.

- Create a script named sysfs.sh (or what ever) in domoticz directory

~$nano ~/domoticz/sysfs.sh

- Add this:

#! /bin/sh
#-----------------------------------------------------------------------------
# Init sysfs GPIO ports
#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
# unexport if needed
#
#echo 6 > /sys/class/gpio/unexport
#echo 9 > /sys/class/gpio/unexport
#echo 10 > /sys/class/gpio/unexport
#echo 13 > /sys/class/gpio/unexport
#echo 15 > /sys/class/gpio/unexport
#echo 16 > /sys/class/gpio/unexport

#-----------------------------------------------------------------------------
# export
#
echo 29 > /sys/class/gpio/export
echo 59 > /sys/class/gpio/export
echo 58 > /sys/class/gpio/export
echo 35 > /sys/class/gpio/export
echo 52 > /sys/class/gpio/export
echo 92 > /sys/class/gpio/export



#-----------------------------------------------------------------------------
# Set direction = out
#
echo out > /sys/class/gpio/gpio29/direction
echo out > /sys/class/gpio/gpio59/direction
echo out > /sys/class/gpio/gpio58/direction
echo out > /sys/class/gpio/gpio35/direction
echo out > /sys/class/gpio/gpio52/direction
echo out > /sys/class/gpio/gpio92/direction

#-----------------------------------------------------------------------------
# Set active_low = 0 (false)
#
echo 0 > /sys/class/gpio/gpio29/active_low
echo 0 > /sys/class/gpio/gpio59/active_low
echo 0 > /sys/class/gpio/gpio58/active_low
echo 0 > /sys/class/gpio/gpio35/active_low
echo 0 > /sys/class/gpio/gpio52/active_low
echo 0 > /sys/class/gpio/gpio92/active_low

#-----------------------------------------------------------------------------
# Set edges = none if needed
#
# echo none > /sys/class/gpio/gpio4/edge
#-----------------------------------------------------------------------------

# Set pullups if needed
#
# raspi-gpio set 4 pu
# raspi-gpio set 11 dl
# raspi-gpio set 12 dl
#-----------------------------------------------------------------------------

- Save
- Make the file executable

chmod +x ~/domoticz/sysfs.sh

- Two options (many in fact)
1- Execute this script in the rc.local file:

~$sudo nano /etc/rc.local

- Add at the end of the script and before exit 0 this line

/home/domoticz/sysfs.sh
exit 0

2- Modify /etc/systemd/system/domoticz.service (better):

- Add the line : ExecStartPre=/home/domoticz/sysfs.sh before starting Domoticz

~$sudo nano /etc/systemd/system/domoticz.service

[Unit]
      Description=domoticz_service
      After=network-online.target
[Service]
#      User=dietpi
#      Group=dietpi
#      PermissionsStartOnly=true
      WorkingDirectory=/home/pi5/dev-domoticz
      PIDFILE=/var/run/domoticz/domoticz.pid
#Kill rtl_433 (domoticz cant start if it's already started)
      ExecStartPre=-/usr/bin/killall -q rtl_433
#      ExecStartPre=/usr/bin/install -d -m 0700 -o pi5 -g PI5 /var/run/domoticz
      ExecStartPre=setcap 'cap_net_bind_service=+ep' /home/pi5/dev-domoticz/domoticz
#GPIO
      ExecStartPre=/home/domoticz/sysfs.sh
      
#Start domoticz
      ExecStart=/home/pi5/dev-domoticz/domoticz -www 80 -sslwww 0 -pidfile /var/run/domoticz/domoticz.pid
      Restart=on-failure
      RestartSec=1m
      #StandardOutput=null
[Install]
      WantedBy=multi-user.target


- Reboot

- Verify GPIO exports
~$sudo gpio exports

You should receive something like that:


GPIO Pins exported:
   0(29): out  1  none
   0(35): out  1  none
   0(52): out  1  none
   0(58): out  1  none
   0(59): out  1  none


In Domoticz -> 
    Setup -> 
        Hardware -> 
            Add New hardware of the type ‘Generic sysfs GPIO’.


        Then add new devices from unused in "Generic GPIO" (the name you give to your new hardware)

Don't forget to add those devices to your user !





lundi 27 novembre 2023

Orange PI 5 + Domoticz + rtl_433

Compile dev_domoticz from sources :

https://www.domoticz.com/wiki/Build_Domoticz_from_source


Install rtl_433 :

sudo apt-get install rtl-433

sudo rtl_433


Using systemd service:


sudo nano /etc/systemd/system/domoticz.service



[Unit]

      Description=domoticz_service

      After=network-online.target

[Service]

#      User=dietpi

#      Group=dietpi

#      PermissionsStartOnly=true

      WorkingDirectory=/home/pi5/dev-domoticz

      PIDFILE=/var/run/domoticz/domoticz.pid

      ExecStartPre=-/usr/bin/killall -q rtl_433

#      ExecStartPre=/usr/bin/install -d -m 0700 -o pi5 -g PI5 /var/run/domoticz

      ExecStartPre=setcap 'cap_net_bind_service=+ep' /home/pi5/dev-domoticz/domoticz

      ExecStart=/home/pi5/dev-domoticz/domoticz -www 80 -sslwww 443 -pidfile /var/run/domoticz/domoticz.pid

      Restart=on-failure

      RestartSec=1m

      #StandardOutput=null

[Install]

      WantedBy=multi-user.target


sudo systemctl enable domoticz

sudo systemctl daemon-reload

sudo systemctl restart domoticz

sudo service domoticz status


● domoticz.service - domoticz_service

     Loaded: loaded (/etc/systemd/system/domoticz.service; enabled; vendor preset: enabled)

     Active: active (running) since Mon 2023-11-27 09:49:56 CET; 3h 26min ago

    Process: 64410 ExecStartPre=/usr/bin/killall -q rtl_433 (code=exited, status=1/FAILURE)

    Process: 64411 ExecStartPre=setcap cap_net_bind_service=+ep /home/pi5/dev-domoticz/domoticz (code=exited, status=0/SUC>

   Main PID: 64412 (domoticz)

      Tasks: 27 (limit: 4149)

     Memory: 27.4M

        CPU: 25min 18.524s

     CGroup: /system.slice/domoticz.service

             ├─64412 /home/pi5/dev-domoticz/domoticz -www 80 -sslwww 443 -pidfile /var/run/domoticz/domoticz.pid

             ├─64440 sh -c "rtl_433 -F json -M newmodel -C si -M level  2>/dev/null"

             └─64441 rtl_433 -F json -M newmodel -C si -M level


Orange PI 5 + GPIO

sudo apt-get update
sudo apt-get install -y git
git clone https://github.com/orangepi-xunlong/wiringOP.git
cd wiringOP
sudo ./build clean
sudo ./build 

If you got something like :

Oops: Unable to determine board revision from /etc/orangepi-release or /etc/armbian-release.

 -> Unable to open /etc/orangepi-release or /etc/armbian-release.

 ->  You'd best google the error to find out why.


echo "BOARD=orangepi5" | sudo tee /etc/orangepi-release

gpio readall
 +------+-----+----------+--------+---+   OPI5   +---+--------+----------+-----+------+
 | GPIO | wPi |   Name   |  Mode  | V | Physical | V |  Mode  | Name     | wPi | GPIO |
 +------+-----+----------+--------+---+----++----+---+--------+----------+-----+------+
 |      |     |     3.3V |        |   |  1 || 2  |   |        | 5V       |     |      |
 |   47 |   0 |    SDA.5 |     IN | 1 |  3 || 4  |   |        | 5V       |     |      |
 |   46 |   1 |    SCL.5 |     IN | 1 |  5 || 6  |   |        | GND      |     |      |
 |   54 |   2 |    PWM15 |     IN | 1 |  7 || 8  | 0 | IN     | RXD.0    | 3   | 131  |
 |      |     |      GND |        |   |  9 || 10 | 0 | IN     | TXD.0    | 4   | 132  |
 |  138 |   5 |  CAN1_RX |     IN | 1 | 11 || 12 | 1 | IN     | CAN2_TX  | 6   | 29   |
 |  139 |   7 |  CAN1_TX |     IN | 1 | 13 || 14 |   |        | GND      |     |      |
 |   28 |   8 |  CAN2_RX |     IN | 1 | 15 || 16 | 1 | IN     | SDA.1    | 9   | 59   |
 |      |     |     3.3V |        |   | 17 || 18 | 1 | IN     | SCL.1    | 10  | 58   |
 |   49 |  11 | SPI4_TXD |     IN | 1 | 19 || 20 |   |        | GND      |     |      |
 |   48 |  12 | SPI4_RXD |     IN | 1 | 21 || 22 | 1 | IN     | GPIO2_D4 | 13  | 92   |
 |   50 |  14 | SPI4_CLK |     IN | 1 | 23 || 24 | 1 | IN     | SPI4_CS1 | 15  | 52   |
 |      |     |      GND |        |   | 25 || 26 | 1 | IN     | PWM1     | 16  | 35   |
 +------+-----+----------+--------+---+----++----+---+--------+----------+-----+------+
 | GPIO | wPi |   Name   |  Mode  | V | Physical | V |  Mode  | Name     | wPi | GPIO |
 +------+-----+----------+--------+---+   OPI5   +---+--------+----------+-----+------+


vendredi 9 juin 2023

Orange Pi 5 - Transfert System and boot ... EASY

From this thread : https://forum.armbian.com/topic/27048-not-booting-to-system-on-nvme/

Thanx to robnielsen


Deleted partition on NVMe (if needed)

gdisk /dev/nvme0n1

 

d

1

d


Copied SD card to NVMD

cat /dev/mmcblk1 > /dev/nvme0n1


Could take some time 


Powered off the Orange Pi 5, removed the SD card and then powered it back on and it booted from the NVMe. 


Then resized the filesystem

 /usr/lib/armbian/armbian-resize-filesystem start

 

Now I have some thing like:

$ df -H
Filesystem      Size  Used Avail Use% Mounted on
udev            8.3G     0  8.3G   0% /dev
tmpfs           1.7G   10M  1.7G   1% /run
/dev/nvme0n1p2  254G  5.7G  245G   3% /
tmpfs           8.3G     0  8.3G   0% /dev/shm
tmpfs           5.3M  4.1k  5.3M   1% /run/lock
tmpfs           8.3G     0  8.3G   0% /tmp
/dev/nvme0n1p1  269M  158M  111M  59% /boot
/dev/zram1       51M  4.8M   43M  11% /var/log
tmpfs           1.7G     0  1.7G   0% /run/user/1000

$ mount | grep /dev/n
/dev/nvme0n1p2 on / type ext4 (rw,noatime,errors=remount-ro,commit=600)
/dev/nvme0n1p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=936,iocharset=utf8,shortname=mixed,errors=remount-ro)
/dev/nvme0n1p2 on /var/log.hdd type ext4 (rw,noatime,errors=remount-ro,commit=600)


 

lundi 22 mai 2023

OrangePi 3 LTS + USB DAC + MPD (from sources) + Resampling and Equalizer

 I've buy this DAC :

A CMEDIA CM6631A

HIFI CM6631A DAC Board USB Digital interface 32 / 24Bit 192k USB To I2S/SPDIF Coaxial Output Audio Decoder Analog Converter


mercredi 10 mai 2023

Howto delete file or folder with dot at the end of the name ...

Open command prompt and use rd :

 rd /s "\\?\C:\Documents and Settings\User\Desktop\Annoying Folder..."

jeudi 13 avril 2023

433 Mhz switch command with GPIO with Raspberry Pi 3

Original thread :


Hardware :

Install g++ and Git :

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc g++ make git

Install and compile 433Utils :

git clone --recursive https://github.com/ninjablocks/433Utils.git 
cd 433Utils/RPi_utils 
make all

sudo ./RFSniffer

... Then press the corresponding buttons on the remote control. The code received is then displayed (for me, it is 5510417 for on and 5510420 for off). 
After reading the code, you can also remove the 433Mhz receiver if you mind.

sudo nano control.cpp

Put in it :

#include "../rc-switch/RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
int PIN = 0; // cf. wiring Pi pinout
int codeSocketDon = 5510417;
int codeSocketDoff = 5510420;

if (wiringPiSetup() == -1) return 1;

RCSwitch mySwitch = RCSwitch();
mySwitch.enableTransmit(PIN);

if (atoi(argv[1]) == 1) { // you can set your own conditions here
    mySwitch.send(codeSocketDon, 24);
} else {
    mySwitch.send(codeSocketDoff, 24);
}
return 0;
}

Then compile :

g++ -DRPI ../rc-switch/RCSwitch.cpp control.cpp -o control -lwiringPi

Turn ON :

sudo ./control 1

Turn OFF :

sudo ./control 0