Tag: IoT

Technical overview of LoRa, LoRaWAN and The Things Network

The Radio Spectrum

Radio-connected devices work within a certain frequency range. The radio spectrum is allocated by government and licensed for specific functions.

For example, broadcast radio currently has a reserved VHF band from 88 to 108 MHz.

Cellular phones have several reserved frequency bands around 900 MHz and 1800 MHz.

The licensees pay for use within these bands. However, there are some specific bands that are made available for low power use, license-free.

2.4GHz is a global band that allows low power unlicensed operation; this is where WiFi and Bluetooth co-exist.

Some license-free bands are allocated differently by each country and LoRa is designed to work in the appropriate band for each country or region. For example, Europe is covered by 863-870MHz, North America, Canada & South America by 902-928MHz. TTN provide details of global frequency plans – https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html

LoRa radio technology

LoRa is a technology that works well within a crowded radio spectrum.

It uses a technique called chirp spread spectrum that creates a signal which is distinguishable by the receiver from the atmospheric noise and signals created by other devices that use simpler modulation techniques, such as On Off Keying (OOK) and Frequency Shift Keying (FSK).

LoRa also takes advantage of a feature called Spreading Factor (SF) where the spreading factors are the duration of the chirp. LoRa operates with SF7-12. SF7 is the shortest time on air, SF12 the longest. Each step up in spreading factor doubles the time on air to transmit the same amount of data.

With the same bandwidth, longer time on air obviously results in less data transmitted per unit of time.

So, with very little output power, the LoRa signal can be detected at great distance or through infrastructure that attenuates the signal. Typically, this could be 1-3km in an urban environment. The current record distance is just over 700km from a node under a helium balloon at a height of 40km, at an output power of only 25mw. For comparison your car key fob works at 2mw for a couple of metres and your phone at up to 1W to the nearest cellphone mast, at most 30km distant.

The trade-off for LoRa is that low power and long distance is traded for limited data rate. Maximum data rate at SF7 is 6kbits/s, reducing to 300bits/s at SF12. One key figure RF engineers discuss is “link budget”, bigger is better and Spreading Factor affects the number where SF12 gives the best chance to receive data. For more information – https://www.semtech.com/uploads/documents/an1200.22.pdf

There are payload size limitations for LoRa – in EU it’s 230 bytes per transmission at SF7, 59 bytes at SF12. Consider LoRa only for telemetry data, such as location, heading, height, temperature, pressure and humidity values or simple on-off actions.

The LoRaWAN protocol

LoRaWAN is a communication protocol that runs on LoRa hardware.

LoRaWAN operates in a star of stars network with ability for multiple gateways to receive and forward data from any nearby node to The Things Network.

Each multi-channel LoRaWAN gateway can scan 8 channels simultaneously and decode up to 8 data packets at the same time. Several packets using different data rates may be demodulated simultaneously even on the same channel.

LoRaWAN provides several modes of operation – modes A, B & C, where B is allocated a time slot and C devices are permanently powered on and receiving.

Most nodes run as mode A devices where they occasionally wake up to transmit a small amount of data and listen for a short time after transmission for any received data. Working like this, it is possible to construct a node that can transmit an update every 30 minutes and run off 2 ‘C’-size alkaline batteries for more than 5 years.

Each mode A node is free to transmit at any time, with the limitation in Europe that each node should not exceed a 1% duty cycle.

There are predictive formulae available to show that the combination of multi-channel gateways, small data packets, operational modes and Spreading Factors results in the capability to handle thousands of nodes per gateway. See “Understanding the Limits of LoRaWAN (Adelantado, Vilajosana et al, IEEE magazine January 2017)” – https://arxiv.org/pdf/1607.08011.pdf

The Things Network originally provided complete LoRaWAN coverage for the city of Amsterdam with just 10 gateways – https://www.thethingsnetwork.org/community/amsterdam/

The Things Network

The Things Network is an open-source, free-to-use solution that provides all functions necessary to:

  • Register a gateway
  • Register a node
  • Handle encryption and decryption of payload data.
  • Route the data between node and the internet using MQTT-broker technology.
  • Queue data for transmission to each node.
  • Monitor and action the process through API

The Things Network does all this and more on a scalable, resilient platform with regional bridge access globally.

https://www.thethingsnetwork.org/docs/network/architecture.html

The Things Network is provided as open-source solution by The Things Industries. Gateways are being made available worldwide by The Things Network community – see https://www.thethingsnetwork.org/community and try it for yourself! it costs less than £200 to setup your own.

