-
Notifications
You must be signed in to change notification settings - Fork 9
Spice up Raspbian for the IoT
Using the basic WPAN enabled Raspbian image we created using the first guide, we now want to add some software and convenience functionality to use the Pi in IoT projects. That means to init a 6LoWPAN device on system startup and add support for common IoT protocols to Raspbian.
- useful tools when using the terminal
sudo apt install vim screen htop cmake
- some Python add ons
sudo apt install virtualenv python-all-dev python-pip python3-pip
Wouldn't it be nice to have your 6LoWPAN network interface up and running right on system boot? Unfortunately, wpan integration is not fully functionally so you cannot setup these devices using /etc/network/interfaces
like for your other ethernet or wlan interfaces such as eth0
or wlan0
. However, with a little work around providing some helper scripts and a system service definition you can achieve the same. Proceed as follows:
- first clone this repository
sudo mkdir -p /opt/src
sudo chown pi /opt/src
cd /opt/src
git clone https://github.com/riot-makers/wpan-raspbian
cd wpan-raspbian
- next copy some helper (shell) scripts to a well-known location:
sudo cp -r usr/local/sbin/* /usr/local/sbin/.
sudo chmod +x /usr/local/sbin/*
- afterwards copy files for systemd integration
sudo cp etc/default/lowpan /etc/default/.
sudo cp etc/systemd/system/lowpan.service /etc/systemd/system/.
- modify channel and pan id in
/etc/default/lowpan
as needed - optional you can also set the MAC/LLADDR of the lowpan interface, it changes with every boot on default
- and finally activate the low pan autostart in systemd
sudo systemctl enable lowpan.service
- you can check if everything works as expected by running
sudo systemctl start lowpan.service
ip link
# ^^^^ you should see a lowpan0 device, and wpan0
sudo systemctl stop lowpan.service
ip link
# ^^^^ lowpan0 device should be gone, only wpan0
- have a look at the README for details
COAP is one of the major protocols for the Internet of Things, simply said it implements a HTTP-like protocol to query sensors that provide a RESTful interface. For further information on COAP see here and if you want to use COAP for development or testing you may want to install one of the following libraries and tools.
- clone libcoap from Github
$ cd /opt/src
$ git clone https://github.com/obgm/libcoap.git
- configure and build
$ cd /opt/src/libcoap
$ ./autogen.sh
$ ./configure --disable-documentation
$ make
$ sudo make install
- we disable documentation, because otherwise you'll have to install >2GB of dependencies
-
Note:
libcoap
comes with a nice tool for testing namedcoap-client
, so if you have a sensor node with a 802.15.4 transceiver that uses for instance RIOT-OS with microcoap you can query that node. - to run
coap-client
you have to update the dynamic linker cache before:
sudo ldconfig -f /etc/ld.so.conf
coap-client -m GET coap://[ff02::1]/.well-known/core
- install txThings using
pip2
:
sudo pip2 install txThings
- install aiocoap using
pip3
:
sudo pip3 install aiocoap