nootropicdesign / lora-mesh Goto Github PK
View Code? Open in Web Editor NEWLoRa mesh networking
License: MIT License
LoRa mesh networking
License: MIT License
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 ..
Can u make some example to make mesh network with this sandeepmistry/arduino-LoRa library
can anyone tell the circuit diagram of esp32 with Lora connection for this mesh code?
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
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.
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.
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
am also getting the same output NO ROUTE is found. Did you solved it ? any one can help me?
Originally posted by @sitharthen in #11 (comment)
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?
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!
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
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?
Hi all,
uint8_t routes[N_NODES]; // full routing table for mesh
int16_t rssi[N_NODES]; // signal strength info
In both places where it says "N_NODES" should I replace it with the max number of nodes in the network?
Thanks,
Zeb
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.