element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Arduino MKR  WAN 1300  p2p communication and the MKR ENV shield
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 3 Jul 2020 6:44 PM Date Created
  • Views 5559 views
  • Likes 6 likes
  • Comments 6 comments
  • oled
  • arduino_mkr
  • arduino mkr env
  • 915 mhz
  • lora
  • arduino mkr 1300
Related
Recommended

Arduino MKR  WAN 1300  p2p communication and the MKR ENV shield

carmelito
carmelito
3 Jul 2020

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.

 

image

 

 

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.

image

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

image

 

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.

image

  • Sign in to reply

Top Comments

  • dubbie
    dubbie over 5 years ago +3
    Interesting system. I am impressed that you managed a range of 400 m without problems. How did the RSSI vary? I have undertaken some measurements with RSSI using laptops and the values would vary constantly…
  • dougw
    dougw over 5 years ago in reply to carmelito +3
    That is pretty good. I got about -117 dBm at 400 m and -121 dBm at 783 m using 5dBi gain antennas, with lots of houses obstructing a direct line-of-sight.
  • dougw
    dougw over 5 years ago +2
    Good start. What was the RSSI at 400 m?
  • leehaesung
    leehaesung over 5 years ago

    I'm writing to have problem.  I used your codes for Lora P2P in MKRWAN 1300

    They stuck in LoRa P2P connection.

    The error is blow that.

    "LoRa Receiver"

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 5 years ago in reply to carmelito

    That is pretty good. I got about -117 dBm at 400 m and -121 dBm at 783 m using 5dBi gain antennas, with lots of houses obstructing a direct line-of-sight.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • carmelito
    carmelito over 5 years ago in reply to dougw

    I was getting a RSSI of around -90dBm , and when I placed it on the ground to take a picture it hit -120.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 5 years ago

    Interesting system. I am impressed that you managed a range of 400 m without problems. How did the RSSI vary? I have undertaken some measurements with RSSI using laptops and the values would vary constantly without apparent relationship to the surroundings. I did these measurements inside in a a corridor so it may have been some external varying interference that induced the changes.

     

    I liked the sensor board as well. I have not seen a board with all these four sensors on before - I must lead a sheltered life. Something to look into for the future I think.

     

    Dubbie

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • aswinvenu
    aswinvenu over 5 years ago

    Nice work! Hoping to see more on your RoadTest review.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube