ch2i / LoraGW-Setup

SX1301 Lora Concentrator Raspberry PI based gateway setup
72 stars 29 forks source link

Detect the GPS module of the official RAK831 shield for Raspberry Pi 3 #2

Open manuelbl opened 6 years ago

manuelbl commented 6 years ago

Thanks for the awesome setup procedure. I've successfully used it with a RAK831 board and RAK's official shield (converter board) for the Raspberry Pi 3. However the GPS module soldered onto the shield was not configured.

With manual work, I was able to get the GPS module running. The relevant steps are:

Serial port

On the Raspberry Pi 3, the serial port /dev/ttyAMA0 is used for the bluetooth module. The GPS module is found on /dev/ttyS0. The path /dev/serial0 is linked to that device as well. The Raspbian distribution configures it as a login shell, which is in conflict with the use for the GPS module. So it must be changed, either by removing console=serial0,115200 from /boot/cmdline.txt or by using raspbi-config:

Permissions for serial port

In order to access the serial port (without being root), the user must belong to the group dialout. The user pi belongs to it, the user loragw doesn't. So:

sudo usermod -a -G dialout loragw

Discovery

Even after these changes, the setup script did not properly discover the GPS module. It said:

Has hardware GPS:   False
Hardware GPS port:  /dev/ttyAMA0
Using fake GPS

I have no idea how the discovery works. Is the GPS port a default value? Anyhow, I've modified the global_conf.json manually:

        "fake_gps": false, 
        "gps": true,
    "gps_tty_path": "/dev/ttyS0"

After a reboot, the GPS module is now working. It would be cool if no manual work was needed and the setup scripts would automatically detect and configure the GPS module.

hallard commented 6 years ago

Thanks for the procedure, I'll try to add it next time I do changes. The drawback is that you loose the FTDI console access in case you loose network. Anyway I'll try to do it and also link the GPS to real UART switching BLE to soft Uart to be safe. See section Raspberry PI 3 on the post I made here http://hallard.me/enable-serial-port-on-raspberry-pi/

evandavey commented 5 years ago

Using a RAK831 shield, I found the GPS was /dev/ttyAMA0 and needed to run

sudo systemctl mask serial-getty@ttyAMA0.service

to give the loragw user permission to read it.

BraveUlysses81 commented 5 years ago

@manuelbl I don't seems to have a cmdline.txt file and when I try to raspbi-config, I get command not found.

I also don't have a user "loragw", or "pi" so I'm not sure who would be attempting to access the serial port in my case.

I'm at a loss here. I've been working on this for too long. Is there not a simple fix that just works??

Any help is huge.

manuelbl commented 5 years ago

@BraveUlysses81 I've just checked that the latest Raspberry Stretch Lite image still contains a cmdline.txt file. You can edit it on a different computer before you boot the Raspberry Pi for the first time.

Once you have booted the Raspberry Pi with the modified image, you can log in to the Raspberry Pi and either run raspbi-config or edit /boot/cmdline.txt. You can also later modify it if you have further proceeded in the installation.

How far have you gotten in the installation? How do you log in to the Raspberry Pi if you don't have user pi?

BraveUlysses81 commented 5 years ago

Thanks for getting back so quickly. I log in through the Balena console. It's not the best way of course, but I'm in dev mode and trying to do everything simply just to get it going.

"I've just checked that the latest Raspberry Stretch Lite image still contains a cmdline.txt file. You can edit it on a different computer before you boot the Raspberry Pi for the first time."

Do I need to re-flash my micro SD? It looks like at part of the Docker build, it's grabbing the latest Stretch. Also, I've look at a tone of things on the net and although yours seems to work from what others say, I've also seen it work when people just "cat /dev/ttyAMA0" "cat /dev/ttyS0" When I do that, I get nothing for "cat /dev/ttyS0" and my terminal hangs for "cat /dev/ttyAMA0." None of this makes sense to me. I seem to be the only one who can't get any output from these files.

Where do you check the latest Stretch image? I need to know more of this stuff clearly... Thanks for all the help and the guides you've posted. Best.

manuelbl commented 5 years ago

Do I understand it correctly that you are running the LoRa gateway within a Docker container? If so, I can't help you as I'm not familiar with how serial ports are made available to the Docker container. Possibly the problem needs to be solved outside the Docker container, i.e. in the operating system hosting the Docker container.

BraveUlysses81 commented 5 years ago

@manuelbl I have fixed the issue if maybe not figured it out. What I ended up doing was re-starting the entire set up, from the flashing of the SD. I did all the same things as before with the exception of I chose "production" instead of "development" when setting up my device. Also, I was especially careful to follow the exact order of steps...

It turns out, I didn't not need to free the permissions for the serial port. To be honest, I'm not sure exactly what the original problem really was.

I do thank you very much for being so quick and helpful. Always thanks to guys like you.