Getting started with NB-IoT the easy way. This project explains how you can connect easily an NB-IoT board. For example, the XYZ-mIoT BC95-G board, over NB-IoT of you local network provider to AllThingsTalk Maker IoT platform.
Narrowband IoT is already deployed in several countries around the world. Before you start, check if NB-IoT is available in your area and when purchasing a SIM card you are able to have following information:
Step 1: Create your device in AllThingsTalk MakerSing in to AllThingsTalk Maker IoT Platform
Select Playground >> New Device
The AllThingsTalk Maker Catalogue will appear.
Select Your Own NB-IoT Device
If in the NB-IoT network provider screen your operator is not listed, click skip
Fill in a name for your device. For example XYZ-mIoT BC95-G. Click Connect.
Now your digital representative of your device is created. Time to create the assets of your board. For this easy example we will create an asset called counter with a profile type integer. Click on create asset.
Select Sensor. Fill in the name "counter" and select integer as profile type. Click Create Asset.
The asset name needs to be "counter" as it needs to match the name "counter" used in the Arduino Sketch.
Your counter asset is now created, but no state or data have been received yet. Time to move to the next step. Do not close your browser yet, we will need it again later on.
The XYZ-mIoT board is shipped with a through-the-hole capacitor. You will need to solder this on the UBat+ and GND pads.
To power the board from USB, you will also need to connect the Vraw and Vusb pins.
Connect the antenna to the UFL connector.
Insert your SIM card.
Download the XYZ-mIoT board support and follow the instructions on Itbrainpower.net.
Step 4: Uploading the example sketchDownload the source code attached to this project.
Place the folder under Arduino >> Libraries.
Open the Keys.h file with an editor. (Notepad or something similar)
Go to AllThingsTalk Maker and the device you have created.
Go to Settings in the top right corner.
Click on Authentication.
Now copy the Device ID and Device Token to the Keys.h file. You can use the copy icon next to the tokens. Device ID and Device Token are unique for each device created in AllThingsTalk Maker.
const char* DEVICE_ID = "xvBmQzsrK7WwdtyblRiFogDe";
const char* DEVICE_TOKEN = "maker:4HkO1OUNbLQ4W1VeVsmmhEN6wvpzvR5RqleO5zw";
Set your APN
const char* APN = "your apn";
In the Keys.h file you also need to fill in the frequency band for your NBIoT network and optional your operator MCC/MNC.
const char* NBIOT_BAND = "20"; //add by Dragos Iosub @ itbrainpower.net
//B1="1"/B3="3"/B8="8"/B5="5"/B20="20"/B28="28"
const char* forceOperator = "20610"; // "20610" for Orange Belgium
Now save and close the Keys.h file.
Open Arduino IDE. Go to File >> Examples >> Arduino-nbiot-sdk-BC95-G >> xyz-mIoT_BC95-G_AllThingsTalk_counter.
Connect the USB cable to the XYZ-mIoT and your PC. The Arduino IDE will automatically recognise the board.
Click upload.
Once uploaded go to Tools >> Serial Monitor
The serial monitor log will first show the initialisation of the BC95-G module, once done the device will be registered on the Orange NBIoT network, the APN will be set.
Setting the operator
>> AT+COPS=1,2,"20610"
[rdResp]: AT+COPS=1,2,"20610"
[rdResp]: OK
Query the signal quality, if response is below 99, 99, it means that the device is recognised by the network
>> AT+CSQ
[rdResp]: AT+CSQ
[rdResp]: +CSQ:99,99
[rdResp]: OK
[rdResp]: AT+CSQ
[rdResp]: +CSQ:13,99
[rdResp]: OK
Request the attach status to the packet domain service. If it becomes 1, the device is attached
>> AT+CGATT?
[rdResp]: AT+CGATT?
[rdResp]: +CGATT:0
[rdResp]: OK
>> AT+CGATT?
[rdResp]: AT+CGATT?
[rdResp]: +CGATT:1
[rdResp]: OK
Creating the UDP socket
>> AT+NSOCR=DGRAM,17,3000,1
[rdResp]: AT+NSOCR=DGRAM,17,3000,1
[rdResp]: 1
[rdResp]: OK
Once the UDP socket is created successfully, transmitting the value of the counter can start. The log will indicate every time a data packet is send.
Counter: 1
>> AT+NSOST=1,40.68.172.187,8891,82,555A67655162374F754C744654626B304C62797A7A6D79530A6D616B65723A3450736E444E446E6A546F4257315665567A5446736674584D397A4D776C7A3376506A6D364A61300AA167636F756E7465720
In AllThingsTalk Maker, the counter asset value will be updated.
For a quick overview in a chart form click on Live
The incoming data can be seen in the debug log.
To forward the data of the assets to your own web application, you can subscribe to the MQTT broker of the Orange Maker IoT Platform with your own MQTT Client.
Here is a tutorial how to forward your data to an MQTT Client.
Comments
Please log in or sign up to comment.