Raspberry GPIO's Setup: Difference between revisions

From WLPS Wiki
Jump to navigation Jump to search
(Created page with "ASL GPIO wiki Lets consider we are going to use GPIO 17 (Pin 11) for COS input GPIO 27 (Pin 13) for PTT Output = Install wiringpi = repeater@repeater:~$ sudo apt-get i...")
 
mNo edit summary
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
ASL GPIO wiki
= At this moment only PTT is working, COR is a work in progress =


Lets consider we are going to use
Lets consider we are going to use


GPIO 17 (Pin 11) for COS input  
GPIO 17 (Pin 11) for COR input  


GPIO 27 (Pin 13) for PTT Output
GPIO 27 (Pin 13) for PTT Output


= Install wiringpi =
= Install wiringpi =


  repeater@repeater:~$ sudo apt-get install git-core
  sudo apt-get install git-core
  repeater@repeater:~$ sudo git clone https://github.com/WiringPi/WiringPi.git /opt/wiringpi
  sudo git clone https://github.com/WiringPi/WiringPi.git /opt/wiringpi
  repeater@repeater:~$ cd /opt/wiringpi
  cd /opt/wiringpi
  repeater@repeater:~$ sudo ./build
  sudo ./build


= Create an initialization file =
= Create an initialization file =
Line 19: Line 18:
Create the following file using nano:
Create the following file using nano:


  repeater@repeater:~$ sudo nano /usr/local/sbin/Init-GPIO.sh
  sudo nano /usr/local/sbin/Init-GPIO.sh


Add the following  code to the file
Add the following  code to the file
Line 25: Line 24:
  #!/bin/bash
  #!/bin/bash
  #script name - Init_GPIO
  #script name - Init_GPIO
  # COS Input
  # COR Input
  gpio -g mode 17 in # makes gpio 17 pin 11 on Raspberry pi 2/3 as input
  gpio -g mode 17 in # makes gpio 17 pin 11 on Raspberry pi 2/3 as input
  gpio -g mode 17 up # activates pull-up
  gpio -g mode 17 up # activates pull-up
Line 34: Line 33:
After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.
After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.


= Create the COS monitoring script =
= Create the COR monitoring script =


Create the following file using nano:
Create the following file using nano:


  repeater@repeater:~$ sudo nano /usr/local/sbin/COS-wfi.sh
  sudo nano /usr/local/sbin/COR-wfi.sh


  #!/bin/bash
  #!/bin/bash
Line 47: Line 46:
   # wait int pin to go low
   # wait int pin to go low
   gpio -g wfi 17 both
   gpio -g wfi 17 both
     COS=$(gpio -g read 17)
     COR=$(gpio -g read 17)
     if [ "$COS" = "0" ]; then
     if [ "$COR" = "0" ]; then
       gpio -g write 27 1
       gpio -g write 27 1
       echo COS GPIO low/closed
       echo COR GPIO low/closed
     else
     else
       gpio -g write 27 0
       gpio -g write 27 0
       echo COS GPIO high/open
       echo COR GPIO high/open
     fi
     fi
  done
  done
Line 63: Line 62:
now create the following file using nano:
now create the following file using nano:


  repeater@repeater:~$ sudo nano /usr/local/sbin/PTT-GPIO-high.sh
  sudo nano /usr/local/sbin/PTT-GPIO-high.sh


Add the following lines to the file, in this example I am using GPIO 27 which is assigned to pin 13 on a Raspberry Pi Model 2/3.
Add the following lines to the file, in this example I am using GPIO 27 which is assigned to pin 13 on a Raspberry Pi Model 2/3.
Line 74: Line 73:
Next create the following file using nano:
Next create the following file using nano:


  repeater@repeater:~$ sudo nano /usr/local/sbin/PTT-GPIO-low.sh
  sudo nano /usr/local/sbin/PTT-GPIO-low.sh


Add the following lines to the file, in this example I am using GPIO 27 which is assigned to pin 13 on a Raspberry Pi Model 2/3.
Add the following lines to the file, in this example I am using GPIO 27 which is assigned to pin 13 on a Raspberry Pi Model 2/3.
Line 83: Line 82:
After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.
After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.


= Make the Init-GPIO and COS-wfi.sh scripts run at startup =
= Make the Init-GPIO and COR-wfi.sh scripts run at startup =


you have to add a line to the rc.local file.
you have to add a line to the rc.local file.


  repeater@repeater:~$ sudo nano /etc/rc.local
  sudo nano /etc/rc.local


Before the '''exit 0''' line you have to add:
Before the '''exit 0''' line you have to add:


# For AllStarLink
  /usr/local/sbin/Init-GPIO.sh
  /usr/local/sbin/Init-GPIO.sh
  /usr/local/sbin/COS-wfi.sh
  /usr/local/sbin/COR-wfi.sh


After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.
After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.
= Set permissions to execute scripts =
cd /usr/local/sbin
sudo chmod +x Init-GPIO.sh
sudo chmod +x COR-wfi.sh
sudo chmod +x PTT-GPIO-high.sh
sudo chmod +x PTT-GPIO-low.sh
= Test GPIO pins =
You can test PTT output by manually setting High or Low the PTT pin.
High:
sudo /usr/local/sbin/PTT-GPIO-high.sh
Low:
sudo /usr/local/sbin/PTT-GPIO-low.sh


