GithubHelp home page GithubHelp logo

lora-mesh's Introduction

LoRa Mesh Networking

This project implements the components of a system that demonstrates mesh networking between LoRa nodes and a way to visualize the network on a web page. For full details of the project, see the full project writeup on the Project Lab blog.

Nodes in the network are Arduino-compatible boards with a LoRa tranceiver. For example, Moteino boards.

There are several components of this project:

SetNodeId

Arduino sketch to set the node's ID in EEPROM so that every node can have the same source code (without hard-coding the node ID). This is a one-time process for each node. Set the node ID in this sketch then upload to a node (e.g. a Moteino). When it runs it saves the node ID in EEPROM. Then you can load the LoRaMesh sketch to the node.

LoRaMesh

Arduino sketch that attempts to talk to all other nodes in the mesh. Each node sends its routing information to every other node. The process of sending data and receiving acknowledgements lets a node determine which nodes it can successfully communicate with directly. This is how each node builds up it's routing table. You must set N_NODES to the max number of nodes in your mesh.

Dependencies:

Gateway

ESP8266 Arduino sketch that talks to a connected LoRa node via Serial (node number 1 in the mesh) and publishes mesh routing information to an MQTT topic. Node 1 in the mesh will eventually receive routing info from every other node.

Dependencies:

mesh-server

Node.js server provides a web visualization of the mesh. Runs on port 4200. Install with npm install. The server subscribes to the MQTT topic to receive routing info about nodes. This server sends the received routing info to the web client using Socket.IO. The web client uses p5.js to draw a representation of the mesh based on the routing information received from each node.

Dependencies (install with npm install)

  • express
  • jquery
  • mqtt
  • socket.io
  • rxjs
  • p5

lora-mesh's People

Contributors

nootropicdesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lora-mesh's Issues

Arduino Nano stuck in sendtoWait()!

I am using RF96 with Arduino Nano,

Code works with Uno, but no luck with Nano,

On Nano it gets stuck on line 158 in loraMesh.ino

"uint8_t error = manager->sendtoWait((uint8_t *)buf, strlen(buf), n);"

I tried to print (error), but no output on serial monitor, What could be the issue?

Not getting signal strength of nodes

I am using arduino nano and AI-Thinker SX1278 RF RA-02 lora module.

This is my code-

//#include <EEPROM.h>
//#include <Arduino.h>
#include <SPI.h>
//#include <ESP8266WiFi.h>
#include <RHRouter.h>
#include <RHMesh.h>
#include <RH_RF95.h>
//#define RH_HAVE_HARDWARE_SPI
#define RH_HAVE_SERIAL
#define LED 13
#define N_NODES 4

uint8_t nodeId;
uint8_t routes[N_NODES]; // full routing table for mesh
int16_t rssi[N_NODES]; // signal strength info

#define RFM95_CS 10
#define RFM95_RST 9
#define RFM95_INT 2

// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS,RFM95_INT);

// Class to manage message delivery and receipt, using the driver declared above
RHMesh *manager;

// message buffer
char buf[RH_MESH_MAX_MESSAGE_LEN];