The Things Industries also deliver private LoRaWAN solutions with guaranteed SLA, so be assured that you can develop a solution and build it out to a stable product.

For more information, please get in touch – take a look at https://thinnovation.com/remon.html

IoT server development with MeteorKitchen & Cloud9

c9-mk

Once the sensors are in place and your board is publishing data to an MQTT broker, the next steps are to aggregate, display and action. I recommend you try a free account with cloud9 (https://c9.io/c/mdINlHY8cba) and developing in YAML (https://en.wikipedia.org/wiki/YAML) with MeteorKitchen (http://www.meteorkitchen.com/).

From Wikipedia:- “Meteor, or MeteorJS, is a free and open-source JavaScript web framework written using Node.js. Meteor allows for rapid prototyping and produces cross-platform (web, Android, iOS) code. It integrates with MongoDB and uses the Distributed Data Protocol and a publish–subscribe pattern to automatically propagate data changes to clients without requiring the developer to write any synchronization code. On the client, Meteor depends on jQuery and can be used with any JavaScript UI widget library.”

From MeteorKitchen website:- “Meteor Kitchen” is a code generator for Meteor.js. Just describe your application in a simple JSON file and let meteor-kitchen build a complete Meteor application for you. I looked at this and saw that MeteorKitchen also works with YAML and I found this to be a revelation – web development by definition, not having to worry about javascript syntax – you have to try it for yourself!

Cloud9 offers hosted workspaces pre-configured for many common programming platforms and I chose Node.js. Right there in your browser you will see a fully-functional IDE running within a configured Ubuntu instance. In my C9 workspace console I installed Meteor, MeteorKitchen and JSON-YAML parser:

curl https://install.meteor.com/ | sh
curl http://www.meteorkitchen.com/install | /bin/sh
npm install -g js-yaml

There are many examples shown in MeteorKitchen, but as we are discussing IoT, lets take a look at:

https://github.com/perak/kitchen-examples/blob/master/example-iot/example-iot.yaml

The result? – a working reactive web app showing live sensor data, written in 44 lines of code. Enough said, go try!

Samsung IoT platform – wireless everything!

artik5-dev

Samsung recently announced their dev kit for Artik 5 IoT devices. In stock at Digi-Key, priced at £70 and delivered in 3 days. Note that the pic above shows the whole dev kit – Artik 5 is the plug-in board located left of centre. Artik 5 provides ARM7 dual-core CPU @ 1GHz, 512MB LPDDR3 + 4GB eMMC. The module is well-connected wirelessly with WiFI, BLE 4.1 and ZigBee. In addition, there is LoRa (SigFox) and Z-Wave hardware installed on the dev board. To ease development, Arduino connectors and libArduino enable simple prototyping with the Arduino IDE. The eMMC comes with Fedora 22 installed and it took me 30 mins to register on https://developer.artik.io/ configure WiFi and run htop:

Also built-in to the dev board are USB console, MicroSD, audio, 2nd USB port, JTAG, Secure Element – TEE (TrustZone), LiPo battery support and connectors for camera and 480×800 display.

This has to be the most flexible, low-cost and productive way to learn and develop IoT wireless solutions in your favourite coding language – top marks to Samsung! – available here: http://www.digikey.co.uk/product-search/en?keywords=artik

Raspberry Pi Zero – MVP?

Raspberry Pi Zero

I ordered two of these last Thursday from The PiHut (http://thepihut.com/) and they turned up this morning. I am impressed by the size and the immediate compatibility with my existing B+ project. I splashed out on a board only and the bundle with their essential kit.

For this test, I simply transferred the micro-SD card and USB  WiFi adapter from a running B+. The micro USB to standard USB socket came with the kit.

The picture above shows a Raspberry Pi Zero fitted with DIL socket (also provided in the kit) on the GPIO pins so it can sit nicely in the T-Cobbler Plus. Note that the power is supplied via a power monitor that shows current with an active WiFi connection; standalone, running linux, no active apps, current consumption is around 0.08A.

The Zero is an interesting solution for IoT; board area is around 1/3 of the B+, then choose any kind of wireless networking; Bluetooth, WiFi and/or GSM. It runs the same Broadcom chip originally used on the A+, but at a faster clock speed. The GPIO pinout is identical to the B+.

The Raspberry Pi Zero costs £4 quantity 1 – great value!