1. Hardware
- Used Hardware: Banana-Pi M2U quad-core mini single board computer + iC880a LoRaWAN Concentrator 868MHz (bought here)
- Banana-Pi advantage: internal 8 GB eMMC storage
- OS Raspbian 2017-05-25-raspbian-jessie-preview3-bpi-m2u-sd-emmc.img, how to burn it to MMC find here
- Step 1: Start up the computer with the SD card which has been burnt with the Linux images.
- Step 2: Put the images which you’d like to burn to the EMMC Storage to the USB drive.
- Step 3: Run “fdisk -l” command line on your BPI-M3 and you can see the EMMC path as “/dev/mmcblk1”
sudo fdiskfa -l
- Step 4:Switch to the path of images, and run the command.
sudo dd if=2017-05-25-raspbian-jessie-preview3-bpi-m2u-sd-emmc.img of=/dev/mmcblk1 bs=10MB
see also video on youtube.
2. Customise OS
uninstall Xserver:
sudo apt-get remove --auto-remove --purge 'libx11-.*' sudo apt-get autoremove --purge
(Repeat apt-get autoremove --purge
until no orphans remain)
update OS:
# rpi-update # apt-get dist-upgrade # apt-get update # bpi-update # bpi-tools -u # bpi-tools -U
delete default user PI:
# adduser new-user # deluser pi
install Persistent IPtables:
# apt-get install iptables-persistent # vi /etc/iptables/rules.v4 # Generated by iptables-save v1.4.21 on Thu Feb 16 18:14:59 2017 *filter :INPUT DROP [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 22,80 -j ACCEPT -A INPUT -p udp --dport 1700 -m state --state NEW -j ACCEPT -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED COMMIT
set NTP time:
1. Go to http://support.ntp.org/bin/view/Servers/NTPPoolServers and click the host name corresponding to your area. Assuming the area is North America, the servers are:
server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org
2. Open /etc/ntp.conf in a text editor. If you use the nano editor, run sudo nano /etc/ntp.conf
You should see a list of servers similar to the one below, replace the servers with the ones from step 1::
server 0.cz.pool.ntp.org iburst server 1.cz.pool.ntp.org iburst server 2.cz.pool.ntp.org iburst server 3.cz.pool.ntp.org iburst
3. Comment out (by adding a # in front of the line) the following two lines:
restrict 127.0.0.1 restrict ::1
4. Save the file and exit
5. Set the correct time zone by running # sudo cp /usr/share/zoneinfo/US/Pacific /etc/localtime. Replace US/Pacific with your time zone. If you are not sure about the possible values, look in /usr/share/zoneinfo
6. Restart the ntp server: sudo /etc/init.d/ntp restart
7. Run date
in a terminal
8. If the time is not correct, you might have to force update it. This is because, by default, ntp
will not sync if the difference between the system time and the real-time is greater that 1000 seconds. Run sudo ntpd -gq
and the restart ntp
Turn off WiFi:
# iwconfig wlan0 txpower off (if needed tun on: # iwconfig wlan0 txpower auto)
check status:
# rfkill list all
3. Assemble it all together
step by step here
Connect the jumper wires between the two boards using the following table:
iC880a pin | Description | RPi physical pin |
---|---|---|
21 | Supply 5V | 2 |
22 | GND | 6 (14, 25) |
13 | Reset | 11 |
14 | SPI CLK | 23 |
15 | MISO | 21 |
16 | MOSI | 19 |
17 | NSS | 24 |
OK! We’re now ready to power up and start configuring our gateway!
4. Setting up the software
- Use
raspi-config
utility to enable SPI> ([5] Interfacing options -> P4 SPI
) and also expand the filesystem ([7] Advanced options -> A1 Expand filesystem
):$ sudo raspi-config
- Reboot (it will ask on exit, but you can do it manually with
sudo reboot
) - Configure locales and time zone:
$ sudo dpkg-reconfigure locales $ sudo dpkg-reconfigure tzdata
- Make sure you have an updated installation and install
git
:$ sudo apt-get install git
- Create new user for TTN and add it to sudoers
$ sudo adduser ttn
- Logout and login as
ttn
and remove the defaultpi
user$ sudo userdel -rf pi
- Configure the wifi credentials (check here for additional details)
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
And add the following block at the end of the file, replacing SSID and password to match your network:
network={ ssid="The_SSID_of_your_wifi" psk="Your_wifi_password" }
- Clone the installer and start the installation
$ git clone -b spi https://github.com/ttn-zh/ic880a-gateway.git ~/ic880a-gateway $ cd ~/ic880a-gateway $ sudo ./install.sh spi
- If you want to use the remote configuration option, please make sure you have created a JSON file named as your gateway EUI (e.g.
B827EBFFFE7B80CD.json
) in the Gateway Remote Config repository. EUI folows MAC addr of eth0 (or wlan0) - By default, the installer changes the hostname of your Raspeberry Pi to
ttn-gateway
(to prevent collisions with other Raspberry Pis in your network). You can override this in non-remote configuration mode. - reset iC880a on boot (GPIO 17 = pin 11 conected to reset pin 13 on iC880a):
put simlink to /etc/rc2.d to following script:
#!/bin/bash echo "17" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio17/direction echo "1" > /sys/class/gpio/gpio17/value sleep 5 echo "0" > /sys/class/gpio/gpio17/value sleep 1 echo "0" > /sys/class/gpio/gpio17/value iC880-SPI_reset.sh (END)
5. Checking connection to TTN (The Things Network)
The best way to check if the gateway is working is registering it on the TTN Console.
- Login to www.thethingsnetwork.org Console
- Click on Gateways -> Register gateway
- Select the Packet forwarder protocol
- Enter your Gateway EUI (if is printed on start and end of the installer)
- Enter any description
- Select Europe 868 MHz as frequency plan
- Select the correct antenna placement according to your plans
- Confirm clicking Register gateway
Now you can see the status (which at this point should be connected
if we did everything right) and traffic of your gateway!
And now we’re really done!
6. Backups
RPI – save SD card
http://ideaheap.com/2013/07/stopping-sd-card-corruption-on-a-raspberry-pi/
RPI backup img:
# dd if=/dev/mmcblk0 | gzip -1 - | ssh user@backup-server dd of=image.gz
Raspi UPS HAT Board:
http://www.raspberrypiwiki.com/index.php/Raspi_UPS_HAT_Board#how_to_USP_HAT_use_via_i2c