IOT-GATE-RPi: Raspbian

From Compulab Mediawiki
Revision as of 11:50, 21 March 2018 by Rinata (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

IOT-GATE-RPi comes with a Raspbian Linux image. Raspbian Linux is a free operating system based on Debian optimized for the Raspberry Pi hardware. It is the official supported operating system for Raspberry Pi. Raspbian Linux image includes more than 35,000 software packages. Among them:

  • Core system
  • Debian package management system
  • X11 Windowing System
  • LXDE desktop manager
  • SSH server and client
  • Python, Scratch, Sonic Pi, Java and Mathematica

Additional images can be used with IOT-GATE-RPi. All optional images can be found in Raspberry Pi downloads. The IOT-GATE-RPi: Raspbian: Manual Installation page provides a brief introduction on how to install the Rasbian image.

Using Raspbian Linux on IOT-GATE-RPi

Connection and Logging In

To login into the Linux system, use a keyboard and display or a serial console, connect through the network (ssh).

Use the following username and password to login:

raspberrypi login: pi
Password: raspberry

Networking

For most home networks, no further configuration is required in order to be able to connect to the Internet. For this to work, the router should be configured for DHCP (Dynamic Host Configuration Protocol).

To configure networking, edit /etc/network/interfaces and /etc/dhcpcd.conf. For more information about Debian Linux network configuration read:

The majority of network setup can be done via the interfaces configuration file at /etc/network/interfaces.

Admolition note.png auto line is required for interfaces that have to be brought up at boot time.
  • Using DHCP to automatically configure the interface
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
  • Configuring the interface manually
auto eth0
    iface eth0 inet static
        address 192.168.1.170
        netmask 255.255.0.0
        gateway 192.0.0.1

RTC

Accessing and setting the RTC

To access the RTC time and date run:

root@cm-debian:~# hwclock
Sat Jan 1 00:00:00 2000 -10.011159 seconds

To set the date and write it into the RTC do the following:

root@cm-debian:~# date -s "31 JUL 2015 10:00:00"
Fri Jul 31 10:00:00 UTC 2015
root@cm-debian:~# hwclock -w
root@cm-debian:~# hwclock
Fri Jul 31 10:00:13 2015  -1.066224 seconds

Wifi

IOT-GATE-RPi features 802.11b/g/n wireless connectivity solution.

WiFi Initialization

  • WiFi requires no user interaction for being configured. The drivers get loaded automatically.

Make sure that the WiFi drivers are loaded:

root@cl-rootfs:~# lsmod
rt2800usb                 18824  0
rt800lib                  80070  1
rt2x00usb                 12798  1
rt2x00lib                 48694  3

The WiFi driver can be loaded manually using modprobe.

  • iwconfig command from wireless-tools package can be used to retrieve detailed information about the WiFi interfaces:
root@cl-rootfs:~# iwconfig wlan0
wlan0     IEEE 802.11abgn  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
  • Activate the interface:
root@cl-rootfs:~# ifconfig wlan0 up
  • Sample WiFi scanning:
root@cl-rootfs:~# iwlist wlan0 scan

The output will show the list of Access Points and Ad-Hoc cells in range. For more information about connecting to wireless networks and tuning WiFi interfaces refer to wpa_supplicant and wireless-tools man pages.

wpa_supplicant

  • Configuration sample

Please open a wpa_supplicant configuration file bellow and put a network name and a password into the "ssid" and "psk" fields respectively.

root@cl-rootfs:~# cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant

network={
	ssid="wireless_network_name"
	key_mgmt=WPA-PSK
	psk="wireless_network_password"
}
  • Sample run
root@cl-rootfs:~# ifconfig wlan0 up
root@cl-rootfs:~# wpa_supplicant -B -Dwext -c /etc/wpa_supplicant.conf -i wlan0
root@cl-rootfs:~# dhclient wlan0

4G/3G Cellular Modem

IOT-GATE-RPi is equipped with an on-board micro-SIM card socket and support cellular communication using 4G/3G cellular modem with USB interface in mini-PCIe form-factor.

The following 3G cellular modules have been tested:

In order to use 4G/3G cellular modem the several software packages have to be installed.

Admolition note.png iot-gate-rpi_raspbian_2018-01-24.zip contains the package rpi3-modem which takes care of all needed package installations.

When using the image burned to the eMMC provided by us, there is no need to install additional packages because rpi3-modem is allready installed. In both cases continue to the Loading kernel modules section.

Installing Debian packages

root@cm-debian:~# apt-get install libpcap0.8 libuniconf4.6 libwvstreams4.6-base libwvstreams4.6-extras ppp wvdial

Loading kernel modules

Device driver modules require no user interaction and get loaded automatically. If for some reason device driver modules are not loaded automatically, please load them manually:

  • USB Driver for GSM modems and Qualcomm MSM Interface (QMI) WWAN driver are required for SIMcom modules:
root@cl-som-imx7-sid:~# modprobe option
root@cl-som-imx7-sid:~# modprobe qmi_wwan
  • USB Abstract Control Model driver is required for Telit HE910-D:
root@cl-som-imx7-sid:~# modprobe cdc-acm

Point-to-Point protocol (PPP) drivers must be loaded manually prior to dialing:

root@cl-som-imx7-sid:~# modprobe ppp_generic
root@cl-som-imx7-sid:~# modprobe ppp_async
root@cl-som-imx7-sid:~# modprobe ppp_synctty
root@cl-som-imx7-sid:~# modprobe bsd_comp
root@cl-som-imx7-sid:~# modprobe ppp_deflate

WvDial

WvDial is a Point-to-Point Protocol dialer that automatically detects modem, and can log into almost any Internet Service Provider without a complicated configuration. First, edit the wldial configuration file. Please use the a correct ISP APN instead of YOUR_ISP_APN stub:

root@cl-som-imx7-sid:~# cat /etc/wvdial.conf
[Dialer cellular]

# Your modem device. Usually /dev/ttyUSB0 or /dev/ttyACM0
#Modem = /dev/ttyACM0
Modem = /dev/ttyUSB3

# Port speeds that're worth testing:
# 921600
# 460800
# 115200
#  57600
Baud = 115200

# If your SIM card has a PIN, comment this line, uncomment the next one, and
# change the PIN shown to your PIN.
Init = ATZ
# Init = ATZ+CPIN="0000"

# If you know your ISP's APN, specify it instead of YOUR_ISP_APN below.
# If you don't, you may be able to find out on the 'net, or from tech
# support.
#
# There's also an APN table at https://wiki.ubuntu.com/NetworkManager/Hardware/3G .
#
# If you can't find it, you might be able to dial out without setting an APN
# (especially from a mobile phone). Just comment this line and uncomment
# the next one.
Init2 = AT+CGDCONT=1,"IP","YOUR_ISP_APN"
#Init2 = AT+CGDCONT=1,"IP"

# Most services/devices dial with *99# . A few seem to require *99***1#
Phone = *99#

# These often suffice, but your ISP might require different details. They're
# often dummy details used for all users on the ISP, frequently the ISP's
# name, but some ISP's do require you to use a real username and password.
Username = dummy
Password = dummy

The following command can be used for dialing:

root@cm-debian:~# wvdial cellular &

GPIO access

Linux provides simple and convenient GPIO access via sysfs interface. A GPIO should be exported using /sys/class/gpio/export. After the GPIO is exported it is possible to change its direction and value using /sys/class/gpio/gpioX/direction and /sys/class/gpio/gpioX/value attributes.

Example

The following example demonstrates how to configure GPIO 140 as output and set value to high:

root@cl-rootfs:~# echo 140 > /sys/class/gpio/export
root@cl-rootfs:~# echo out > /sys/class/gpio/gpio140/direction
root@cl-rootfs:~# echo 1 > /sys/class/gpio/gpio140/value
Admolition note.png The above example assumes that the pinmux configuration of the corresponding pin is set to GPIO mode and the GPIO 140 is not requested in the Linux kernel.

See also