For a longer time I own the NanoPi Duo2 from FriendlyARM including the IoT-Box Carrier Board. The specs of the NanoPi Duo2 and IoT-Box are as follows:
NanoPi Duo2:
- CPU: Allwinner H3, Quad-core Cortex-A7 Up to 1.2GHz
- DDR3 RAM: 512M
- Connectivity: 10/100M Ethernet
- WiFi: 802.11b/g/n
- Bluetooth: Bluetooth V4.0 of 1, 2 and 3 Mbps.
- Camera: OV5640
- ...
IoT-Box Carrier Board:
- Onboard quad-band GSM/GPRS module
- 2 x USB Host
- Serial port and Ethernet port
- Audio input and output
- MicroUSB power input and a power switch
- IPX to SMA WiFi converter
A lot of features are not accessable from the board itself like the ethernet port. One of the reason I also bought the IoT-Box. Another nice feature of the IoT-Box is the GSM/GPRS module (SIM800C), which will be the main focus of this article.
When you want to do the same, you first have to activate UART3 in armbian-config (easiest way) or add UART3 to the overlay of /boot/armbianEnv.txt:
# vi /boot/armbianEnv.txt
...
overlays=analog-codec uart1 uart2 uart3 usbhost0 usbhost2 usbhost3
...
To have UART3 available (I added all of them), a reboot is required:
# shutdown -r now
After reboot, the modem first needs to be woken up which can be done with the following script:
# vi /usr/local/sbin/modem.sh
#!/bin/bash
g=203 # GPIO
cd /sys/class/gpio
echo $g > export
echo out > gpio${g}/direction
echo 1 > gpio${g}/value
sleep 3
stty -F /dev/ttyS3 115200
ln -s /dev/ttyS3 /dev/modem
The above script will export GPIO PIN 203, sets the direction to out and sets the value to one. Make it executable and run it:
# chmod 755 /usr/local/sbin/modem.sh
# /usr/local/sbin/modem.sh
After 2-3 seconds, the yellow led on the IoT-Box should turn on while the blue led on IoT-Box should start blinking. Additionally the script will setup the communication speed between the IoT-Box and the modem to 115200 and create a symbolic link from /dev/ttyS3 (UART3) to /dev/modem. At this point, the modem should be accessable with e.g. minicom.
Now continue with the ppp configuration. I am really not an expert on this and everything below this point are copies from various sources of the internet. First add the ppp interface to /etc/network/interfaces:
# vi /etc/network/interfaces
...
iface lo inet ppp loopback
...
Add user and password to chap-secrets and pap-secrets:
# vi /etc/ppp/chat-secrets
...
"TM" * "TM"
# vi /etc/ppp/pap-secrets
...
"TM" * "TM"
Create the pppd script:
# vi /etc/ppp/peers/gprs
user "TM"
connect "/usr/sbin/chat -v -f /etc/chatscripts/gprs -T internet.t-d1.de"
/dev/modem
115200
debug
nodetach
ipcp-accept-local
ipcp-accept-remote
noipdefault
usepeerdns
defaultroute
replacedefaultroute
persist
noauth
Create the chatscript:
# vi /etc/chatscripts/gprs
ABORT BUSY
ABORT VOICE
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "NO DIAL TONE"
ABORT "NO ANSWER"
ABORT "DELAYED"
ABORT "ERROR"
ABORT "+CGATT: 0"
"" AT
TIMEOUT 12
OK ATH
OK ATE1
OK AT+CFUN=1
OK AT+CGDCONT=1,"IP","\T","",0,0
OK ATD*99#
TIMEOUT 22
CONNECT ""
Now try to connect with the internet using the modem (example output):
# pppd call gprs &
...
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/modem
...
PAP authentication succeeded
...
replacing old default route to wlan0 [192.168.178.2]
local IP address 37.81.154.22
remote IP address 192.168.254.254
primary DNS address 10.74.210.210
secondary DNS address 10.74.210.211
Script /etc/ppp/ip-up started (pid 1765)
Script /etc/ppp/ip-up finished (pid 1765), status = 0x0
After the ppp script is running, you can check the IP for the ppp0 device:
# ip a
...
4: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 3
link/ppp
inet 37.81.154.22 peer 192.168.254.254/32 scope global ppp0
valid_lft forever preferred_lft forever
Depending on your local network connection / local network setup you have to do additional steps to really use the modem's internet connection and not the local network connection. These steps can include:
- DNS setup (/etc/resolv.conf)
- Routing setup (route -n)
- ...
Another interesting fact about the SIM800C modem is, that it has an additional Bluetooth controller available. So far I have only discovered how to activate it, not how to use it in Linux. To activate it, just connect with e.g. minicom again to the modem and run the following commands:
Turn power on:
AT+BTPOWER=1
OK
Query Bluetooth name and address:
AT+BTHOST?
+BTHOST: SIM800C,38:1c:4a:6a:21:ea
OK
As I said, I haven't done too much with the Bluetooth controller on the SIM800C modem so far.
Links:
NanoPi Duo2: http://wiki.friendlyarm.com/wiki/index.php/NanoPi_Duo2
IoT-Box Carrier Board: http://wiki.friendlyarm.com/wiki/index.php/NanoPi_Duo2_IoT-Box
SIM800C AT commands: https://www.waveshare.com/wiki/SIM800C_GSM/GPRS_HAT
No comments:
Post a Comment