https://doc.lab.cityofthings.eu/w/index.php?title=Special:NewPages&feed=atom&hideredirs=1&limit=50&offset=&namespace=0&username=&tagfilter=&size-mode=max&size=0CityLab Testbed - New pages [en]2024-03-29T08:37:21ZFrom CityLab TestbedMediaWiki 1.35.1https://doc.lab.cityofthings.eu/wiki/Lora_Quick_Start_GuideLora Quick Start Guide2023-04-05T07:11:13Z<p>Dvdakker: /* Experiment Setup */</p>
<hr />
<div>This quick start guide will explain how to get started with the "LoRa" (EFM32GG+RFM95W) an the OpenUSB modules of the Citylab testbed nodes.<br />
== Prerequisites ==<br />
<br />
This quick start guide assumes you already have access to the Citylab Testbed and that you are familiar with the steps required to start experiments. If that is not the case then please follow the [[Getting Started]] guide first.<br />
<br />
<br />
== Experiment Setup == <br />
<br />
* Open the JFed GUI, create a new experiment and drag in two wireless nodes. <br />
[[File:jfed_embedded_setup_01.png|Experiment Setup|480px]]<br />
* Configure the nodes. Make sure that you:<br />
** Set the correct testbed for the node (defaults to w-iLab.2, needs to be set to Citylab)<br />
** Set Disk image to <code>Ubuntu 20.04 LTS 64-bit (CoT) with ARM gcc compiler</code>. This is important as we'll need the ARM gcc toolchain to compile the images for the devices.<br />
** Explicitly set the specific node to use. '''Make sure that the nodes you select are within range of each other!'''. You can use the [https://doc.lab.cityofthings.eu/nodemap/ Node Map] to help you with this.<br />
** name one of the nodes <code>nodeTX</code> and the other one <nodeRX>. You can use other node names but those are the node names that will be used throughout this guide.<br />
[[File:jfed_embedded_setup_02.png|Experiment Setup|600px]]<br />
<br />
* Click "Run" to start the experiment and wait the the nodes to finish initialising. ''Important'': It'll take a bit longer than usual to start the experiment as the <code>Ubuntu 20.04 LTS 64-bit (CoT) with ARM gcc compiler</code> image we're using in this experiment is quite large so it'll take some time to load it onto the nodes.<br />
<br />
== Getting started with the EFM32GG+RFM95W (LoRa) module ==<br />
<br />
To help you get started with the "EFM32GG+RFM95W" module, we've ported the [https://github.com/Lora-net/LoRaMac-node LoraWAN network stack] to the "EFM32GG+RFM95W". This port can be found in the following Github repository:<br />
* https://github.com/imec-idlab/LoRaMac-node<br />
<br />
In this guide, we'll use that repository to set up a basic broadcast tx/rx between two nodes but the stack has many other capabilities as well.<br />
<br />
=== Preparing the receiver node ===<br />
<br />
1) SSH into the <code>nodeRX</code> and clone the <code>LoRaMac-node</code> repository<br />
<pre><br />
git clone https://github.com/imec-idlab/LoRaMac-node<br />
</pre><br />
2) Change to the root dir of the repository<br />
<pre><br />
cd LoraMac-node<br />
</pre><br />
3) Edit the file <code>Makefile.local</code> and make sure it has the following contents:<br />
<pre><br />
TARGET = beacon_rx<br />
CFLAGS += -DUSE_BAND_868=1<br />
CFLAGS += -DUSE_MODEM_LORA=1<br />
</pre><br />
The <code>TARGET</code> line tells the compiler which application to build. The other lines tell the application to use the LoRa radio in the 868MHz band<br />
4) Compile the binary using the <code>make</code> command:<br />
<pre><br />
make -j4<br />
</pre><br />
If all went well you should now have a file named <code>beacon_rx.bin</code> in the local directory. If you get a complaint that no compiler could be found then, most likely you are not using the correct disk image. <br />
5) Flash the binary onto the EFM32GG device using the <code>flash_lora</code> script:<br />
<pre><br />
flash_lora ./beacon_rx.bin<br />
</pre><br />
<br />
6) Use <code>picocom</code> to listen to the serial port of the 'Lora' device<br />
<pre><br />
sudo picocom -b 115200 /dev/ttyLORA<br />
</pre><br />
In the above command:<br />
* <code>115200</code> is the baud rate to use<br />
* <code>/dev/ttyLORA </code> is the path to the serial port of the Lora device. (This is a symlink to the actual 'ttyUSB' device that auto-generated via udev-rules present in all 'CoT' disk images)<br />
<br />
At this point you won't see anything yet, but once the transmitter node has also been prepared you'll see text appearing here<br />
<br />
=== Preparing the transmitter node ===<br />
<br />
The steps needed to prepare the transmitter node are almost identical to the steps needed to prepare the receiver node.<br />
<br />
1) Open a new terminal, SSH into the <code>nodeTX</code> and clone the <code>LoRaMac-node</code> repository<br />
<br />
2) Change to the root dir of the repository<br />
<br />
3) Edit the file <code>Makefile.local</code> and make sure it has the following contents:<br />
<pre><br />
TARGET = beacon_tx<br />
CFLAGS += -DUSE_BAND_868=1<br />
CFLAGS += -DUSE_MODEM_LORA=1<br />
</pre><br />
The only difference between the <code>Makefile.local</code> used here and the one used for the receiver is that we are now building the <code>beacon_tx</code> rather than the <code>beacon_rx</code> app.<br />
The <code>TARGET</code> line tells the compiler which application to build. The other lines tell the application to use the LoRa radio in the 868MHz band<br />
<br />
4) Compile the binary using the <code>make</code> command.<br />
<br />
5) Flash the binary onto the EFM32GG device using the <code>flash_lora</code> script:<br />
<pre><br />
flash_lora ./beacon_tx.bin<br />
</pre><br />
<br />
6) Use <code>picocom</code> to listen to the serial port of the 'Lora' device<br />
<pre><br />
sudo picocom -b 115200 /dev/ttyLORA<br />
</pre><br />
You should now see lines similar to the ones below appearing:<br />
<pre><br />
Sent Packet using LORA. size=16, counter=3 TimeOnAir(us)=52<br />
Sent Packet using LORA. size=16, counter=4 TimeOnAir(us)=52<br />
Sent Packet using LORA. size=16, counter=5 TimeOnAir(us)=52<br />
</pre><br />
<br />
7) Switch back to the terminal of the <code>nodeRX</code> testbed node. You should see lines similar to the ones below appearing<br />
<pre><br />
0x520B4614248AB601,10,-33,25<br />
0x520B4614248AB601,11,-35,25<br />
0x520B4614248AB601,12,-34,26<br />
0x520B4614248AB601,13,-33,24<br />
</pre><br />
In the reported lines, the first field is the UUID of the node sending the beacons, the second field is the sequence number of the packet and the 3rd & 4th fields are the RSSI & LQI of the received beacon packet.<br />
<br />
=== Experiment Cleanup ===<br />
<br />
In both the <code>nodeTX</code> and <code>nodeTX</code> terminals, perform the following actions to clean up the experiment:<br />
<br />
1) Press the 'Control' key and then press the 'A' and 'X' one after the other while holding the 'Control' key pressed down. This control-sequence stops the running <code>picocom</code> program<br />
<br />
2) Run the <code>erase_lora</code> program to wipe the LoRa devices. <br />
<pre><br />
erase_lora<br />
</pre><br />
It is important you do this since otherwise the transmitter node will keep sending beacons.<br />
<br />
== Running Contiki-NG on the OpenUSB Radios ==<br />
<br />
For this guide we re-use the same JFed experiment setup as for the 'LoRa device' (discussed above). In this section we'll flash two OpenUSB devices and ping from one to the other. The guide in this section is based on the [https://docs.contiki-ng.org/en/develop/doc/tutorials/Hello%2C-World%21.html Hello World], [https://docs.contiki-ng.org/en/develop/doc/tutorials/Shell.html Shell] and [https://docs.contiki-ng.org/en/develop/doc/tutorials/IPv6-ping.html IPv6 Ping] tutorials on the Contiki-NG documentation website, but focusses specifically on the OpenMote platform.<br />
<br />
For more information on how to use Contiki-NG consult the Contiki-NG documentation at:<br />
* https://docs.contiki-ng.org/en/develop/doc/tutorials/<br />
* https://github.com/contiki-ng/contiki-ng/wiki<br />
<br />
=== Cloning, Compiling & Flashing the nodes ===<br />
<br />
1) SSH into both the <code>nodeTX</code> and <code>nodeRX</code> experiment nodes in two separate terminals. Then perform the steps below '''on both experiment nodes'''<br />
<br />
2) Clone the contiki-ng git repository<br />
<pre><br />
git clone https://github.com/contiki-ng/contiki-ng/<br />
</pre><br />
<br />
3) Change to the root of the source tree<br />
<pre><br />
cd contiki-ng<br />
</pre><br />
<br />
4) Pull in all submodules (please note: this will take a while)<br />
<pre><br />
git submodule update --init --recursive<br />
</pre><br />
<br />
4) move to the 'app' directory of the <code>hello-world</code> example application<br />
<pre><br />
cd examples/hello-world<br />
</pre><br />
<br />
5) Edit the file <code>hello-world.c</code> and change the following line:<br />
<pre><br />
etimer_set(&timer, CLOCK_SECOND * 10);<br />
</pre><br />
Into the following one:<br />
<pre><br />
etimer_set(&timer, CLOCK_SECOND * 120);<br />
</pre><br />
The reason we do this is because we'll be opening a 'shell' to the device later on and having the "''Hello World''" prompt interrupting the shell session every 10 seconds is annoying.<br />
<br />
6) Edit the <code>Makefile</code> and add the line <code>MODULES += os/services/shell</code> just below the <code>all: $(CONTIKI_PROJECT)</code> line. The end result should look like this:<br />
<pre><br />
CONTIKI_PROJECT = hello-world<br />
all: $(CONTIKI_PROJECT)<br />
<br />
MODULES += os/services/shell<br />
<br />
CONTIKI = ../..<br />
include $(CONTIKI)/Makefile.include<br />
</pre><br />
<br />
7) Run <code>make distclean</code> to ensure the build environment is clean<br />
<br />
8) Compile the hello-world application for the Openmote platform using the following command<br />
<pre><br />
make TARGET=openmote BOARD=openmote-cc2538<br />
</pre><br />
<br />
9) Flash the hello-world application on the device using the following command:<br />
<pre><br />
sudo make TARGET=openmote BOARD=openmote-cc2538 PORT=/dev/ttyOPENUSB hello-world.upload<br />
</pre><br />
<br />
10) Connect with <code>picocom</code> to the serial port of the openmote:<br />
<pre><br />
sudo picocom -c -b 115200 --imap lfcrlf /dev/ttyOPENUSB<br />
</pre><br />
In the above command:<br />
* <code>115200</code> is the baudrate<br />
* <code>-c</code> turns on local echo (so you can see what you type)<br />
* <code>--imap lfcrlf</code> automaticall converts the "\n" printed by the Openmote into "\r\n" so the terminal behaves as you expect it to<br />
<br />
11) Type <code>help</code> and press enter to see a list of all commands available<br />
<br />
=== Pinging from one node to another ===<br />
<br />
If you've followed the steps above you should now have two 'terminal' windows open. One where you are logged in to the serial console of the OpenUSB devices of <code>nodeTX</code> and one where you are logged in to the console of the OpenUSB device connected to <code>nodeRX</code>.<br />
<br />
<br />
12) In the <code>nodeRX</code> terminal, enter <code>ip-addr</code> and press enter to retrieve the link-local address of the Openmote. The result should be similar to this:<br />
<pre><br />
#0012.4b00.0YYY.XXXX> ip-addr<br />
Node IPv6 addresses:<br />
-- fe80::212:4b00:YYY:XXXX<br />
#0012.4b00.0YYY.XXXX><br />
</pre><br />
<br />
13) In the <code>nodeTX</code> terminal, enter the following command:<br />
<pre>ping <ip><br />
</pre><br />
Where <code><ip></code> is the ''ip-address'' of the <code>nodeRX</code>. The result should be similar to this:<br />
<pre><br />
#0012.4b00.0YYY.ZZZZ> ping fe80::212:4b00:YYY:XXXX<br />
Pinging fe80::212:4b00:613:1506<br />
Received ping reply from fe80::212:4b00:YYY:XXXX, len 4, ttl 64, delay 78 ms<br />
</pre><br />
<br />
=== Experiment Cleanup ===<br />
<br />
In both the <code>nodeTX</code> and <code>nodeTX</code> terminals, perform the following actions to clean up the experiment:<br />
<br />
1) Press the 'Control' key and then press the 'A' and 'X' one after the other while holding the 'Control' key pressed down. This control-sequence stops the running <code>picocom</code> program<br />
<br />
2) From the <code>examples/hello-world</code> directory in the contiki-ng source tree, run the following command to wipe the flash on the OpenUSB device:<br />
<pre><br />
../../tools/cc2538-bsl/cc2538-bsl.py -e -p /dev/ttyOPENUSB --bootloader-invert-lines<br />
</pre><br />
It is important you do this since otherwise the OpenUSB devices will remain accessible over the wireless interface.</div>Dvdakker