element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Save The Bees Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Save The Bees Design Challenge
  • More
  • Cancel
Save The Bees Design Challenge
Blog Bee Healthy - Blog 6: Hardware Development - LoRa Module
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Save The Bees Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ralphjy
  • Date Created: 19 Feb 2023 6:54 PM Date Created
  • Views 32323 views
  • Likes 12 likes
  • Comments 3 comments
  • save the bees
  • savethebeesch
  • nicla vision
  • lora
  • nicla sense me
  • mkr wan 1310
Related
Recommended

Bee Healthy - Blog 6: Hardware Development - LoRa Module

ralphjy
ralphjy
19 Feb 2023

Hardware Concept

My plan is to develop two hardware modules, the first LoRa module would contain the MKR WAN 1310 with the Nicla Vision and the second module would contain the Nicla Sense.  The second module would connect to the first via a 6 conductor cable that would provide +5V, GND, I2C SDA/SCL, and 2 GPIO.  My thought is that the first module would mount at the top of the hive near the solar panel and the second with the environment sensors would mount somewhere in the interior.

image

Nicla as a shield

I had not realized that the Nicla boards were designed with pinouts such that they can mount directly onto MKR boards - until I read this tutorial Nicla Sense ME - Use as MKR shield which uses a MKR WiFi 1010.

Looking at the board pinouts, the power (+5V,GND), the I2C (SDA/SCL), and UART (TX/RX) pins align when the Nicla is mounted at the top end of the MKR WAN 1310 connectors.

image

image

image

So, this makes connections in the LoRa module much easier - just plug the Nicla on top.  I added a proto board with a socket for the MKR WAN 1310 so that I could interface a plug-in connector to module 2.  This also provides space for a small LiPo battery in case I want to use this module without the solar module.  The picture below shows the Nicla Sense ME mounted on the MKR WAN 1310 (I don't have the Nicla Vision board yet).  This is the configuration that I used to test the connection to the Things Stack.

image

Then I printed a case to house the boards.  I added mounting holes at the back so that I could add mounting adapters later.

The cutout in the cover exposes the entire top of the Nicla board where the camera, microphone, and other sensors would be.

image

A closeup of the assembly mounted in the case.

image

And the assembly mounted on a tripod with the cover on and off.

image

image

Code used for Things Stack test

Nicla_Sense_as_shield.ino

#include "Arduino.h"
#include "Arduino_BHY2.h"

// Set DEBUG to true in order to enable debug print
#define DEBUG false

void setup(){
#if DEBUG
  Serial.begin(115200);
  BHY2.debug(Serial);
#endif

  BHY2.begin(NICLA_I2C, NICLA_AS_SHIELD);
}

void loop(){
  // Update and then sleep
  BHY2.update(100);
}

MKR1310_Nicla_Sense_THPG_TTN.ino

#include "Arduino.h"
#include "Arduino_BHY2Host.h"
#include <MKRWAN.h>
#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
String appEui = SECRET_APP_EUI;
String appKey = SECRET_APP_KEY;

LoRaModem modem;

// SensorXYZ accel(SENSOR_ID_ACC);
Sensor temperature(SENSOR_ID_TEMP);
Sensor humidity(SENSOR_ID_HUM);
Sensor pressure(SENSOR_ID_BARO);
Sensor gas(SENSOR_ID_GAS);

void setup()
{
  // debug port
  Serial.begin(115200);
//  while(!Serial);

  BHY2Host.begin(false, NICLA_AS_SHIELD);

//  accel.begin();
  temperature.begin();
  humidity.begin();
  pressure.begin();
  gas.begin();

  // change this to your regional band (eg. US915, AS923, ...)
  if (!modem.begin(US915)) {
    Serial.println("Failed to start module");
    while (1) {}
  };
  Serial.print("Your module version is: ");
  Serial.println(modem.version());
  Serial.print("Your device EUI is: ");
  Serial.println(modem.deviceEUI());

  int connected = modem.joinOTAA(appEui, appKey);

//  delay (3 * 60 * 1000);
  
//  if (!connected) {
//    Serial.println("Something went wrong; are you indoor? Move near a window and retry");
//    while (1) {}
//  }
  while(!connected){
  Serial.println("Retry...");
  if(!modem.joinOTAA(appEui, appKey)){
  Serial.println("Fail");
      }
  else{
  break;
     }
   };
  // Set poll interval to 60 secs.
  modem.minPollInterval(60);
  // NOTE: independent of this setting, the modem will
  // not allow sending more than one message every 2 minutes,
  // this is enforced by firmware and can not be changed.
    
}

void loop()
{
  static auto printTime = millis();
  BHY2Host.update();

  int temp = temperature.value() * 100;
  int humid = humidity.value() * 100;
  int press = pressure.value() * 100;
  int gs = gas.value() * 100;
  int err;

  if (millis() - printTime >= 60000) {
    byte payload[4];
    payload[0] = highByte(humid);
    payload[1] = lowByte(humid);
    payload[2] = highByte(temp);
    payload[3] = lowByte(temp);

    modem.beginPacket();
    modem.write(payload, 16);
    err = modem.endPacket(true);
    if (err > 0) {
      Serial.println("Message sent correctly!");
    } else {
      Serial.println("Error sending message :(");
      Serial.println("(you may send a limited amount of messages per minute, depending on the signal strength");
      Serial.println("it may vary from 1 message every couple of seconds to 1 message every minute)");
    }

    printTime = millis();
//    Serial.println(String("Acceleration values: ") + accel.toString());
    Serial.println(String("temperature: ") + String(temperature.value(),3));
    Serial.println(String("humidity: ") + String(humidity.value(),3));
    Serial.println(String("pressure: ") + String(pressure.value(),3));
    Serial.println(String("gas: ") + String(gas.value(),3));
    Serial.println("");
  }
}

  • Sign in to reply
  • shabaz
    shabaz over 2 years ago

    Nice setup! 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • genebren
    genebren over 2 years ago

    Coming along very nicely!  I look forward to future posts on your project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 2 years ago

    Nice update, it looks like you are getting close to trying it out.

    • Cancel
    • Vote Up 0 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