mandag 2. april 2018

Winlink on an Raspberry Pi Zero W

The Winlink system is great for of the grid communications. Lugging a Windows pc with Winlink Express is OK if you are on a boat, but if you are wandering in to the wilderness by foot, it's not so great. Until recently a computer with X86 processor was our only real option, but all this has changed with the recent development with a software modem called ARDOP, now running on most RMS servers, the winlink client called PAT (by LA5NTA) and micro computers like the Raspberry Pi. Lightweight QRP transceivers like the Yaesu FT817/818 and the Elecraft KX3/2 makes e-maling from the bush even more feasible.

Here is an image of the  Raspberry Pi box I used for a short trip in the Norwegian mountains.



Thats right, 212 grams or 7.5 oz. It has been revised a couple of times since then, but you get the idea.

How does this work? you might ask. I'm not going into the details of the Winlink system, you can find that at www.winlink.org if you are not familiar with the system. The beauty of the Pat client is that it can run as a web server on you computer, or in this case Raspberry Pi Zero W, that you connect to by Wi-Fi by setting up either your phone/tablet, or the Pi as a hot spot. Giving you an easy to use web mail like interface.

So what would you need to build something like this.


Hardware


  • Raspberry Pi Zero W or 3B
  • Micro SD card
  • Some sort of power supply. This could be a 12v to usb converter if you plan on powering it with the same battery as you radio, or an usb powerbank of some sort. Please be aware og Ampere rating of the power supply, and possible RFI issues. Especially with cheap Chinese 12v to USB converters.
  • A sound card. Chep usb dongles from ebay will work just fine. Remember OTG adapter if you plan on using it on a zero.
  • A PC817 optocoupler and a 220 Ohm resistor (for ptt)
  • A 3,3v to 5v TTL level converter if you plan on using the built in serial port on the Pi for rig control. 
  • Appropriate HDMI cable, mouse and keyboard for setup. It is possible to do it without, but i wont go into detail about that here. (TIP: Google Raspberry Pi wifi first boot, and Raspberry pi SSH first boot) 
  • Some sort of enclosure is recommended, especially if you plan on bringing it out doors.
  • Connectors, plugs, wire, cable to your liking to connect the Pi to your radio.

Software.

These are the bare minimum. You could also include
For remote controlling from smartphone / tablet / pc
Some Android apps are practical.
  • Fing is useful for finding the Pi's Ip andress on the network
  • Juice SSH For remote terminal.