= Edit rpt.conf file =
= Edit rpt.conf file =
Line 100: Line 118:
Now use nano to edit your rpt.conf file:
Now use nano to edit your rpt.conf file:


  repeater@repeater:~$ sudo nano /etc/asterisk/rpt.conf
  sudo nano /etc/asterisk/rpt.conf


On your node number stanza, i.e. [12345] add the following line:
On your node number stanza, i.e. [12345] add the following line:
Line 113: Line 131:


After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.
After making your changes type '''<CTRL> + <X>''' and then type '''<Y>''' followed by '''<Enter>'''. You will be back to the previous menu and choose '''<Back>'''.
sudo chmod +x Init-GPIO.sh
sudo chmod +x PTT-GPIO-high.sh
sudo chmod +x PTT-GPIO-low.sh

Revision as of 16:41, 23 November 2020

At this moment only PTT is working, COR is a work in progress

Lets consider we are going to use

GPIO 17 (Pin 11) for COR input

GPIO 27 (Pin 13) for PTT Output

Install wiringpi

sudo apt-get install git-core
sudo git clone https://github.com/WiringPi/WiringPi.git /opt/wiringpi
cd /opt/wiringpi
sudo ./build

Create an initialization file

Create the following file using nano:

sudo nano /usr/local/sbin/Init-GPIO.sh

Add the following code to the file

#!/bin/bash
#script name - Init_GPIO
# COR Input
gpio -g mode 17 in # makes gpio 17 pin 11 on Raspberry pi 2/3 as input
gpio -g mode 17 up # activates pull-up
# PTT pin (Output)
gpio -g mode 27 out # makes gpio 27 pin 13 as output
gpio -g write 27 0 # Default to 0/Off

After making your changes type <CTRL> + <X> and then type <Y> followed by <Enter>. You will be back to the previous menu and choose <Back>.

Create the COR monitoring script

Create the following file using nano:

sudo nano /usr/local/sbin/COR-wfi.sh
#!/bin/bash
gpio -g mode 17 in
gpio -g mode 17 up
while [ 1=1 ]
do
  # wait int pin to go low
  gpio -g wfi 17 both
    COR=$(gpio -g read 17)
    if [ "$COR" = "0" ]; then
      gpio -g write 27 1
      echo COR GPIO low/closed
    else
      gpio -g write 27 0
      echo COR GPIO high/open
    fi
done

After making your changes type <CTRL> + <X> and then type <Y> followed by <Enter>. You will be back to the previous menu and choose <Back>.

Create Event files

now create the following file using nano:

sudo nano /usr/local/sbin/PTT-GPIO-high.sh

Add the following lines to the file, in this example I am using GPIO 27 which is assigned to pin 13 on a Raspberry Pi Model 2/3.

#!/bin/bash
gpio -g write 27 1

After making your changes type <CTRL> + <X> and then type <Y> followed by <Enter>. You will be back to the previous menu and choose <Back>.

Next create the following file using nano:

sudo nano /usr/local/sbin/PTT-GPIO-low.sh

Add the following lines to the file, in this example I am using GPIO 27 which is assigned to pin 13 on a Raspberry Pi Model 2/3.

#!/bin/bash
gpio -g write 27 0

After making your changes type <CTRL> + <X> and then type <Y> followed by <Enter>. You will be back to the previous menu and choose <Back>.

Make the Init-GPIO and COR-wfi.sh scripts run at startup

you have to add a line to the rc.local file.

sudo nano /etc/rc.local

Before the exit 0 line you have to add:

# For AllStarLink
/usr/local/sbin/Init-GPIO.sh
/usr/local/sbin/COR-wfi.sh

After making your changes type <CTRL> + <X> and then type <Y> followed by <Enter>. You will be back to the previous menu and choose <Back>.

Set permissions to execute scripts

cd /usr/local/sbin
sudo chmod +x Init-GPIO.sh
sudo chmod +x COR-wfi.sh
sudo chmod +x PTT-GPIO-high.sh
sudo chmod +x PTT-GPIO-low.sh

Test GPIO pins

You can test PTT output by manually setting High or Low the PTT pin.

High:

sudo /usr/local/sbin/PTT-GPIO-high.sh

Low:

sudo /usr/local/sbin/PTT-GPIO-low.sh

Edit rpt.conf file

Now use nano to edit your rpt.conf file:

sudo nano /etc/asterisk/rpt.conf

On your node number stanza, i.e. [12345] add the following line:

events=events12345;

Then at the end of the file add the following stanza:

[events12345]
sudo /usr/local/sbin/PTT-GPIO-high.sh = S|T|RPT_TXKEYED;
sudo /usr/local/sbin/PTT-GPIO-low.sh = S|F|RPT_TXKEYED;

After making your changes type <CTRL> + <X> and then type <Y> followed by <Enter>. You will be back to the previous menu and choose <Back>.