How to Get Sensor Data From a Remote Arduino Via Wireless Lora Protocol


29,667

121

24

Introduction: How to Get Sensor Data From a Remote Arduino Via Wireless Lora Protocol

This is an example to show how to get sensor data from a remote Arduino via Wireless Lora Protocol.
The exampels requries below hardwares:

1) Client Side: Arduino + Lora Shield (868Mhz) + DS18B20 (Temperature Sensor).

2) Server Side: Arduino + Lora Shield (868Mhz) + Yun Shield + USB flash.

make sure the USB flash has this file datalog.csv in the data directory of root.

Requrie below software: Radiohead library from: http://www.airspayce.com/mikem/arduino/RadioHead/...

Client side will get the temperature and keep sending out to the server via Lora wireless. Server side will listin on the Lora wireless frequency, once it get the data from Client side, it will turn on the LED and log the sensor data to a USB flash.

Follow the next operations to complete this project.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Preparations

In this project,you need the things below:

  • Arduino board x 2 (We use the MEGA2560 here)
  • Dragino Lora Shield v1.3 x 2 (We use 868MHZ here)
  • Yun Shield v1.1.6 x 1
  • USB flash x 1
  • DS18B20 x 1 (Temperature sensor)
  • Bread board x 1
  • 868MHZ antenna x 2
  • USB cable x 2
  • LED x 2
  • 4.7k resistance x 1
  • Some jump wires
  • Power supply

Note:

About the Yun Shiled,we must use the Yun Shield v1.1.6/Yun Shield v2.2.4 or higher version

Step 2: Connections

In this step,we need to assemble the client and the server separately.Follow above pictures,and make sure

you got everything ready.

NOTE:

  • The data wire is plugged into port 3 on the Arduino (Client)
  • The LED is on the GPIO 4 (Server)
  • Put the ant on the boards
  • Create a directory named “data” in the USB flash root and create a file data.csv in this directory.

.

Step 3: Codes

Power them by Power supply,and connect them to the computer via USB cable.

Client

Open the IDE(Over here,we use the version 1.6.8),choose the correct port and correct board for your client.Upload the client sktech to the arduino board,you can find the code here:

https://github.com/dragino/Lora/blob/master/Lora%20Shield/Examples/Lora_Temperature_RadioHead/get_temp_data_and_sent_to_the_Lora_Server/get_temp_data_and_sent_to_the_Lora_Server.ino

Server

Upload the server sktech to the arduino as above,youcan find the code here:

https://github.com/dragino/Lora/blob/master/Lora%20Shield/Examples/Lora_Temperature_RadioHead/get_data_from_lora_node_and_store_in_USB/get_data_from_lora_node_and_store_in_USB.ino


Step 4: Running Result

After the last step,you can see the LED on the server will flash once per second.Open the Serial Monitor of the client,you can see the temperature info obtained through the sensor and the communication between client and server.Open the Serial Monitor of the server,you can also get the server status.

Then,enter the USB flash by WinSCP.Open "/mnt/sda1/data/datalog.csv" and you will see the stored information(time stamp with the real-time temperature) as the last photo at this step.

Step 5: ​ Usage Notice of Lora Shield

You have to be aware that Radio link quality and performances are highly dependent of environment.

Better performances can be reached with:

  • Outdoor environment.
  • No obstacles.
  • No high level radio interferer in the ISM 868MHz band.
  • At least 1 meter above the ground.

Radio performances are degraded with:

  • Obstacles: buildings, trees...
  • Inner buildings environments.
  • High ISM 868MHz band usage by other technologies.

Radio communication are usually killed with bad topographic conditions. It is usually not possible to communicate through a hill, even very small.

Step 6: Reference

Be the First to Share

    Recommendations

    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest
    • Fix It Contest

      Fix It Contest

    24 Discussions

    0
    DavidGuo
    DavidGuo

    3 years ago

    Yes,you can use the Uno board,but the Mega2560 could be better,the Mega2560 have more RAM space for the code

    0
    bryan chuah
    bryan chuah

    Reply 1 year ago

    hi david, i need some help one how to send more than one sensor data to my receiver. Wish you could help, Thanks

    0
    bryan chuah
    bryan chuah

    1 year ago

    hi david, may i know how do i send multiple sensor data to the server node then upload to the cloud? As for now i am only able to send one sensor data.

    0
    Dimagoreev
    Dimagoreev

    1 year ago

    Hello, could you help me with sample ?

    How I can save data from Client to Server and next step to PC in data file ?

    0
    YimengZ2
    YimengZ2

    2 years ago

    Hi David,

    Thanks for this post. I'm wondering if it is possible to make the data to a Lorawan Server e.g. The Things Network etc. I'm trying to set the arduino as the gateway but I'm not sure this can make the captured data be written into the server.

    0
    GiovanniG43
    GiovanniG43

    2 years ago

    Hi, I would like to know if me using an ethernet shield v2 would work the same way, i know i got to change the program but would it be possible to do this with an ethernet shield and the micro sd card instead of an yun shield and the usb?

    0
    GiovanniG43
    GiovanniG43

    Reply 2 years ago

    Thank you already!

    0
    wisnubramantyo
    wisnubramantyo

    2 years ago

    Hi David,

    In my case when I uploaded the server sketch and open the serial monitor it showed me nothing but (???) signs continously.

    Could you tell me what went wrong? Thank you.

    Screenshot from 2017-08-10 01-54-49.png
    0
    diy_bloke
    diy_bloke

    2 years ago

    Is the Lora shield compatible with the ethernetshield?

    0
    DavidGuo
    DavidGuo

    Reply 2 years ago

    Yes ,the LoRa Shield is compatibale with the Ethernet Shield,and you need to use the chip select singnals there.

    0
    diy_bloke
    diy_bloke

    Reply 2 years ago

    yes but the problem with that is that both shields are hardwired to use pin 10

    0
    DavidGuo
    DavidGuo

    Reply 2 years ago

    Have you tried it ?

    0
    diy_bloke
    diy_bloke

    Reply 2 years ago

    don't get me wrong, it is a great shield and I would certainly use it as a node, but the cs pin issue keeps me from using it as a gateway

    0
    diy_bloke
    diy_bloke

    Reply 2 years ago

    No, but if both shields use pin 10 for chipselect, how would you propose using another pin for chipselect without cutting traces?
    As you no doubt know the shield, rather than asking me if I tried, you could say: This is how you do it :-)
    I would have picked the UNO shield because it seemed an out of the box working solution, if not for the conflicting pin for chip select, but if I have to start modifying, just as well I might use a separate module

    0
    diy_bloke
    diy_bloke

    Reply 2 years ago

    seems both use pin 10 for cs so that will create a problem

    0
    BrandonF42
    BrandonF42

    3 years ago

    I am looking at doing a similar project but using cellular. Any advice on shields, boards to use for this?

    0
    DavidGuo
    DavidGuo

    Reply 3 years ago

    Did you make it?Could you tell me more details?

    0
    JiwonC
    JiwonC

    3 years ago

    Can I use Arduino uno instead of Arduino MEGA 2560 board at this project?

    0
    victor.feria.75
    victor.feria.75

    3 years ago

    I just ordered the LoRa/Shield Module for Arduino. Do I need to preconfigure the LoRas prior to installing the mods to Arduino?