/*int freeMem() {
extern int __heap_start, __brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
/

void setup() {
randomSeed(analogRead(A0));

//pinMode(9, OUTPUT);
// digitalWrite(9, HIGH);

pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);

pinMode(LED, OUTPUT);
Serial.begin(115200);
while (!Serial) ; // Wait for serial port to be available
Serial.println("program is going to execute");
//nodeId = EEPROM.read(0);
nodeId = 1;
if (nodeId > 10) {
Serial.print(F("EEPROM nodeId invalid: "));
Serial.println(nodeId);
nodeId = 1;
}
Serial.print(F("initializing node "));
delay(1000);
manager = new RHMesh(rf95, nodeId);

digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);

if (!manager->init()) {
//if (!rf95.init()) {
Serial.println(F("init failed"));
} else {
Serial.println("init successful");
}
rf95.setTxPower(23, false);
rf95.setFrequency(433.0);
//rf95.setCADTimeout(500);

////////////////////////////////////////////////////
if (!rf95.setFrequency(433.0)) {

Serial.println("setFrequency failed");

while (1);

}
else{
Serial.println("Set frequency successful");
}

///////////////////////////////////////////////////////

// Possible configurations:
// Bw125Cr45Sf128 (the chip default)
// Bw500Cr45Sf128
// Bw31_25Cr48Sf512
// Bw125Cr48Sf4096

// long range configuration requires for on-air time
boolean longRange = false;
if (longRange) {
RH_RF95::ModemConfig modem_config = {
0x78, // Reg 0x1D: BW=125kHz, Coding=4/8, Header=explicit
0xC4, // Reg 0x1E: Spread=4096chips/symbol, CRC=enable
0x08 // Reg 0x26: LowDataRate=On, Agc=Off. 0x0C is LowDataRate=ON, ACG=ON
};
rf95.setModemRegisters(&modem_config);
if (!rf95.setModemConfig(RH_RF95::Bw125Cr45Sf128)) {
Serial.println(F("set config failed"));
}
}

Serial.println("RF95 ready");

for(uint8_t n=1;n<=N_NODES;n++) {
routes[n-1] = 0;
rssi[n-1] = 0;
}

}

const __FlashStringHelper* getErrorString(uint8_t error) {
switch(error) {
case 1: return F("invalid length");
break;
case 2: return F("no route");
break;
case 3: return F("timeout");
break;
case 4: return F("no reply");
break;
case 5: return F("unable to deliver");
break;
}
return F("unknown");
}

void updateRoutingTable() {
for(uint8_t n=1;n<=N_NODES;n++) {
RHRouter::RoutingTableEntry *route = manager->getRouteTo(n);
if (n == nodeId) {
routes[n-1] = 255; // self
} else {
routes[n-1] = route->next_hop;
if (routes[n-1] == 0) {
// if we have no route to the node, reset the received signal strength
rssi[n-1] = 0;
}
}
}
}

// Create a JSON string with the routing info to each node
void getRouteInfoString(char *p, size_t len) {
p[0] = '\0';
strcat(p, "[");
for(uint8_t n=1;n<=N_NODES;n++) {
strcat(p, "{"n":");
sprintf(p+strlen(p), "%d", routes[n-1]);
strcat(p, ",");
strcat(p, ""r":");
sprintf(p+strlen(p), "%d", rssi[n-1]);
strcat(p, "}");
if (n<N_NODES) {
strcat(p, ",");
}
}
strcat(p, "]");
}

void printNodeInfo(uint8_t node, char *s) {
Serial.print(F("node: "));
Serial.print(F("{"));
Serial.print(F("""));
Serial.print(node);
Serial.print(F("""));
Serial.print(F(": "));
Serial.print(s);
Serial.println(F("}"));
}

void loop() {

for(uint8_t n=1;n<=N_NODES;n++) {
if (n == nodeId) continue; // self

updateRoutingTable();
getRouteInfoString(buf, RH_MESH_MAX_MESSAGE_LEN);

Serial.print(F("->"));
Serial.print(n);
Serial.print(F(" :"));
Serial.print(buf);

// send an acknowledged message to the target node
uint8_t error = manager->sendtoWait((uint8_t *)buf, strlen(buf), n);
if (error != RH_ROUTER_ERROR_NONE) {
  Serial.println();
  Serial.print(F(" ! "));
  Serial.println(getErrorString(error));
} else {
  Serial.println(F(" OK"));
  // we received an acknowledgement from the next hop for the node we tried to send to.
  RHRouter::RoutingTableEntry *route = manager->getRouteTo(n);
  if (route->next_hop != 0) {
    rssi[route->next_hop-1] = rf95.lastRssi();
  }
}
if (nodeId == 1) printNodeInfo(nodeId, buf); // debugging

// listen for incoming messages. Wait a random amount of time before we transmit
// again to the next node
unsigned long nextTransmit = millis() + random(3000, 5000);
while (nextTransmit > millis()) {
  int waitTime = nextTransmit - millis();
  uint8_t len = sizeof(buf);
  uint8_t from;
  if (manager->recvfromAckTimeout((uint8_t *)buf, &len, waitTime, &from)) {
    buf[len] = '\0'; // null terminate string
    Serial.print(from);
    Serial.print(F("->"));
    Serial.print(F(" :"));
    Serial.println(buf);
    if (nodeId == 1) printNodeInfo(from, buf); // debugging
    // we received data from node 'from', but it may have actually come from an intermediate node
    RHRouter::RoutingTableEntry *route = manager->getRouteTo(from);
    if (route->next_hop != 0) {
      rssi[route->next_hop-1] = rf95.lastRssi();
    }
  }
}

}

}

This is OUTPUT-

program is going to execute
initializing node init successful
Set frequency successful
RF95 ready
->2 :[{"n":255,"r":0},{"n":0,"r":0},{"n":0,"r":0},{"n":0,"r":0}]
! no route
node: {"1": [{"n":255,"r":0},{"n":0,"r":0},{"n":0,"r":0},{"n":0,"r":0}]}
->3 :[{"n":255,"r":0},{"n":0,"r":0},{"n":0,"r":0},{"n":0,"r":0}]

The problem is that I am not getting noe no. and rsi values of the nodes. I am using 4 nodes. Please help and thanks in advance.

lom204 (stm32l072+sx1276)

Hi
I initialized 2 modules LOM204...
And i am getting only this messages on both
image
image
Is that i interrupt problem um DIO0 ?

Limited amount of nodes in mesh network?

Hello,
I see in LoRaMesh.ino the following lines:
nodeId = EEPROM.read(0);
if (nodeId > 10) {
Serial.print(F("EEPROM nodeId invalid: "));
Serial.println(nodeId);
nodeId = 1;
}

does this means that the mesh network size is limited to 10 units maximum including the gateway?

If this is the case, is there a reason for this limit?

Few questions max nodes max hops

Hi

How many devices are possible on a single mesh network?

Are there any know way to reach 512 or 1024 nodes per mesh network?

How many hops are allowed? Max hops number?

Thanks in advance.

Runtime Error in ESP8266 NodeMCU + RFM95 LoRa Module for Mesh Networking

Dear Mr. Michael Sir, Greetings!
(http://www.nootropicdesign.com/)
By profession, I am a teacher; teaching in the School of Computing of Trident Academy of Technology.
I am facing problem as described in detail in the file attached.
Kindly extend your help please
With sincere regards, I am eagerly looking forward to your valuable response and constructive suggestions please,
A. K. Samal
NodeMCU with RFM95 LoRa Modules Interface Runtime Execution Error Report.pdf
NodeMCU with RFM95 LoRa Modules Interface Runtime Execution Error Report.docx

Is Lora Mesh Will Follow Duty Cycle Regulations

Hello,

As a Lora node may have transmit more for neighbor nodes, which may be higher than 1% of duty cycle.
Is Lora Mesh Follow regulations like duty cycle of 1%, etc. as it follow in LoraWAN.

Thank You

Security of Lora Mesh Network

Hello,
I want to know about data security in Lora Mesh Network, is it encrypted?
And How can I used two or more different Lora Mesh network at same place, like zigbee ?

Thank You

Compiling in esp32

Arduino: 1.8.5 (Linux), Board: "Heltec_WIFI_LoRa_32, 80MHz, 921600"

WARNING: Category 'Language' in library ArduinoStreaming is not valid. Setting to 'Uncategorized'
Archiving built core (caching) in: /tmp/arduino_cache_366318/core/core_espressif_esp32_heltec_wifi_lora_32_FlashFreq_80,UploadSpeed_921600_808b03452edbafa9ebcae00cb952e117.a
sketch/Router.ino.cpp.o:(.literal._Z7freeMemv+0x0): undefined reference to __brkval' sketch/Router.ino.cpp.o:(.literal._Z7freeMemv+0x4): undefined reference to __heap_start'
collect2: error: ld returned 1 exit status
Multiple libraries were found for "RHRouter.h"
Used: /home/jpy/Arduino/libraries/RadioHead-master
Not used: /home/jpy/Arduino/libraries/RadioHead
Not used: /home/jpy/Arduino/libraries/RadioHead
Not used: /home/jpy/Arduino/libraries/RadioHead
Not used: /home/jpy/Arduino/libraries/RadioHead
exit status 1
Error compiling for board Heltec_WIFI_LoRa_32.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

HI
I TRIED TO RUN LORA MESH IN ESP32 AND END UP WITH THIS ERROR. PLS HELP ..

mesh server node limit

node mesh server can plot up to 4 nodes but if add 5th node like this, it just draw a line and hang.

image

Great Project!

This is a great project!
Still: more cost-effective than Zigbee for getting on sub-1GHz WSN design using LoRa Phy.
Thanks for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.