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 Monitoring: Bee Hive Environmental Monitoring using Arduino MKR 1310
  • 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: aaryan2134
  • Date Created: 23 Apr 2023 1:46 PM Date Created
  • Views 850 views
  • Likes 4 likes
  • Comments 0 comments
  • save the bees
  • savethebeesch
  • the things stack
  • nicla vision
  • Save The Bees - Design Challenge
  • lora
  • arduino pro
  • edge impulse
  • mkr1310
  • mkr wan 1310
  • arduino
Related
Recommended

Bee Monitoring: Bee Hive Environmental Monitoring using Arduino MKR 1310

aaryan2134
aaryan2134
23 Apr 2023

Blog List:

1. Bee Monitoring: Introduction

2. Bee Monitoring: System Design & Workflow

3. Bee Monitoring: Setting up Nicla Vision

4. Bee Monitoring: Training the Model & Inferencing

5. Bee Monitoring: Bee Hive Environmental Monitoring using Arduino MKR 1310

Introduction:

In this blog, we will complete the project by bringing together the Arduino MKR WAN 1310. We will set it up, connect it to the Arduino Cloud and then use various sensors to get data. The goal would be to complete the environmental monitoring system that records all the data from the environment and sends to the Arduino Cloud for processing and creating a monitoring dashboard for the bee care taker. I would also try to see if I can get the results from the Nicla Vision to the Arduino MKR 1310.

Setting up Arduino MKR 1310:

This was a long grinding journey. Let us first understand the connection options and the working. So, here we go:

The first obvious choice for me to setup the Arduino MKR 1310 was using LoRa. But I soon found that it requires 2 boards with LoRa to work. As Nicla Vision doesn't have LoRa support, this soon became the impossible option. But still let us understand LoRa so that we can try the 2nd option which is LoRaWAN

Long Range, Low Power Networks

There are many different terms to be familiar with in the world of LoRa® technology, so let's go through some of them!

LoRa

LoRa is short for long range modulation technique based on a technology called chirp spread spectrum (CSS). It is designed to carry out long-range transmissions with minimal power consumption. LoRa defines as the "lower layer" or "physical layer", according to the OSI model. The physical layer is defined by hardware, signals and frequencies.LoRa uses different radio frequencies depending on where you are located in the world. 

The Arduino MKR WAN 1310 has a LoRa module called Murata CMWX1ZZABZ.

Now, moving on the LoRaWAN

LoRaWAN

LoRaWAN® can be defined as the networking protocol used in an Low-Power, Wide-Area networks (LPWAN). The architecture of the network consists of different gateways that relay messages from low-power devices over long ranges, to central network servers. The protocol is defined as the upper networking layers.

The Benefits of LoRa

There are three distinct benefits of using LoRa technology.

1. Price: LoRa® chips are quite inexpensive for its performance levels. The MKR WAN 1310 is one of the cheapest long-range connectivity boards produced.

2. Low power: Both hardware and software is designed to run on minimal energy, which boosts its value significantly. In present day and future, energy consumption is a large problem to tackle.

3. Long range: To transmit data over long distances brings more accessibility to more remote regions, and is ideal for agricultural, forestry and weather applications.

Secondly, I tried LoRaWAN to send data from the Arduino MKR 1310 to the Arduino Cloud. This would have allowed me to build two independent applications and I could use the Arduino Cloud for the Nicla Vision as well using WIFI. I used this post and this blog to get some inspiration. 

One issue I had before getting started was I didn't have the LoRa antenna with MKR. It was not available in the kit and I tried searching for options online but the shipping charges were huge(it was costing me over Rs 5k to get the antenna which cost approx Rs 500).

 I got the device linked on the Arduino IoT Portal.

image

image

image

Unfortunately, the transmission was not a success. I tried the steps in tutorial to update a counter every 3 minutes but we couldn't get the data transmission step working. This potentially was due to the lack of an antenna or could also be due to the lack of network coverage as the servers were from Australia that were being used to provide coverage in India.

image

image

image

I also thought about getting my own LoRaWAN gateway but the price tag of Rs 22,000 meant this was not an option I could afford.

image

Moving on to the third attempt. This was a mixed bag where I searched various articles, blogs, tutorials etc. I found one attempt by another challenger but they couldn't get it working properly either using I2C communication between Nicla Vision and MKR 1310. Then, I thought about trying to send data directly to the MKR 1310 from the Nicla Vision by using GPIO pins. I could just send a HIGH signal to indicate a certain thing and so on. For this I searched a few forums and found this, this and this. So, I tried I my 4th attempt.

This time I tried to use Edge Impulse to control the GPIO pins on the Nicla Vision. For this, I used their deployment option and created an Arduino Library for the model that I had trained. I then added the library successfully to the Arduino IDE and tried to upload the code to the Nicla Vision. But...

The code just didn't get uploaded at all!

image

image

