The hard RAK831 cafe part 2

No, I mean a device file like ‘/dev/ttyAMA0’ (which happens to be the file I use)

Yes there are special settings. Can be found in the code on github. (9600, uBlox or NMEA protocol for those too lazy)

Raspberry Pi 3 and the Serial Port

Source: https://raspberrypi.stackexchange.com How do I make Serial work on the Raspberry Pi 3

This answer is still correct, and explains in more detail the nature of the changes, but most users of current Raspbian should just run sudo raspi-config Select Interfacing Options / Serial then specify if you want a Serial console (probably no) then if you want the Serial Port hardware enabled (probably yes). Then use /dev/serial0 in any code which accesses the Serial Port.

The BCM2837 on the Raspberry Pi3 has 2 UARTs (as did its predecessors), however to support the Bluetooth functionality the fully featured PL011 UART was moved from the header pins to the Bluetooth chip and the mini UART made available on header pins 8 & 10.

This has a number of consequences for users of the serial interface.

The /dev/ttyAMA0 previously used to access the UART now connects to Bluetooth.
The miniUART is now available on /dev/ttyS0.
In the latest operating system software there is a /dev/serial0 which selects the appropriate device so you can replace /dev/ttyAMA0 with /dev/serial0 and use the same software on the Pi3 and earlier models.

Unfortunately there are a number of other consequences:

The mini UART is a secondary low throughput UART intended to be used as a console.

The mini Uart has the following features:
• 7 or 8 bit operation.
• 1 start and 1 stop bit.
• No parities.
• Break generation.
• 8 symbols deep FIFOs for receive and transmit.
• SW controlled RTS, SW readable CTS.
• Auto flow control with programmable FIFO level.
• 16550 like registers.
• Baudrate derived from system clock.

There is no support for parity and the throughput is limited, 
but the latter should not affect most uses.

There is one killer feature “Baudrate derived from system clock” which makes the miniUART useless as the this clock can change dynamically e.g. if the system goes into reduced power or in low power mode.

Modifying the /boot/config.txt removes this dependency by adding the following line at the end:
core_freq=250

This fixes the problem and appears to have little impact. The SPI clock frequency and ARM Timer are also dependent on the system clock.

For some bizarre reason the default for Pi3 using the latest 4.4.9 kernel is to DISABLE UART. To enable it you need to change enable_uart=1 in /boot/config.txt. (This also fixes the core_freq so this is no longer necessary.)

Finally if you don’t use Bluetooth (or have undemanding uses) it is possible to swap the ports back in Device Tree. There is a pi3-miniuart-bt and pi3-disable-bt module which are described in /boot/overlays/README.

.
.

Not everyone here on the forum is a seasoned Linux expert (me included) but many try to operate their gateway as good as possible and learn new things (TTN is community driven).
Many will not dive directly into the source code as their first source of information (and others will).

i was able to access the GPS module by enabling SPI using the RESIN_HOST_CONFIG_dtparam device config variable with a value of i2c_arm=on,spi=on. i also added this device config RESIN_HOST_CONFIG_enable_uart with a vaue of 1. i was then able to access the GPS by reading from /dev/ttyS0. :slight_smile:

then i set GW_GPS to true and GW_GPS_PORT to /dev/ttyS0. the gateway was able to read the gps.

3 Likes

Enabling (or disabling) SPI and I2C do not effect the Serial Port (UART) so are not required for the GPS.
SPI is required for the RAK831 board though.

It will be /dev/ttyS0 that did the trick (together with enabling GPS in the gateway config).

To enable the serial port for use with a GPS it is best to explicitly enable the Serial Port and disable Console over the Serial Port with raspi-config (see ‘Raspberry Pi 3 and the Serial Port’ in my previous post).
This will make modifications to the cmdline.txt and config.txt files on the boot partition.
I’m not sure how that should be done when using RESION.IO.

1 Like

RESIN_HOST_CONFIG_enable_uart=1 would enable /dec/ttyS0

1 Like

Was looking at GPS options for my RAK gateway setup, decided to just buy a cheap USB device an have a play with it (I guessed there maybe a hidden pps pin), took some opening but then noticed that this model has PPS available, not sure what EN pin mean mind - need to test now.

