RAK13102 WisBlock Blues Notecarrier Module Quick Start Guide
Prerequisite
- Assemble the RAK13102 with a WisBlock Base and WisBlock Core by following the RAK13102 Installation Guide.
- Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
- USB Cable
- GNSS and GSM Antennas
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software Configuration and Example
The RAK13102 WisBlock Notecarrier Module uses I2C serial communication lines. In this example code, you will be able to communicate with the RAK13102 module. This will ensure that your RAK13102 is functional and ready for your IoT project.
- This guide uses the RAK4631 WisBlock Core to demonstrate the configuration and upload process. The example is also compatible with other WisBlock Cores, including the RAK11200 and RAK11310.
- When using RAK11200 as WisBlock Core, configure the BOOT0 pin properly before uploading the firmware. Incorrect BOOT0 configuration may cause the firmware upload to fail. For more information, refer to the RAK11200 Quick Start Guide.
- You need to select first the WisBlock Core you have.
Figure 1: Selecting RAK4631 as WisBlock Core- Before you can use the RAK13102 and the Blues Notecard, you need to open a project in Blues Notehub.IO and get a product UID. Follow the Quickstart guides provided by Blues. Make sure the product UID is saved in the NoteCard during the setup.
- To follow the Blues.IO Quickstart, connect the USB of the RAK13102 module to your computer.
- Next, copy the following sample code into your Arduino IDE:
If you add a RAK1906 environment sensor to the WisBlock Base Board, this example code will read the sensor values from the sensor and transmit them. Without the RAK1906, the code will send.
Click to view the sample code.
//
// Copyright 2019 Blues Inc. All rights reserved.
// Use of this source code is governed by licenses granted by the
// copyright holder including that found in the LICENSE file.
//
// This example contains the complete source for the Sensor Tutorial at dev.blues.io
// https://dev.blues.io/build/tutorials/sensor-tutorial/notecarrier-af/esp32/arduino-wiring/
//
// This tutorial requires an external Adafruit BME680 Sensor.
//
// **********************************************************************
// **********************************************************************
// **********************************************************************
// This example is adapted to work with RAKwireless WisBlock Core module
// It works with the following modules:
// WisBlock Core
// RAK4631
// RAK11200
// RAK11310
// WisBlock Base Boards
// RAK19007
// RAK19001
// WisBlock Sensor
// RAK1906
// **********************************************************************
// **********************************************************************
// **********************************************************************
// Include the Arduino library for the Notecard
#include <Notecard.h> // Click to install library: http://librarymanager/All#Blues-Wireless-Notecard
#ifdef NRF52
#include <Adafruit_TinyUSB.h>
#endif
#include <Wire.h>
#include <Adafruit_BME680.h> // Click to install library: http://librarymanager/All#Adafruit-BME680
Adafruit_BME680 bmeSensor(&Wire);
// This is the unique Product Identifier for your device
#ifndef PRODUCT_UID
#define PRODUCT_UID "" // "com.my-company.my-name:my-project"
#pragma message "PRODUCT_UID is not defined in this example. Please ensure your Notecard has a product identifier set before running this example or define it in code here. More details at https://dev.blues.io/tools-and-sdks/samples/product-uid"
#endif
#define myProductID PRODUCT_UID
Notecard notecard;
uint8_t sync_request_counter = 59;
bool has_rak1906 = false;
J *req;
char prn_buff[2048];
bool blues_send_req(void)
{
char *json = JPrintUnformatted(req);
Serial.printf("Card request = %s\n", json);
notecard.sendRequest(req);
return true;
}
// One-time Arduino initialization
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
// Initialize Serial for debug output
Serial.begin(115200);
time_t serial_timeout = millis();
// On nRF52840 the USB serial is not available immediately
while (!Serial)
{
if ((millis() - serial_timeout) < 5000)
{
delay(100);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
else
{
break;
}
}
digitalWrite(LED_BUILTIN, LOW);
Serial.println("**********************************************");
Serial.println("Blues Notecard Test");
Serial.println("**********************************************");
notecard.setDebugOutputStream(Serial);
// Initialize the physical I/O channel to the Notecard
Wire.begin();
delay(500);
notecard.begin();
Serial.println("**********************************************");
Serial.println("Hub setup:");
Serial.println("**********************************************");
if (!bmeSensor.begin(0x76))
{
Serial.println("Could not find a valid BME680 sensor...");
}
else
{
Serial.println("BME680 Connected...");
bmeSensor.setTemperatureOversampling(BME680_OS_8X);
bmeSensor.setHumidityOversampling(BME680_OS_2X);
has_rak1906 = true;
}
delay(2000);
Serial.println("Get hub sync status:");
// {“req”:”hub.sync.status”}
req = notecard.newRequest("hub.sync.status");
blues_send_req();
Serial.println("**********************************************");
delay(2000);
Serial.println("Get note card status:");
// {“req”:”card.wireless”}
req = notecard.newRequest("card.wireless");
blues_send_req();
Serial.println("**********************************************");
delay(2000);
Serial.println("Get note card version:");
// {“req”:”card.wireless”}
req = notecard.newRequest("card.version");
blues_send_req();
Serial.println("**********************************************");
delay(2000);
}
void loop()
{
Serial.println("**********************************************");
Serial.println("Get hub sync status:");
// {“req”:”hub.sync.status”}
req = notecard.newRequest("hub.sync.status");
blues_send_req();
Serial.println("**********************************************");
Serial.println("Get hub status:");
// {“req”:”hub.status”}
req = notecard.newRequest("hub.status");
blues_send_req();
Serial.println("**********************************************");
delay(2000);
Serial.println("Get note card status:");
// {“req”:”card.wireless”}
req = notecard.newRequest("card.wireless");
blues_send_req();
Serial.println("**********************************************");
delay(2000);
float temperature, humidity, pressure;
if (has_rak1906)
{
if (!bmeSensor.performReading())
{
Serial.println("Failed to obtain a reading...");
delay(15000);
return;
}
temperature = bmeSensor.temperature;
humidity = bmeSensor.humidity;
pressure = (float)bmeSensor.pressure / 100.0;
Serial.printf("Temperature = %.2f *C\n", bmeSensor.temperature);
Serial.printf("Humidity = %.2f %%RH\n", bmeSensor.humidity);
Serial.printf("Pressure = %.2f mBar\n", (float)bmeSensor.pressure / 100.0);
}
else
{
temperature = 28.3;
humidity = 65.7;
pressure = 1008.05;
}
req = notecard.newRequest("note.add");
if (req != NULL)
{
JAddStringToObject(req, "file", "data.qo");
// JAddBoolToObject(req, "sync", true);
J *body = JCreateObject();
if (body != NULL)
{
JAddStringToObject(body, "sensor", "rak4631");
JAddNumberToObject(body, "temperature", temperature);
JAddNumberToObject(body, "humidity", humidity);
JAddNumberToObject(body, "pressure", pressure);
JAddItemToObject(req, "body", body);
}
blues_send_req();
}
req = NoteNewRequest("card.location");
if (req != NULL)
{
blues_send_req();
}
sync_request_counter++;
if (sync_request_counter == 60)
{
sync_request_counter = 0;
Serial.println("Get hub sync status:");
// {“req”:”hub.sync”}
req = notecard.newRequest("hub.sync");
blues_send_req();
Serial.println("**********************************************");
for (uint8_t check = 0; check < 6; check++)
{
Serial.println("Get hub status:");
// {“req”:”hub.sync.status”}
req = notecard.newRequest("hub.status");
blues_send_req();
Serial.println("**********************************************");
delay(10000);
}
}
delay(60000);
}
- You can now select the right serial port and upload the code.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the RAK13102 example codeIf you experience any error in compiling the example sketch, check the updated code for the RAK13102 Module that can be found on the WisBlock Example Code Repository.
- When you successfully uploaded the example sketch, open the Serial Monitor of the Arduino IDE to see the initial logs. If you do not see any logs, you can try to disconnect the USB cable and battery, then reconnect again with the battery first. If you see that the LED of the Notecard on the RAK13102 is blinking after a few seconds, the module is now initialized properly.
Figure 1: RAK13102 initial logs