Friday, 29 April 2016

remote AIS receiver/repeater - part 5 - base station

 [prev]     [first]     [next]

TL;DR

Raspberry Pi LoRa gateway


* Raspberry Pi 2/3 with HopeRf RFM98 shield from store.uptronics.com
* antenna can be yagi
* software on Pi adapted from Dave Ackerman's LoRa gateway software for High-altitude baloons
http://www.daveakerman.com/?p=1719
* Pi receives messages from LoRa and reconstructs full sentences (!AIVDM header is stripped from the on-air backhaul to save size, so is reconstructed on the Pi before pushing to the LAN over UDP
* pi also receives battery level from the remote receiver and publishes to IoT cloud e.g adafruit.io




remote AIS receiver/repeater - part 4 - LoRa data link


  [prev]     [first]     [next]

TL;DR

LoRa data link

* Transmitter HopeRF RFM98 433MHz HopeRF RFM98W-433S2
* code adapated from various sources listed on  kh-gps.de/lora.htm

Antenna is just 1/4 wire at the moment, but could be directional yagi/moxon, given that it need only point in one direction.


remote AIS receiver/repater - part 3 - power management


[prev]     [first]     [next]
TL;DR
* 10W 12V solar panel
* 2x18650 LiPo
LT3652  based Solar LiPo charge contoller
* Teensy 3.1 microcontroller for power management.


I want about 5 days of solar redundancy to allow for Highlands weather.

Instead of having a transparent serial link whereby all AIS sentences are just packetised and transmitted over the LoRa, we waste a lot of energy on partially-full LoRa packets, redundant AIS sentences and possible brownout at night. We want to be able to control the LoRa radio state too by using sleep mode to minimise current draw (we don't need it to receive any messages over LoRa just yet)

If we control the LoRa transmissions and AIS reception with a microcontroller, we can optimise power usage by pre-filtering sentences and packaging up several AIS sentences in on LoRa data frame (max 258bytes - could get perhaps 3 AIS sentences in one LoRa packet ). We can also monitor the power and switch off the AIS receiver when the battery is low or rate limit packets as the input current allows. There is a tradeoff between the extra draw of a microcontroller and that saved by optimising packets. We don't have to receive any information back through the LoRa link (unless we want to at a later date), so we can put it to sleep outside transmissions.

I have a few Teensy 3.1 controllers knocking around which are more than overkill for the job,but they seem suitable because
* 3.3v power possible for low current
* underclock easy for low current
* Snooze library good for low power mode
* good HW serial support for buffering AIS sentences
* good number crunching abilities should we wish to add AIS decoding/prefiltering

Some fag packet calculations. I have made up some assumptions on AIS packet data rates. The LoRa parameters are critical for power consumption - different coding rates, spreading factors etc all vary the packet transmission duration significantly, so I have just made a guess here based on some mid-range figures from the Semtech LoRa calculator

Device On state Sleep State
LoRa 130 2 mA
Teensy 20 1 mA
Ais 20 mA
Teensy duty cycle 0.75
time per sentence 0.15 s
sentences per min 120
sentences per hour 7200
tx time per hour 1080 s
calculated lora duty cycle 0.3
LoRa mean current over 1 hour 40.4 mA
Average total current draw over 1 hour 75.4 mA
energy used in 1 day 1809.6 mAh
battery capacity 5500 mAh
battery duration (no solar input) 136.1 hours
5.67days
solar panel Current @Pmax 550 mA
sunshine per day 4 hours
solar input per day
2200 mAh
time to full charge @ max flux 10 hours



I happened to have a 12V 10W solar panel going spare, so used this. I have a stash of 18650 cells too. Two in parallel give me 5500mAh.

The solar charge controller - I would have liked this from Adafruit  https://www.adafruit.com/products/390 but it is not available locally and only handles a 6V panel

but it didn't handle the 12V (20V open circuit) from my existing solar panel, so I chose one based on the LT3652 charge controller chip

https://www.sparkfun.com/products/12885

out of the box it required a bit of tinkering to get going. The board is set for a 4 hour timer using a 1uf cap on pin 6 of the LT3652 . I bypassed this to allow full current to the board (connected in parallel with the battery) when the sun is shining. Battery charge is then current - rather than time - limited.
There are options on the board for current sense resistors, which I could use to rate-limit the AIS backhaul based on available current should I so desire at a later date



remote AIS receiver/repeater - part 2 - AIS receiver

[prev]     [first]     [next

TL;DR
* dAISy AIS receiver running at 3.3v  3.7 - 4.2V and direct serial output
http://www.wegmatt.com/
* homemade 5 element colinear at 162MHz or Moxon rectangle (reception azimuth is limited)
http://arundale.com/docs/ais/aerial.html
http://w4.vp9kf.com/moxon_calculate.php




Originally I used a Raspberry Pi and RTL-SDR dongle to receive AIS messages at home, but this requires too much power for solar operation if my receiver/repeater is going to live on a remote hilltop

I have settled on a small standalone receiver called dAISy http://www.wegmatt.com/. Purchased from Tindie, not yet arrived from the USA.

The creator has been very helpful answering some technical queries about boot times, power management and reception advice.

The unit can be powered from 3.3v and output AIS messages over TTL serial. Power <20 mA@5V (untested at 3.3v)

Receiver is apparently easily desensitied by nearby transmitters, so need careful placement away from the LoRa transmitter




Remote AIS receiver/repeater

I live close to the sea, and my kids love seeing the comings and goings of boats into town on their way to school. I have an AIS receiver in the loft that feeds data to our local network and to the chart software on my laptop. I'm then primed each morning to answer the kid's questions of "What's that boat Daddy? Where is it going? Where is it from?".

When the search-and-rescue helicopters fly overhead to refuel at the local airfield, I get a ping from Twitter to tell me to point it out

I have AIS envy though. We are *just* in range of the larger ships entering town, but smaller fishing vessels are just out of range, hidden behind some big lumps of granite. The Scottish geography is not my friend here; across the bay just over 5 miles away is a receiver on top of a big hill - that receiver sees EVERYTHING, and I am jealous.

Here enters the gadget tinkerer, throwing his latest acquired technology toolkit towards the problem. I'm tinkering with a wireless race tracker project at the moment, which involves LoRa data links, GPS position reporting and low power/battery power design, so it's just one small step up to building a solar powered AIS receiver to plonk on a local hilltop and use the LoRa radio link to backhaul the AIS messages to my house.

There's a few parts to this project:
* AIS reception
* LoRa backhaul
* solar power management
* LoRa basestation and AIS WAN uplink

I'll cover each section in a separate post