Linking Autonomo board profile to Arduino IDE (current version of Arduino IDE is 1.8.5)
The Autonomo’s board profile is available through the Arduino Boards Manager. In order to install the board files I added the SODAQ board manager URL on File->Preferences->Additional Board Manager URLs
http://downloads.sodaq.net/package_sodaq_samd_index.json
From the Board Manger (Tools->Board->Board Manger) I installed the SODAQ Boards (SODAQ SAMD boards for the Autonomo).
I configured the actual board rig with Autonomo, LoraBee, antenna, grove shield, solar panel and a lipo battery (3.7V, 1200mAh, 1804, KC 503562P).
Next, I connected the board rig to my computer and from the boards list I selected the SODAQ Autonomo.
For some reason when I requested the Board Info from the Arduino IDE I got BN: SODAQ SARA (!?)
My intention is to compile the SODAQ LoraBee example code (here):
#include <Sodaq_RN2483.h> #include <Wire.h> #include <Sodaq_BMP085.h> #include <Sodaq_SHT2x.h> ////SETTINGS/// // MBili / Tatu //#define debugSerial Serial //#define beePin 20 // Autonomo #define debugSerial SerialUSB #define beePin BEE_VCC ////END SETTINGS//// // LoRaBEE #define loraSerial Serial1 const uint8_t devAddr[4] = { 0x00, 0x00, 0x00, 0x00 }; // USE YOUR OWN KEYS! const uint8_t appSKey[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // USE YOUR OWN KEYS! const uint8_t nwkSKey[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //TPH BMP sensor Sodaq_BMP085 bmp; void setup() { // REMOVE WHEN YOU DONT USE PC while(!debugSerial); debugSerial.begin(57600); loraSerial.begin(LoRaBee.getDefaultBaudRate()); digitalWrite(beePin, HIGH); LoRaBee.setDiag(debugSerial); // optional if (LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, true)) { debugSerial.println("Connection to the network was successful."); } else { debugSerial.println("Connection to the network failed!"); } setupTPH(); } void loop() { debugSerial.println("Sending payload: TempSHT21, TempBMP, PressureBMP, HumiditySHT21"); String reading = takeTPHReading(); //sendPayload((uint8_t*)reading.c_str(), reading.length()); debugSerial.println(); switch (LoRaBee.sendReqAck(1, (uint8_t*)reading.c_str(), reading.length(), 8)) { case NoError: debugSerial.println("Successful transmission."); break; case NoResponse: debugSerial.println("There was no response from the device."); break; case Timeout: debugSerial.println("Connection timed-out. Check your serial connection to the device! Sleeping for 20sec."); delay(20000); break; case PayloadSizeError: debugSerial.println("The size of the payload is greater than allowed. Transmission failed!"); break; case InternalError: debugSerial.println("Oh No! This shouldn't happen. Something is really wrong! Try restarting the device!rnThe program will now halt."); while (1) {}; break; case Busy: debugSerial.println("The device is busy. Sleeping for 10 extra seconds."); delay(10000); break; case NetworkFatalError: debugSerial.println("There is a non-recoverable error with the network connection. You should re-connect.rnThe program will now halt."); while (1) {}; break; case NotConnected: debugSerial.println("The device is not connected to the network. Please connect to the network before attempting to send data.rnThe program will now halt."); while (1) {}; break; case NoAcknowledgment: debugSerial.println("There was no acknowledgment sent back!"); break; default: break; } // Delay between readings // 60 000 = 1 minute delay(30000); } void setupTPH() { //Initialize the wire protocol for the TPH sensors Wire.begin(); //Initialize the TPH BMP sensor bmp.begin(); } String takeTPHReading() { //Create a String type data record in csv format //TempSHT21, TempBMP, PressureBMP, HumiditySHT21 String data = String(SHT2x.GetTemperature()) + ", "; data += String(bmp.readTemperature()) + ", "; data += String(bmp.readPressure() / 100) + ", "; data += String(SHT2x.GetHumidity()); debugSerial.println(data); return data; }
To do so, a number of libraries needed to be installed first. These were Sodaq_RN2483, Sodaq_BMP085, Sodaq_SHT2x. From Sketch->Include Library->Manage Libraries I searched and installed them respectively.
I built the default code with no errors. Next step was to configure the TTN application.
Creating a TheThingsNetwork (TTN) application
Next step was to create the TTN application and device.
I logged in to my TTN account and went to my console: https://console.thethingsnetwork.org/
and clicked on the “Applications” icon.
I clicked on “add application” and filled in Application ID: autonomo-test1, description (blah blah) and Handler: ttn-handler-eu. Application EUI is automatically issued by TTN.
Next, from within the aforementioned application, I clicked on “Devices” and “register device”. I gave it a name “autonomo-01” and from Settings (top right) I changed the Activation Method to ABP.
Finally, from the Device->Overview I copied the following and replaced the respective values on the example code (I used the msb values by clicking the <> hex/C-style conversion icon from the TTN UI):
- Device Address:
- Network Session Key
- App Session Key
// USE YOUR OWN KEYS! const uint8_t devAddr[4] = { 0xXX, 0xXX, 0xXX, 0xF8 }; // USE YOUR OWN KEYS! const uint8_t appSKey[16] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0x39, 0xD4, 0x16, 0xE7, 0xA2, 0xC6, 0xF5, 0x3D }; // USE YOUR OWN KEYS! const uint8_t nwkSKey[16] = { 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xC9, 0x62, 0x49, 0x16, 0xB0, 0x6B, 0xB3, 0x3A };
Next big thing is to actually send something useful and configure the Payload Formats and Integration methods.
Leave A Comment