I am road testing https://www.element14.com/community/roadTests/2184/l/Arduino-MKR-WAN-1300-+-ENV-Sensor-Shield , and this is simple point to point communication test using two Arduino MKR 1300. As part of the test I am using an Arduino MKR Environment shield on one of the MKR 1300 boards and other board is connected to an OLED display to show the Temperature, Humidity , Illuminance, and UVIndex. In addition as you see in the picture below, I am also keeping track of the packet count and RSSI value.
Now before you get started you will have to install MKRWAN Library and also update the latest firmware on the MKR 1300 using the MKRWANFWUpdate_standalone sketch, you should find this in the example menu are the library is installed.
In addition I had to install the LoRa library to use the Sender and Receiver sketches below, and the Arduino_MKRENV for the MKR ENV environmental shield.
Here is the Sender code, uploaded on the MKR 1300 connected to the MKR ENV shield
#include <SPI.h> #include <LoRa.h> #include <Arduino_MKRENV.h> int counter = 0; String val=""; void setup() { Serial.begin(9600); //while (!Serial); if (!ENV.begin()) { Serial.println("Failed to initialize MKR ENV shield!"); while (1); } Serial.println("LoRa Sender"); if (!LoRa.begin(915E6)) { Serial.println("Starting LoRa failed!"); while (1); } } void loop() { // MKR ENV read all the sensor values float temperature = ENV.readTemperature(); float humidity = ENV.readHumidity(); float pressure = ENV.readPressure(); float illuminance = ENV.readIlluminance(); float uva = ENV.readUVA(); float uvb = ENV.readUVB(); float uvIndex = ENV.readUVIndex(); val = "PacketCount: "+String(counter)+"\nT: "+String(temperature)+ " H: "+String(humidity)+"\nI: " + String(illuminance)+ " uvI: " + String(uvIndex); //+"\nUva:"+String(uva)+ " Uvb:"+String(uvb)+ "\nuvI:"+String(uvIndex); Serial.println(val); Serial.println("------------------------------------"); Serial.println(); Serial.print("Sending packet: "); Serial.println(counter); LoRa.beginPacket(); LoRa.print(val); LoRa.endPacket(); counter++; // this help keep track if the packet is recived on the sender side delay(5000); }
Serial monitor output from the sender
And the sketch for the receiver MKR 1300, connected to the OLED using I2C, don't forget to install the SSD1306 and Adafruit_GFX libraries
#include <SPI.h> #include <LoRa.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 32 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); String vals =""; void setup() { // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32 Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } display.display(); delay(2000); display.clearDisplay(); Serial.begin(9600); //while (!Serial); Serial.println("LoRa Receiver"); if (!LoRa.begin(915E6)) { Serial.println("Starting LoRa failed!"); while (1); } } void loop() { int packetSize = LoRa.parsePacket(); if (packetSize) { // received a packet Serial.print("Received packet '"); // read packet while (LoRa.available()) { vals= LoRa.readString() +"\nRSSI: " +LoRa.packetRssi(); Serial.println(vals); } } display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0,0); display.println(vals); display.display(); }
In addition, I also took the receiver module for a walk with the sender connected to my laptop at home with a simple sketch loaded, and I would have walked for approximately 400 to 500 meters from the home, and was still receiving packets, I decided to turn back as I am still recovering from an ankle injury. I will have a proper range test done with the antenna's as part of the road test.
And the antenna's that you see attached on the board are 915 MHz from TTGO LoRa32 SX1276 with ESP32 and SSD1306 OLED boards that I purchased about a year ago.
Top Comments