20180228_091629329_iOS

EN for Enable?

I know, but why, this operates on power up - data comes through as expected, I got a pulse on the pps pin with my meter too - not sure what is left to enable :slight_smile:

Nice quote. If you look at the instructions for the resin.io builds you will notice for the RPi3 it mentions:
RESIN_HOST_CONFIG_dtoverlay pi3-miniuart-bt

This does exactly what is mentioned at the end of the quote so ttyAMA0, the full UART becomes available for the GPS. For GPS use I would recommend to always use the full UART, not the mini one.

2 Likes

I did say we were lucky with a temperate climate in Ireland did I not?
06%20PM
root@xxxxxxx:/opt/ttn-gateway# /opt/vc/bin/vcgencmd measure_temp
temp=22.9’C

The snow that came from last night’s storm doesn’t seem to upset the RAK831 + Resin.io image on a Pi sitting on the bottom of my antenna pole, only the spare heat from the Pi and RAK pcb’s to keep warm!

52%20PM

3 Likes

Hi folks,

recently i got the green V1.3-ch2i RPI Zero Shield for RAK831.
So I just need to buy me a RAK831 module .

So I searched Ebay and Aliexpress but only found chinese sellers. Ofcourse I can order one from China, but big chance for import-duties/handling-fees of maybe up to 40 euro and waiting a few weeks.
So I would prefer ordering it in UK/Germany or somewhere else in EU.
Is anyone aware of a seller that delivers from within EU ?

I give you little chance that you can buy it locally in UK or Germany.

I suggest to order a RAK831 here: https://www.aliexpress.com/store/product/RAK831-LoRa-LoRaWAN-Gateway-Module-433-868-915MHz-base-on-SX1301-Wireless-Spread-Spectrum-Transmission-range/2805180_32832894046.html for some €106 including shipping.

In the Netherlands one has to pay additional 21% VAT and €13 handling fee, around €36 additional costs (or nothing if you are very lucky).

In case you could buy it locally in Europe you would have to pay the VAT anyway.
"and waiting a few weeks": You can’t have both cheap and fast. :wink:

1 Like

@ bluejedi
Thanks for the info, guess I have to go the china-way.

I just added the English version of my document on building a gateway based on a RAK831 and an Orange Pi zero to my github repositry. See [https://github.com/Edzelf/RAK831-LoRa-gateway].

4 Likes

Is the RAK831 module 100% compatible with Lorawan, or only with LoRa?

Very interesting! Quite funny as I just fabbed some backplane PCBs using an onion omega as well (Went with the Pin version).

Did you have trouble cross compiling the packet forwarders? Think I had to also re-compile a C library for one of the functions.

100% compatible with LoRaWAN.

@Ryanteck it was not completely straightforward to make OpenWrt package makefiles for packet_forwarder and lora_gateway, and it’s still WIP because packet forwarder has an ugly ../../xxx style path reference into the sources of lora_gateway.

It’s only the legacy forwarder for now, I haven’t found the time yet to try packaging @kersing’s MP version, altough I would like to do that.

But I have documented and published how to build a ready to run Omega2 Linux LoRa gateway firmware image from scratch. Improvements are welcome :wink:

1 Like

Excellent. Will have a look. I think my binaries work but am awaiting 2 voltage regulators to arrive still. I’ve cheated by compiling all on my linux box and then uploading the binaries to github which I then clone on the Onion Omega - https://github.com/ryanteck/onion-lora-backplane

Will try to package @kersings version after I know the hardware works.

Here’s my backplane attempt, needs lots of testing.

Went with the THT Onion due to it being slightly easier to get hold of. (£12 in the UK inc PNP)
IMG_20180307_181811717

IMG_20180307_182605618

Gone for a passive POE Power supply method to keep it cheaper and easier. One reg down from 9-12V to 5V and the other for 9-12 to 3V3, Chose the onion for ethernet capabilities.

Should be able to have either RAK831 or ic880a soldered in.

Total cost is around £25 inc the onion. So around £150-175 including one of the two gateways.

5 Likes

did your RAK survived ?