BastWAN [1] is all the best in the world format Feather and LoRa® communication. You will be able to connect to a LoRa® server, receiving from and sharing data. Designed to wirelessly connect battery-operated “things” to the Internet in regional, national, or global networks, and targets key Internet of Things (IoT) requirements such as bidirectional communication, end-to-end security, mobility, and localization services.
What will we learn?In this tutorial, we will use a GY-BME/P280 module (BMP280 Bosch sensor) to get environment data such as temperature, humidity, and barometric pressure; then, BastWAN will receive and process this data in order to send it to The Things Network (LoRaWAN® server). We will use our Beelan-LoRaWAN [2] library to establish the LoRaWAN® communication between the End Device (BastWAN) and the server (The Things Network); furthermore, using our CayenneLPP [3] library, we will decode the information sent to TTN (The Things Network) in order to read it in a more representative format.
Once you have completed this exercise, you will be able to:
- Create applications on TTN
- Add and configure devices to work with your TTN applications
- Understand the main settings for LoRaWAN® devices, in order to join LoRaWAN® servers
- Use some basic functions from Cayenne LPP
LoRa® is a proprietary low-power wide-area network (LPWAN) modulation technology developed by Semtech. It is the physical layer modulation scheme that enables long-range communication with low power consumption. LoRa uses chirp spread spectrum modulation, allowing it to achieve long-range communication while operating in the sub-GHz frequency bands.
LoRaWAN ® stands for “Long Range Wide Area Network”. It is a communication protocol and network architecture built on top of LoRa. LoRaWAN provides the higher layers of the protocol stack, including network topology, security, and application interfaces. It defines the communication protocol between LoRa devices and the LoRaWAN network server. LoRaWAN operates in a star-of-stars topology, where LoRa devices (also known as end nodes or sensors) communicate with LoRaWAN gateways, which act as base stations.
First, let's understand our application:
- BastWAN is our End Node. Of course, BMP280 is part of our End Node, but it is just a sensor. BastWAN is like the “speaker man” that will manage and send the data.
- Gateway: you need to be sure that there is a gateway around that covers your area, also, you must know over which band it is working. Without this information, it is like you go and knock on the wrong door.
- The Things Network (TTN) is our Network Server. It will receive the readings of BMP280, sent from BastWAN.
Please, consider that you need to have installed Arduino IDE 1.6.6 (or a later version) on your PC. Furthermore, you need to install our Electronic Cats Boards core to be able to upload the sketch we will use in this exercise. If any of the previous is missing, please go to our BastWAN's wiki.
In addition, we are assuming that you already have an account with TTN [4], so we will skip this step. If not, you will need to create yours.
1. Log in to your account. On the right-upper side of the page, go to your profile iconand look for “Console” in the dropdown list. Click on it.
2. You need to select your country and a network cluster. North American cluster is recommended, but you can select another one, maybe depending on your geographical location.
3. The main menu shows the option for Applications and Gateways. In this article, we will be focused on Applications. Click on it.
4. You will be driven to the Applications tab. If you have just created an account, this section will be empty. Click on the “Create application” button.
5. Fill in the blanks for your application info. The name must be written in lowercase, with no spaces (use dash). The Name and Description blanks do not have rules.
6. Once your application is created, you can register your device.
There are some device brands listed in the LoRaWAN Device Repository.
If your device is not listed, select “Enter end device specifics manually”.
We selected US915, FSB2 (frequency sub-band 2) since we had a gateway configured for working over this band. Remember, this data could differ for you. Set the one according to your resources. Select LoRaWAN version 1.0.0.
In this application, we will work with ABP mode, setting our device as Class A.
If you want to learn more about the end devices activation methods and LoRaWAN classes, please visit:
Finally, you will be asked to type the “credentials” for your device.
As seen in the picture above, all the information can be generated by clicking on the “Generate” button. For the DevEUI field, you can also use the one given by the manufacturer to your device.
Some additional information about the credentials:
- DevEUI: is a 64-bit globally-unique Extended Unique Identifier (EUI-64) assigned by the manufacturer, or the owner, of the end device. [5]
- Device Address: A DevAddr is assigned during the join process for devices that join a network. It is composed of two parts: the address prefix and the network address. [6]
- AppSKey: is used for encryption and decryption of the payload. This means that nobody except you is able to read the contents of messages you send or receive.
- NwkSKey: is used for interaction between the Node and the Network Server. This key is used to validate the integrity of each message by its Message Integrity Code (MIC check). This MIC is similar to a checksum, except that it prevents intentional tampering with a message. [7]
Your device is already set on TTN!
7. Make the connections between BastWAN and BMP280 module sensor.
8. Upload the code shared in the “Code” section. Note that you need to type your device's credentials in the specified variables: *devAddr, *nwkSKey, and *appSKey. This way, your device will be identified by the server.
Once done, open the Serial Monitor to confirm the readings:
To take the readings, we used a cup of hot water. The testing was done using the steam of the hot water, also, we test it by approaching the sensor directly to the cup (touching the porcelain with the BMP280 sensor). The next video shows the real-time data display from TTN, using the Cayenne LPP format.
If you got until this point, congratulations! You are done.
We kindly invite you to take our course for LoRa® and LoRaWAN® protocols. Available at our official website:
RESOURCES
[5] Semtech. [Online]. Available in: https://learn.semtech.com/mod/book/view.php?id=171&chapterid=91
[6] Semtech. [Online]. Available in: https://learn.semtech.com/mod/book/view.php?id=171&chapterid=100
[7] The Things Network Docs. [Online]. Available in: thethingsnetwork.org/docs/lorawan/security/
Comments
Please log in or sign up to comment.