Seems like I was out of luck on this one and I couldn't get the Nicla Vision and MKR 1310 working together. I tried searching for various alternatives and ideas for weeks but at the end I had to give up and try something else.

Building the Monitoring System:

Finally, I decided to just build the monitoring system on the MKR 1310 and get the output. I had to leave the part of using Cloud to store the data and linking up the Nicla Vision to it.

Linking up the LDR:

Hardware setup:

  1. Connect one LDR pin to +5V
  2. Connect the other pin to Arduino Ground
  3. Connect 1k ohm Resistor to LDR
  4. Connect the LDR pin connected to +3.3V to A0

image

image

Code:

/* Light Intensity using LDR in Lux*/

/* Setup 
   1. Connect one LDR pin to A0
   2. Connect the other pin to Arduino Ground
*/

//constants
int LDRpin = A0;  // select the input pin for LDR
int LDRvalue = 0; // variable to store the value coming from the LDR
int lux = 0;      //to store the intensity of light in 

void setup() {
  //Begin Serial Monitor
  Serial.begin(9600);
}

void loop() {
  
  //Getting the LDR analog value
  LDRvalue = analogRead(LDRpin);
  
  //Using the formula for conversion from analog value to lux
  lux = (512000 / LDRvalue) - 500;

  // Show output on serial monitor
  Serial.print("Intensity: ");
  Serial.print(lux);
  Serial.print(" lux");
}

Linking up the DHT11:

Hardware setup:

image

I used the the EduIntro library for interfacing with the DHT11

The data pin was configured to pin D7.

Code:

/*
DHT11

This example reads a DHT11 sensor hooked up on pin D7. Reads both
temperature and humidity and sends it to the Serial port

created in Feb 2019 by D. Cuartielles
based on work by F. Vanzati (2011) and M. Loglio (2013)

This example code is in the public domain.
*/

// include the EduIntro library
#include <EduIntro.h>

DHT11 dht11(D7);  // creating the object sensor on pin 'D7'

int C;   // temperature C readings are integers
float F; // temperature F readings are returned in float format
int H;   // humidity readings are integers

void setup()
{
  // initialize serial communications at 9600 bps
  Serial.begin(9600);
}

void loop()
{
  dht11.update();

  C = dht11.readCelsius();     	// Reading the temperature in Celsius degrees and store in the C variable
  F = dht11.readFahrenheit();  	// Reading the temperature in Fahrenheit degrees and store in the F variable
  H = dht11.readHumidity();     // Reading the humidity index

  // Print the collected data in a row on the Serial Monitor
  Serial.print("H: ");
  Serial.print(H);
  Serial.print("\tC: ");
  Serial.print(C);
  Serial.print("\tF: ");
  Serial.println(F);

  delay(1000);                // Wait one second before get another temperature reading
}

Linking everything up:

So, finally I had both the sensors linked and working. 

Code:

// include the EduIntro library
#include <EduIntro.h>

DHT11 dht11(D7);  // creating the object sensor on pin 'D7'

int C;   // temperature C readings are integers
float F; // temperature F readings are returned in float format
int H;   // humidity readings are integers

/* Light Intensity using LDR in Lux*/

/* Setup 
   1. Connect one LDR pin to A0
   2. Connect the other pin to Arduino Ground
*/

//constants
int LDRpin = A1;  // select the input pin for LDR
int LDRvalue = 0; // variable to store the value coming from the LDR
int lux = 0;      //to store the intensity of light in 


void setup()
{
  // initialize serial communications at 9600 bps
  Serial.begin(9600);
}

void loop()
{
  dht11.update();
  //Getting the LDR analog value
  LDRvalue = analogRead(LDRpin);
  
  //Using the formula for conversion from analog value to lux
  lux = (512000 / LDRvalue) - 500;

  // Show output on serial monitor
  Serial.print("Intensity: ");
  Serial.print(lux);
  Serial.print(" lux");

  C = dht11.readCelsius();       // Reading the temperature in Celsius degrees and store in the C variable
  F = dht11.readFahrenheit();   // Reading the temperature in Fahrenheit degrees and store in the F variable
  H = dht11.readHumidity();     // Reading the humidity index

  // Print the collected data in a row on the Serial Monitor
  Serial.print("H: ");
  Serial.print(H);
  Serial.print("\tC: ");
  Serial.print(C);
  Serial.print("\tF: ");
  Serial.println(F);

  delay(1000);                // Wait one second before get another temperature reading
}

image

Some pictures of the working system:

image

image

image

Conclusion:


It was a lot of fun working with the Nicla Vision and the Arduino MKR 1310. Though it was filled with challenges, it was a whole journey of learning and building! Finally, the MKR 1310 was able to monitor the environment of the bee hive and the Nicla Vision was able to detect & count bees and classify what was happening in the bee hive using the sound detected by the Nicla Vision inbuilt microphone. Hopefully, in the future I can test this in a real bee hive and see how it works!

Connect with Me:

GitHub - aaryan2134

LinkedIn

  • Sign in to reply
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