Sketch \/ Include Library \/ Manage Libraries…<\/strong> menu, and RN2483<\/tt> as filtering string.<\/p>\nSodaq provides a sample code that periodically reads a value from the board temperature sensor, and sends it over the LoRaWAN network. Modify it with above identifiers and key, set OTAA<\/tt> to true<\/tt>, and slightly modify setupLoRaOTAA()<\/tt> code so that it does not perform two successive initializations.<\/p>\n
You get something like:<\/p>\n
#include <Sodaq_RN2483.h>\n\n#define debugSerial SerialUSB\n#define loraSerial Serial2\n\nbool OTAA = true;\n\n\/\/ ABP\n\/\/ USE YOUR OWN KEYS!\nconst uint8_t devAddr[4] =\n{\n 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ USE YOUR OWN KEYS!\nconst uint8_t appSKey[16] =\n{\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ USE YOUR OWN KEYS!\nconst uint8_t nwkSKey[16] =\n{\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n\/\/ OTAA\nconst uint8_t DevEUI[8] =\n{\n 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x88\n};\n\nconst uint8_t AppEUI[8] =\n{\n 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00\n};\n\nconst uint8_t AppKey[16] =\n{\n 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00\n};\n\nvoid setup()\n{\n while ((!debugSerial) && (millis() < 10000)){\n \/\/ Wait 10 seconds for debugSerial to open\n }\n \n debugSerial.begin(57600);\n loraSerial.begin(LoRaBee.getDefaultBaudRate());\n \n setupLoRa();\n}\n\nvoid setupLoRa(){\n if(!OTAA){\n \/\/ ABP\n setupLoRaABP();\n } else {\n \/\/OTAA\n setupLoRaOTAA();\n }\n}\n\nvoid setupLoRaABP(){ \n if (LoRaBee.initABP(loraSerial, devAddr, appSKey, nwkSKey, false))\n {\n debugSerial.println(\"Communication to LoRaBEE successful.\");\n }\n else\n {\n debugSerial.println(\"Communication to LoRaBEE failed!\");\n }\n}\n\nvoid setupLoRaOTAA(){\n\n bool res = LoRaBee.initOTA(loraSerial, DevEUI, AppEUI, AppKey, false);\n debugSerial.println(res);\n \n if (res)\n {\n debugSerial.println(\"Network connection successful.\");\n }\n else\n {\n debugSerial.println(\"Network connection failed!\");\n }\n}\n\nvoid loop()\n{\n String reading = getTemperature();\n\n switch (LoRaBee.send(1, (uint8_t*)reading.c_str(), reading.length()))\n {\n case NoError:\n debugSerial.println(\"Successful transmission.\");\n break;\n case NoResponse:\n debugSerial.println(\"There was no response from the device.\");\n break;\n case Timeout:\n debugSerial.println(\"Connection timed-out. Check your serial connection to the device! Sleeping for 20sec.\");\n delay(20000);\n break;\n case PayloadSizeError:\n debugSerial.println(\"The size of the payload is greater than allowed. Transmission failed!\");\n break;\n case InternalError:\n debugSerial.println(\"Oh No! This shouldn't happen. Something is really wrong! The program will reset the RN module.\");\n setupLoRa();\n break;\n case Busy:\n debugSerial.println(\"The device is busy. Sleeping for 10 extra seconds.\");\n delay(10000);\n break;\n case NetworkFatalError:\n debugSerial.println(\"There is a non-recoverable error with the network connection. The program will reset the RN module.\");\n setupLoRa();\n break;\n case NotConnected:\n debugSerial.println(\"The device is not connected to the network. The program will reset the RN module.\");\n setupLoRa();\n break;\n case NoAcknowledgment:\n debugSerial.println(\"There was no acknowledgment sent back!\");\n break;\n default:\n break;\n }\n \/\/ Delay between readings\n \/\/ 60 000 = 1 minute\n delay(10000); \n}\n\nString getTemperature()\n{\n \/\/10mV per C, 0C is 500mV\n float mVolts = (float)analogRead(TEMP_SENSOR) * 3300.0 \/ 1023.0;\n float temp = (mVolts - 500.0) \/ 10.0;\n \n return String(temp);\n}<\/pre>\nCompile and load the sketch. Display the monitor window (Tools \/ Serial Monitor<\/strong>), and set its speed to 57600<\/strong>.<\/p>\nIf you are under Orange LoRaWAN coverage, you should see following messages:<\/p>\n
1\nNetwork connection successful.\nSuccessful transmission.<\/pre>\nand sent data should be available from Live Objects website:<\/p>\n
<\/p>\n
That’s it.<\/p>\n","protected":false},"excerpt":{"rendered":"
This post explains how to transmit data over French Orange LoRaWAN network using a SODAQ ExpLoRer board.<\/p>\n","protected":false},"author":2,"featured_media":438,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,17],"tags":[],"_links":{"self":[{"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/posts\/436"}],"collection":[{"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/comments?post=436"}],"version-history":[{"count":16,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/posts\/436\/revisions"}],"predecessor-version":[{"id":1093,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/posts\/436\/revisions\/1093"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/media\/438"}],"wp:attachment":[{"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/media?parent=436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/categories?post=436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systev.com\/wp-json\/wp\/v2\/tags?post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}