Raspberry Pi 3 + IC880a + GPS

Hi!

I’ve just built my first gateway using a Raspberry Pi 3 and a ic880a board.
I want to connect a GPS module to the system as my ic880a doesn’t have the GPS chip installed.
I have connected a Ublox N8M module to the UART on RPi3 but the software doesn’t see it.
Has anyone managed to do something similar and got it working?
Do I need to configure anything manually to get this going?
I’m using resin.io to build and install the software so its not possible to do any ‘normal’ Linux commands on the RPi3.

Thanks in advance :slight_smile:

2 Likes

When you click on your device in resin.io dashboard there is a terminal you can start in the left hand side options. How useful it is, I don’t know, but I suspect it will let you do whatever you need.

https://resin.io/how-it-works/
This shows a picture of the architecture. An extract from that site:

It’s important to separate the host OS which is a fairly bare system with just enough to start the resin.io agent, and the OS inside your container, which is by default some flavour of Debian, or whatever you specify in your Dockerfile. We currently use Yocto Linux as the framework to generate host OS. However, the operation of the host OS should be reasonably transparent for the users. What really matters is the OS within the container, called the “Base OS”. This OS shares the kernel of the Host, but otherwise has its own way of working and with resin.io the users can specify what Base OS their applications use by pointing to an existing Docker image, as long as that image is compatible with their target architecture, of course. The application container runs in privileged mode and has direct access to the hardware. In fact, it can even be used to inject modules into the kernel. Resin’s agent runs in a separate container, which allows us to continue running even if your application crashes, and in this way we can continue to pull new code.

I am guessing the terminal connects you to the Base OS, allowing you to obtain the GPS data from the serial port. I am guessing the Base OS can access all the pins through the Yocto Host OS.

The documentation of the ic880a SPI writes that an optional GPS module can be installed on that board. https://wireless-solutions.de/products/long-range-radio/ic880a

I have looked at the code for https://github.com/jpmeijers/ttn-resin-gateway-rpi/blob/master/run.py

Line 173 seems to have a hard coded serial port. I guess you just need to change that, then do another push?

gateway_conf[‘gps_tty_path’] = os.getenv(‘GW_GPS_PORT’, “/dev/ttyAMA0”)

That line looks for a environment variable named GW_GPS_PORT (that might even be mentioned in the documentation). Just add another environment variable with the correct value to the resin settings and you are done.
Keep in mind the Raspberry Pi 3 has two serial ports and /dev/ttyAMA0 is connected to the bluetooth part by default, not to the serial port! (Check the resin forum for details on how to solve this)

2 Likes

The call to getenv( key, default) that you mention, gets the key from the environment setting GW_GPS_PORT. But if you did not configure that, then it uses the hard-coded serial.

1 Like

BTW, to make the GPS really useful you will need to find a way to connect the PPS signal from the GPS to the iC880a as well…

1 Like

I tried setting the environment variable named GW_GPS_PORT to /dev/ttyAMA0 and to the second serial port /dev/ttyS0 but no luck so far.
I am following this blog - http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/ - to try to get the GPS working.

UPDATE

I am now receiving NEMA data on port /dev/ttyS0 but…

the gateway STILL can’t see the GPS even though I’ve set the GW_GPS_PORT to /dev/ttyS0, GW_GPS to true and GW_FAKE_GPS to false. :disappointed:

When I read the source of the run.py that is mentioned, I see that this script reads configuration data and writes out a local configuration 'local_conf.json'. So when running it, line 170 prints that the file will be configured for a real gps, and lines 171-173 are configured in the json.

Also, it reads your configuration data from your TTN account on line 94, then on line 121 it checks the online configured gps position which is then printed on line 138-140. So that position is not read from your real GPS yet.

On line 303 the forwarder is started, and I guess this process will use the GPS device.

Yes - it all seems a bit ‘backwards’ to me. If you have GW_GPS set to true, the code shouldn’t go to the TTN account for configuration data but just wait for the GPS to supply it.
I have now moved the GPS module from the software UART1 to the hardware UART0. I thought that the software expected it to be there (as per RPi2B) but no luck.
I can’t find what mechanism the gateway software uses to actually read and use the GPS data. I have gpsd installed and it works fine.

If you check the output of the packet forwarder you should see it tries to open the tty specified to access the GPS. It does not use gpsd and if gpsd opens the tty the packet forwarder may not be able to. I would remove/disable gpsd and check the output produced at the start of the packet forwarder…

