1 Wenet TX Payload Instructions DEPRECATED
Mark Jessop edytuje tę stronę 2022-03-19 15:16:40 +10:30

This page documents the steps required to set up a Raspberry Pi (2A, Zero, ZeroW) as a Wenet transmitter. These instructions assume that you already have a Raspbian installation set up on a Raspberry Pi, and have SSH access to it.

NOTE: On Raspberry Pi units with Bluetooth (Pi 3, Pi Zero W), you will need to enable the pi3-disable-bt hardware overlay. Refer to this guide (about halfway down the page) for more information. In short, you will probably want to add the dtoverlay=pi3-disable-bt line to your /boot/config.txt file.

1. Required Hardware

1.1 Radio Module

The Wenet codebase currently supports using either a HopeRF RFM22B or a HopeRF RFM98W radio module as the FSK modulator. The RFM22B is now obsolete, so the RFM98W option is probably better.

UpuTronics sells a suitable RFM98W Raspberry Pi shield, with shield sizes suitable for a RPi2 Model A, and a Pi Zero/W.

In both cases, the shield must be modified with the addition of a single wire, connecting the DIO2 pin (GPIO2 on the RFM98W) to the TXD pin (pin 8) on the Raspberry Pi's header.

RFM98W Shield Modifications

The above image shows how this can be implemented on one of the UpuTronics shields. A length of re-work wire is used to join the two pins, and is held down with silicone.

1.2 Camera

The Wenet code is intended to be used with a PiCamera. Both the v1 and v2 cameras, both with IR and no IR sensor, have been used and work well.

There is some partially working code to use the fswebcam utility to capture images from a USB webcam, but this is not recommended.

1.3 GPS Unit (Optional)

The Wenet transmitter code can optionally get payload position information from a uBlox GPS module (accessed via USB-Serial), and overlay the position on the downlinked image.

USB-connected uBlox GPS units are available fairly cheaply on eBay, under the name 'VK-172 G-mouse'. These have a uBlox 7 chipset (or at least a very good clone of one...) and have been tested up to 37km altitude. They appear as an ACM serial device, and later on in the setup process a udev rule is added to provide a symlink to the serial port at /dev/ublox.

2. Software Installation

Install the required dependencies from apt-get using:

$ sudo apt-get install git build-essential vim python-dev python-numpy python-picamera python-crcmod python-spidev python-pip python-serial imagemagick

2.1 SSDV

We need fsphil's 'slow-scan digital video' compression utility available on the system. From the home directory, run:

$ git clone https://github.com/fsphil/ssdv.git
$ cd ssdv 
$ make
$ sudo make install

2.2 Other Dependencies

If you're using a RFM98W module, we need to grab a library which helps us control the Semtech SX127x IC used on it. From the home directory, run:

$ git clone https://github.com/darksidelemm/pySX127x.git

We'll come back to this repository in a moment...

2.3 Downloading Wenet

Run:

$ git clone https://github.com/projecthorus/wenet.git
$ cp -r ~/pySX127x/SX127x ~/wenet/tx/
$ sudo cp ~/wenet/tx/99-usb-serial.rules /etc/udev/rules.d/

In turn, this:

  • Grabs a copy of the Wenet git repository
  • Copies the required RFM98W control library into the wenet TX directory
  • Copies udev rules to be able to easily access a uBlox GPS unit at /dev/ublox

Finally, we need to compile the LDPC Encoding library:

$ cd ~/wenet/tx/
$ gcc -fPIC -shared -o ldpc_enc.so ldpc_enc.c

2.4 Raspi-Config

Run sudo raspi-config, and under Interfacing options, enable:

  • Camera
  • SPI
  • Serial (When prompted, set 'Enable Login Shell' to NO, and 'Serial Port Hardware Enabled' to YES.)

2.5 GPS-NTPD Sync (Optional)

If required, the attached GPS unit can be used to synchronise the system clock, via NTPd's Shared Memory Interface.

To use this, we need to grab the ntpdshm python library from pip, and also install the NTPD server:

$ sudo apt-get install ntp
$ sudo pip install ntpdshm

The NTP config file (/etc/ntp.conf) then need to be edited, and the following lines added at the end of the file:

server 127.127.28.2 minpoll 4 maxpoll 4
fudge 127.127.28.2 time1 0.09 refid PYTH stratum 2

Restart NTPD using sudo /etc/init.d/ntp restart

3. Testing

3.1 FSK Modulator

This section assumes you have a Wenet Receiver available.

Before testing with a camera, is is useful to transmit some test images to check the FSK modulator is working. The test_images directory contains a set of test images that you can transmit. Run:

$ cd ~/wenet/test_images
$ python compress_test_images.py

This will produce SSDV-compressed versions of the JPEG images, and may take a few minutes to run (depending on the RPi board in use).

Now, we need to start up the radio module:

$ cd ~/wenet/tx
$ python init_rfm98w.py --frequency <freq>

Replace <freq> with a frequency in MHz that you are licensed to use. Note that the transmitted signal is over 300 kHz wide, so is in breach of the ISM regulations in most countries. Here in Australia, we run our Wenet payloads on 441.200 MHz, under an Advanced amateur radio licence.

A carrier should now be transmitted on the supplied frequency.

We can now start transmitting the test images using:

$ python tx_test_images.py YOURCALLSIGN

Hopefully images will start appearing on your Wenet receiver!

3.2 GPS Check

To check that the RPi can communicate with an attached uBlox GPS unit, run:

$ cd ~/wenet/tx
$ python ublox.py /dev/ublox

A large amount of JSON objects should be written to the terminal, containing the various GPS parameters (latitude, longitude, time, etc)

If you set up NTPD earlier, you can run ntpq -p, and you should see a SHM(2) entry in the list of NTP peers.

3.3 Pi Camera Check

The WenetPiCam.py file contains a test script which will capture and transmit images. This can be run with:

$ python WenetPiCam.py YOURCALL

Debug information on the scripts current actions will be written to the terminal. Images should be captured, re-sized, and transmitted via the FSK modulator.

3.4 Setting the Focus

$ raspivid -t 0 -l -o tcp://0.0.0.0:3333

VLC: tcp/h264://your.pi.ip.address:3333

3.5 Hardware Watchdog

https://diode.io/raspberry%20pi/running-forever-with-the-raspberry-pi-hardware-watchdog-20202/

4. Setup for Automatic Transmissions

The tx_picam_gps.py Python script will automatically capture images and GPS data, overlay GPS position information at the top of the image, and transmit images.

The start_tx.sh script in ~/wenet is designed to be run from /etc/rc.local on boot, and starts up the radio and the tx_picam_gps.py script. Edit this file and adjust the MYCALL and TXFREQ parameters as necessary.

You can then add the following line into /etc/rc.local (just before the exit 0 line) to start it at boot:

/home/pi/wenet/start_tx.sh &

Some further configuration may be required depending on your payload setup. The main things you may want to change are the capture & transmit resolutions, and whether horizontal/vertical flip is used (depends on your camera orientation). These settings are all around line 138.

You should now be able to reboot the Raspberry Pi, and have it transmit images automatically!