For more fun with this box one can add APRS with Xastir (  http://xastir.org/index.php/Main_Page  ), and ARDOP chatting (and more) with ARIM ( https://www.whitemesa.net/arim/arim.html ).


For software installation I refer you to the links above and Google.( Tip LA3QMA Is working on a piece of software to make setup as easy as pie. https://github.com/LA3QMA/PATPiBox )

Putting it together.

Once you have all the hardware collected and software installed and set up its time to play with the hardware. This is how i put it together.




I just soldered wires from the soundcard to a female trrs connector mounted on the box.
I find that using Tip for Tx and Ring for Rx audio makes things easier to remember. Sleeve is usually ground, so I'm following that standard, that leaves the second Ring for PTT.

I connect only the tip of the mic a headphones connector on the soundcard to the tx and rx line. Ground can most likely be used from anywhere. YMMW. I just connected pin 2 and 4 on the optocoupler It is important thou that the ground and ptt line is connected correctly on the PC817 optocoupler as both the diode and photo resistor side is polarized.
Then i made a TRRS to radio cable matching the connectors on my radio. See the user manual of your radio for how to hook up your cable. 
If you wish to use the Pi's internal serial port for rig control you will most likely want to shift the TTL voltage level form 3,3V to the more common 5V TTL level used in most modern rados. A cheap TTL level converter from E-bay wil do the trick.
Tip. The Pi3 and Zero W with built in bluetooth changed the name of the serial port ont the gpio pins from /dev/ttyAMA0 to /dev/ttyS0. It took me some time and frustration to realize this.




I mounted everything on a pref board that I already had cut to match the pi zero in size. If you look really close you can see that I mounted the ptt circuit on th wrong pins, and had to move it one step to the left.


I removed the connectors from the USB soundcard and soldered the wires directly on it. 




PTT and serial port connected.
For clarity I used only yellow wires ;p 

For DC power I used a connector from a old broken USB cable.
I also added an ACT led to the box. To do this add the following line to /boot/config.txt

dtparam=act_led_gpio=25

And connect a led (with an appropriate resistor ) to gpio 25

 I also connected a momentary pushbutton to the power header, to be able to (re)boot with out disconnecting the power cable, and a RCA connector to the TV-out header.











 




Software setup and testing.

Set up ARDOP:  http://la4tta.blogspot.no/2018/04/setting-up-ardop-on-raspberry-pi.html

Set up Pat: https://github.com/la5nta/pat/wiki/The-command-line-interface
For using the web gui from another device on the network, like your phone it is important to remove localhost from the http addr line. It should look like this.

"http_addr": ":8080",
 

Start ardop

Open a terminal or use ssh.
Navigate to the folder where you downloaded piardopc.
Run with " ./piardopc -p gpio "

Start Pat

From another  terminal window run "  pat interactive --http "
This starts Pat in interactive mode, and the http server.
Interactive mode lets you start and stop listeners and some other neat stuff. But that for another post.

Test from your web browser.


Open a web browser on a device connected to the same network as you pi.
go to [the ip adress of the Pi]:8080.
It should look something like this.
Try a connect just to be sure everything is working.

















Once you are satisfied that everything is working set up your phone as a Wi-Fi hot spot. You will most likely find info on how to do this in your phones user manual, or Google. :)
Connect you Pi to this hot spot using your favorite method.

Alternatively you can set up your Pi as the Hot Spot and connect you phone to that, but I prefer the other way around because once the pi is set up as a hot spot, it can connect to other WiFi networks for updates and other Internet stuff.

Once connected I use Juice to SSH into the Pi. Start screen to be able to run multiple processes in one terminal. And also to be able to retrieve these processes if disconnected for some reason.

I start rig control first.
" rigctl -m 120 -r /dev/ttyS0 -s 4800 "

Then CTRL-a c to open a new window where i start ARDOP or DIREWOLF tnc

Then CTRL-a c to open a new window where i start Pat
" pat interactive --http "

If you want you can start the ardop listener with the command
" listen ardop "  this makes Pat listen for incoming p2p sessions.

I think thats it.
Leave comments and questions below or in the Pat forum.




Setting up Ardop on an Raspberry Pi


This instructions assumes that you have already downloaded piardopc to your Pi, have an usb sound card and some piece of software that uses Ardop to send and receive data over the air. Pat and ARIM are both excellent programs.

Info from the maker here.





Open a terminal, if connected to an monitor, or SSH into the Pi. Find the Pi's IP address by using Fing on an android phone or tablet connected to the same nettwork. If using Juice ( or other terminal amulator/SSH app) on your phone use Screen to be able to run multiple processes in one terminal.



Navigate to the folder where you downloaded piardopc. Make it executable by running the command " sudo chmod 755 piardopc "


Connect an USB sound card and run the command " arecord -l "

This gives me the output:


**** List of CAPTURE Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0


Remember the card number and navigate to your home folder and open or create the file .asoundrc. " nano .asoundrc " The . in front of the file name is important.


This file should contain the following lines. Just copy and paste, and replace the card number with the output number from arecord.


pcm.ARDOP {
type rate
slave {
pcm "plughw:1,0"
rate 48000
}
}


CTRL+o saves the file and CTRL+x exits nano.


Start ardop with PTT on GPIO 17 by navigating to the folder with piardopc and running the command " ./piardopc -p gpio "


If everything is working properly you will see something like this in the terminal.


pi@raspberrypi:~ $ ./piardopc -p gpio
ARDOPC Version 1.0.2.5l-BPQ
GPIO interface for PTT available
Using GPIO pin 17 for PTT
ARDOPC listening on port 8515
getReadDevices
Card 0, ID `ALSA', name `bcm2835 ALSA'
Card 1, ID `Set', name `C-Media USB Headphone Set'
Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
1 channel,
sampling rate 44100..48000 Hz
hw:1,0 USB Audio(C-Media USB Headphone Set)
getWriteDevices
Card 0, ID `ALSA', name `bcm2835 ALSA'
Device 0, ID `bcm2835 ALSA', name `bcm2835 ALSA', 7 subdevices (7 available)
1..2 channels,
sampling rate 8000..48000 Hz
hw:0,0 bcm2835 ALSA(bcm2835 ALSA)
Device 1, ID `bcm2835 ALSA', name `bcm2835 IEC958/HDMI', 1 subdevices (1 available)
2 channels,
sampling rate 44100..48000 Hz
hw:0,1 bcm2835 IEC958/HDMI(bcm2835 ALSA)
Card 1, ID `Set', name `C-Media USB Headphone Set'
Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
2 channels,
sampling rate 44100..48000 Hz
hw:1,0 USB Audio(C-Media USB Headphone Set)
Opening Playback Device ARDOP Rate 12000
Playback Buffer Size 65536
Opening Capture Device ARDOP Rate 12000
ARDOPC listening on port 8515
Input peaks = 0, 322
Input peaks = 0, 321
Input peaks = 0, 319


Connect you radio and make level adjustments.


Adjust RX level until Input peaks show something around +/-20000



You can use alsamixer from terminal to adjust volumes.


Next use your favorite client and send some data to adjust TX level according to to your radios instructions.


Thats about it.

Good luck.




Winlink on an Raspberry Pi Zero W

The Winlink system is great for of the grid communications. Lugging a Windows pc with Winlink Express is OK if you are on a boat, but if you...