I will certainly try that - but before I installed gpsd, to check if the GPS module was actually working, the tty ports were free (only connected to the GPS module) and the packet forwarder couldn’t see/use the GPS module.

OK - removed gpsd - still getting NEMA data on /dev/ttyAMA0 but the packet forwarder can’t see it.
I’m stumped as what to try next. :sob:

Does the packet forwarder say it is looking for it?

EDIT: I think I spotted an error in the python script. Will investigate further tomorrow…

I don’t think so. here is the log from when the gateway boots up -

05.06.17 23:19:59 (+0000) *******************
05.06.17 23:19:59 (+0000) *** Configuration:
05.06.17 23:19:59 (+0000) *******************
05.06.17 23:19:59 (+0000) Gateway ID: marssystems-1
05.06.17 23:19:59 (+0000) Gateway EUI: B827EBFFFE8D952B
05.06.17 23:19:59 (+0000) Gateway Key: ttn-account-v2…
05.06.17 23:19:59 (+0000) Has hardware GPS: true
05.06.17 23:19:59 (+0000) Hardware GPS port: /dev/ttyAMA0
05.06.17 23:19:59 (+0000) *******************
05.06.17 23:19:59 (+0000) *** Fetching config from TTN account server
05.06.17 23:19:59 (+0000) *******************
05.06.17 23:20:00 (+0000) Router: bridge.eu.thethings.network
05.06.17 23:20:00 (+0000) Frequency plan: EU_863_870
05.06.17 23:20:00 (+0000) Frequency plan url: https://account.thethingsnetwork.org/api/v2/frequency-plans/EU_863_870
05.06.17 23:20:00 (+0000) Gateway description: ic880a- rpi-3
05.06.17 23:20:00 (+0000) Gateway placement: outdoor
05.06.17 23:20:00 (+0000) Latitude: 53.450044
05.06.17 23:20:00 (+0000) Longitude: -2.274433
05.06.17 23:20:00 (+0000) Altitude: 77
05.06.17 23:20:00 (+0000)
05.06.17 23:20:00 (+0000) Fallback routers:
05.06.17 23:20:00 (+0000) mqtts://bridge.asia-se.thethings.network
05.06.17 23:20:00 (+0000) mqtts://bridge.us-west.thethings.network
05.06.17 23:20:00 (+0000) mqtts://bridge.brazil.thethings.network
05.06.17 23:20:00 (+0000) Not sending coordinates
05.06.17 23:20:00 (+0000) [TTN Gateway]: Resetting concentrator on pin 22
05.06.17 23:20:00 (+0000) *** Multi Protocol Packet Forwarder for Lora Gateway ***
05.06.17 23:20:00 (+0000) Version: 3.0.0
05.06.17 23:20:00 (+0000) *** Lora concentrator HAL library version info ***
05.06.17 23:20:00 (+0000) Version: 5.0.1; Options: native;
05.06.17 23:20:00 (+0000) ***
05.06.17 23:20:00 (+0000) INFO: Little endian host
05.06.17 23:20:00 (+0000) INFO: found global configuration file global_conf.json, parsing it
05.06.17 23:20:00 (+0000) INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
05.06.17 23:20:00 (+0000) INFO: lorawan_public 1, clksrc 1
05.06.17 23:20:00 (+0000) INFO: no configuration for LBT
05.06.17 23:20:00 (+0000) INFO: antenna_gain 0 dBi
05.06.17 23:20:00 (+0000) INFO: Configuring TX LUT with 16 indexes
05.06.17 23:20:00 (+0000) INFO: radio 0 enabled (type SX1257), center frequency 867500000, RSSI offset -166.000000, tx enabled 1
05.06.17 23:20:00 (+0000) INFO: radio 1 enabled (type SX1257), center frequency 868500000, RSSI offset -166.000000, tx enabled 0
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 0> radio 1, IF -400000 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 1> radio 1, IF -200000 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 2> radio 1, IF 0 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 3> radio 0, IF -400000 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 4> radio 0, IF -200000 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 5> radio 0, IF 0 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 6> radio 0, IF 200000 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora multi-SF channel 7> radio 0, IF 400000 Hz, 125 kHz bw, SF 7 to 12
05.06.17 23:20:00 (+0000) INFO: Lora std channel> radio 1, IF -200000 Hz, 250000 Hz bw, SF 7
05.06.17 23:20:00 (+0000) INFO: FSK channel> radio 1, IF 300000 Hz, 125000 Hz bw, 50000 bps datarate
05.06.17 23:20:00 (+0000) INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
05.06.17 23:20:00 (+0000) INFO: Found 1 servers in array.
05.06.17 23:20:00 (+0000) INFO: Server 0 configured to “router.eu.thethings.network”
05.06.17 23:20:00 (+0000) INFO: packets received with a valid CRC will be forwarded
05.06.17 23:20:00 (+0000) INFO: packets received with a CRC error will NOT be forwarded
05.06.17 23:20:00 (+0000) INFO: packets received with no CRC will NOT be forwarded
05.06.17 23:20:00 (+0000) INFO: GPS is disabled
05.06.17 23:20:00 (+0000) INFO: Upstream data is enabled
05.06.17 23:20:00 (+0000) INFO: Downstream data is enabled
05.06.17 23:20:00 (+0000) INFO: Ghoststream data is disabled
05.06.17 23:20:00 (+0000) INFO: Radiostream data is enabled
05.06.17 23:20:00 (+0000) INFO: Statusstream data is enabled
05.06.17 23:20:00 (+0000) INFO: Beacon is disabled
05.06.17 23:20:00 (+0000) INFO: Monitor is disabled
05.06.17 23:20:00 (+0000) INFO: Packet logger is disabled
05.06.17 23:20:00 (+0000) INFO: found local configuration file local_conf.json, parsing it
05.06.17 23:20:00 (+0000) INFO: redefined parameters will overwrite global parameters
05.06.17 23:20:00 (+0000) INFO: local_conf.json does not contain a JSON object named SX1301_conf
05.06.17 23:20:00 (+0000) INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
05.06.17 23:20:00 (+0000) INFO: gateway MAC address is configured to B827EBFFFE8D952B
05.06.17 23:20:00 (+0000) INFO: Found 1 servers in array.
05.06.17 23:20:00 (+0000) INFO: Server 0 configured to “bridge.eu.thethings.network”
05.06.17 23:20:00 (+0000) INFO: packets received with a valid CRC will be forwarded
05.06.17 23:20:00 (+0000) INFO: packets received with a CRC error will NOT be forwarded
05.06.17 23:20:00 (+0000) INFO: packets received with no CRC will NOT be forwarded
05.06.17 23:20:00 (+0000) INFO: GPS is disabled
05.06.17 23:20:00 (+0000) INFO: Upstream data is enabled
05.06.17 23:20:00 (+0000) INFO: Downstream data is enabled
05.06.17 23:20:00 (+0000) INFO: Ghoststream data is disabled
05.06.17 23:20:00 (+0000) INFO: Radiostream data is enabled
05.06.17 23:20:00 (+0000) INFO: Statusstream data is enabled
05.06.17 23:20:00 (+0000) INFO: Beacon is disabled
05.06.17 23:20:00 (+0000) INFO: Monitor is disabled
05.06.17 23:20:00 (+0000) INFO: Packet logger is disabled
05.06.17 23:20:00 (+0000) INFO: Contact email configured to "mariusz_adamczyk@msn.com"
05.06.17 23:20:00 (+0000) INFO: Description configured to “ic880a- rpi-3”
05.06.17 23:20:00 (+0000) INFO: [Transports] Initializing protocol for 1 servers
05.06.17 23:20:01 (+0000) INFO: [TTN] server “bridge.eu.thethings.network” connected
05.06.17 23:20:01 (+0000) INFO: [main] Starting the concentrator
05.06.17 23:20:01 (+0000) ERROR: [main] failed to start the concentrator
05.06.17 23:20:09 (+0000) Application is already running ‘registry2.resin.io/ttngw/d15ed0ddece
05.06.17 23:20:17 (+0000) [TTN Gateway]: Resetting concentrator on pin 22
05.06.17 23:20:17 (+0000) *** Multi Protocol Packet Forwarder for Lora Gateway ***
05.06.17 23:20:17 (+0000) Version: 3.0.0
05.06.17 23:20:17 (+0000) *** Lora concentrator HAL library version info ***
05.06.17 23:20:17 (+0000) Version: 5.0.1; Options: native;
05.06.17 23:20:17 (+0000) ***

That means it won’t access the GPS. My updated container is looking for the GPS but something else is wrong so please bear with me for a day while I debug…

OK - no worries - just glad that someone is willing to help me out with this. :smile::thumbsup:

@marssystems
I’ve found an issue in the packet forwarder that requires fixing with regards to GPS. Hoping to find the time to fix it before the weekend.

That’s great! I thought I was doing something wrong when I couldn’t get it to work.