The Air Quality Index (AQI) is a number used mostly by government agencies to indicate the level of pollution to the general public. The AQI is also sometimes referred to as Air Pollution Index (API) or Air Quality Health Index (AQHI). As the AQI increases, it can have adverse health effects on a growing percentage of the population, depending on how worse the air quality gets. Most countries have their own way to calculate an AQI, mainly driven by national air quality standards. What you do see in common however is that they divide the AQI measured into ranges and color and label them so it’s easy for people to understand how much risk they run:

Now how does an AQI get calculated? Well, first of all you need to measure the levels of certain gasses as well as the level of particulates in the air over a certain period. The most common components that get measured and which are used to calculate an AQI are:

Ozone (O3): Ground level Ozone is not directly emitted by something, but is created by sunlight acting on NOx (Nitrogen Oxides) and VOC (Volatile Organic Compound) that exists in the air. Ozone is the primary component of smog and it can cause all kind of respiratory problems, even for instance for healthy people if they exercise under such conditions.

Sulfur Dioxide (SO2): SO2 is mainly formed by emissions from fossil fuels used by power plants and other industries, but also from large ships. If you breathe in SO2, it can irritate the nose, throat, and airways and creates a risk for people with respiratory problems.

Carbon Monoxide (CO): CO is emitted by combustion processes, when there is not enough oxygen for complete combustion. Concentrations of CO are mainly high in areas with large concentrations of cars, trucks etc. CO can cause reduction to the oxygen delivery to the body’s organs like the heart and brain. In large concentrations it can even cause dead.

Nitrogen Dioxide (NO2): NO2 is mainly formed by emissions from cars, buses, trucks, power plants etc., anything that burns fossil fuels. It contributes to respiratory problems as well as the buildup of smog, which both can seriously impact the human health.

Particulate Matter PM10: Also referred to as Dust Particles, has a size between 2.5 to 10 micrometer. These particles can be caused by grinding operations, dust stirred up by vehicles etc. Particle pollution can contribute to a broad range of health problems.

Particulate Matter PM2.5: Also referred to as Fine Particles, has a size of 2.5 micrometer or less. These particles can be caused by combustion processes, but also forest fires. Particle pollution can contribute to a broad range of health problems. These Fine Particles are more dangerous then Dust Particles as they are small enough to enter the blood vessels via the lungs.

To get the measurements for an AQI based on the above mentioned elements, governments often use large and expensive monitoring stations. Due to the cost it’s clear you can only have so many per city. It’s nice if you live close to one as then you have a good indication how healthy your living environment is. Wouldn’t it be nice however if there would be a way to increase the number of measuring stations by providing something smaller and more affordable, so that every community, street could have it’s own station and provide data to indicate to the neighborhood how safe it is, that’s what our next blog post will be about.

During the last LoRa Alliance meeting in Rotterdam we discovered a new LoRa modules made by Shenzhen (China) based company, Dapu Telecom.

There are 4 options available, 2 radio only modules based on SX1272 and SX1276 Semtech chips and two complete modules with MCUs also based on SX1272 and SX1276 called respectively RM7201 and RM7601.

For this exercise, we obtained radios with MCUs. One important note, there is no specific part number for EU, Asia or North America. According to Dapu, the software stack will set the radio into the respective ISM band for your region. This requires further investigation, as small hardware changes between EU and North America (RF part) are present in Semtech’s reference designs.

Here is the RM7601 with MCU and SX1276 radio chip

This is theRM7201 with MCU and SX1272 radio chip

Both of them use the same MCU – STM32L151C8U6, only the radio is different as mentioned above.

If you go to the official Semtech git repository and look at their demo code, you will find out that Semtech uses the STM32L151 MCU series as well, just using a different variant of this MCU. This will most likely allow us to port the Semtech LoraWan stack to DAPU hardware with minimal effort.

Store the source code onto your local hard drive, let’s say C:\LORA\and unzip it, then go to C:\LORA\LoRaMac-node-master\Keil\SensorNode\LoRaMac\classA, use Keil5 (i used Keil5.17 lasted one) to open the project. Why “SensorNode” demo code? because that code uses the same MCU as one used in RM7601 module.

As Semtech used Keil4 to create the LoRaWAN demo code, Keil will first migrate the project to Keil5 when you first open it, just allow it do to so.

In the RM7601 data sheet for the SX1276 radio chip we see the following pin definitions:

following this table, we can quickly change the Semtech source code and update pin definitions in C:\LORA\LoRaMac-node-master\src\boards\SensorNode\board.h to the following pins as follows:

Compile the code and flash it to the RM7601, then login via ssh into your gateway and watch for our updated module to join the gateway. For help on how to set up the Multi-tech gateway, please follow our blog posts:

As with RM7601, I expected simply changes in the config files, but unfortunately, it was not that easy . At the beginning, I’ve tried to use the same project – NodeSensor, but I quickly found out that I would have to port the SX1272 driver as this project does not include support for the SX1272. Porting the SX1272 driver should be easy as most likely it would involve just changing some header definitions. However, after looking deeper into Semtech code, I found another project which does have support for the SX1272, the Loramote project.

As the RM7201 uses a smaller header, my connector would not fit, so i soldered 4 wires (SWCLK, SWIO, VDD and GND) to the RM7201 module directly:

Once installed, try compiling one of the demo programs for Teensy, just to make sure that everything went ok.

Now, we are ready to proceed with actual LoRaMac code. First, Clone the whole package to your system, then add it as new library to your Arduino SDK.

You are almost done ;), just few modifications left…

I will be using defaults with the exception of the DevAddr below.

In the main file, we need to change DevAddr to something unique globally.

static const u4_t DEVADDR = 0x03FF0001 ;

//In this example I used 0x03FFEBB2, you will see it below in the section when we define node manually in gateway's db.

This is equivalent of MAC address associated with your Ethernet port. In production, you will have your own prefix, obtained from IEEE, but for now we can just use anything, as long as it’s not duplicated on your network.

Then, we will adjust Spreading Factor from 11 to 9 to match gateway configuration (as per FCC in North America, Spreading Factor could be between 7 and 10).// Set data rate and transmit power (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF9,14);

Now, you need to use your favoured editor to change the config.h located under arduino libraries (in case of MacOS: /Users/<Your User Name>/Documents/Arduino/libraries/arduino-lmic-v1.5-master/src/lmic to support 915MHz as North American ISM frequency and SX1276 chip for RFM95 HopeRF radio module.#ifndef _lmic_config_h_
#define _lmic_config_h_

// In the original LMIC code, these config values were defined on the
// gcc commandline. Since Arduino does not allow easily modifying the
// compiler commandline, use this file instead. (MK)

Depending if you run gateway or packet forwarder, go to you logs or run mosquitto_sub -t lora/+/up to see incoming packets.

As soon as you run your demo code, you should see something like that:{"chan":7,"cls":0,"codr":"4/5","data":"d29ybGQ=","datr":"SF9BW125","freq":"913.3","lsnr":"-12.8","modu":"LORA","rfch":1,"rssi":-113,"seqn":5,"size":8,"timestamp":"2015-11-18T16:08:51Z","tmst":2397020652}

where “d29ybGQ=” is base64 representation of the word “hi”.

Almost forgot about last cosmetic modification… in order to avoid an extra character at the end of the string, modify// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata), 0);
to // Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(my data)-1, 0);

Enjoy and stay tuned…

Soon, I will share my experience with modules from one of the new LoRa node makers from China.

I will also experiment with LoRa range, explaining ways to get the most from your node…