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
Just Encase
  • Challenges & Projects
  • Design Challenges
  • Just Encase
  • More
  • Cancel
Just Encase
Blog Monitoring an irrigation canal using LoRa #4
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Just Encase to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: redcharly
  • Date Created: 25 Feb 2022 6:00 PM Date Created
  • Views 802 views
  • Likes 3 likes
  • Comments 0 comments
  • Arduino MKR WAN 1300
  • grove LCD RGB display
  • lora communication
  • just_encase
Related
Recommended

Monitoring an irrigation canal using LoRa #4

redcharly
redcharly
25 Feb 2022

Hi, I'm Carlo Russo and this is the fourth part of my work.

In the past blogs I have presented the kit received, I have tried the LoRaWAN connectivity and I have added a couple of sensors to the transmitter.
Today I will take care of the receiver and, I will use the wonderful LCD display of the Grove kit to view the temperature values of both the water in the irrigation channel and inside the transmitter box.

image

The use of the display is facilitated by the fact that the second box I received in the kit to be tested has a transparent lid and this makes it possible to view the display without having to make holes in the box which, inevitably, would reduce its water resistance.

image

The display can represent 2 lines of 16 characters for which it is necessary to reduce the size of the message to be displayed so that it can be fully displayed.
The format I think looks like this:

Packet No. Box:xx.xxC

Water:yy.yyC

for example:

345 Box:21.98C

Water:27.98C 

I must therefore modify the transmitter and the receiver codes to display this message.

The receiver sketch will also be modified in order to manage the LCD display of the Grove kit.
I used the information contained on the device's web page: https://www.seeedstudio.com/Grove-LCD-RGB-Backlight.html.

First you need to install the library.  https://github.com/Seeed-Studio/Grove_LCD_RGB_Backlight

Simply search using the keywords LCD and RGB to find the Grove LCD RGB Backlight library.

I installed version 1.0.0 and everything worked perfectly.

 

image

Mounting the display is also very simple. It is managed using only four pins, two for the power supply and 2 for the controls.

It uses the I2C protocol and is easily managed by the Arduino MKR1300.

image

Also in this case, as for the transmitter, I will not use the Arduino Base Shield, but I will connect the display directly to the I2C ports on the Arduino MKR1300 board.

rx

Now let's see how the changes to be made to the receiver and transmitter sketches to obtain the temperature readings as described above.

The transmitter:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <LoRa.h>

#define ONE_WIRE_BUS 2

const int B = 4750;               // B value of the thermistor
const int R0 = 100000;            // R0 = 100k
const int pinTempSensor = A0;     // Grove - Temperature Sensor connect to A0
 
OneWire oneWire(ONE_WIRE_BUS); // Set OneWire Connection
DallasTemperature sensore(&oneWire); 
int counter = 0;  //message counter

void setup() {
  sensore.begin();
  if (!LoRa.begin(868E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  delay(1000);
}


void loop() {
  int a = analogRead(pinTempSensor);
  float R = 1023.0/((float)a)-1.0;
  //convert to temperature via datasheet ;
  float temperature=(1.0/((log(R)/B)+(1/298.15)))-273.15;
  
  sensore.requestTemperatures(); // richiesta lettura temperatura
  float celsius = sensore.getTempCByIndex(0);
  // send packet
  LoRa.beginPacket();
  LoRa.print(counter);
  LoRa.print(" Box:");
  LoRa.print(temperature);
  LoRa.print("C ");
  LoRa.print("Water:");
  LoRa.print(celsius);
  LoRa.println("C");
  LoRa.endPacket("!");

  counter++;
  delay(10000);
}

The receiver:

#include <SPI.h>
#include <LoRa.h>
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;

// Setting green LCD
const int colorR = 0;
const int colorG = 255;
const int colorB = 0;
int len;
String first,secondo;

void setup() {
  if (!LoRa.begin(868E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  lcd.setRGB(colorR, colorG, colorB);
  delay(1000);
}

void loop() {
  // try to parse packet
  int packetSize = LoRa.parsePacket();
  if (packetSize) {  // received a packet
  // read packet
  String LoRaLabel = LoRa.readStringUntil('!');
  lcd.clear();
  len = LoRaLabel.length();
  first = LoRaLabel.substring(0,len-15);
  lcd.setCursor(0, 0); //write on first row
  lcd.print(first);
  secondo = LoRaLabel.substring(len-14,len-2);
  lcd.setCursor(0, 1); //write on second row
  lcd.print(secondo);
  }
}

With these changes I will get the data on the display formatted as I had already described.

display

This activity is now over.

In the next one we will provide the boxing of the two circuits and the field test!
Greetings

Carlo

  • 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