bY白

bY白

0个粉丝

1

问答

0

专栏

0

资料

bY白  发布于  2020-11-25 16:40:20
采纳率 0%
1个问答
3327

怎么做一个lora系统的仿真

 

怎么做一个lora系统的仿真

我来回答
回答1个
时间排序
认可量排序

1

0个粉丝

1

问答

16

专栏

6

资料

1 2020-12-04 08:36:40
认可0

Arduino 代码
编译本工程需要添加 LoRa 驱动库

使用 Arduino IDE 打开工程,点击”Sketch -> Include Library -> Add .ZIP Library…”

Arduino 的 zip 库安装路径一般为:C:\Users\Administrator\Documents\Arduino\libraries

Arduino 的代码简洁,容易理解,下载链接

DEBUG 设置为 0 禁止调试功能;设置为 1 它将通过 8 和 9 两个引脚打印调试信息(使用“USB转串口”连接到 PC)。
哨兵观察与快速采样算法原理:无烟时每秒仅读取 1 次,一旦发现烟雾浓度超过阈值(哨兵观察),以每 0.12 秒频率快速采集 16 次,计算烟雾浓度平均值。

include

lora LoRa;

const int buzzerPin = 13;
const int photodiodePin = 0; // A0
const int smokeThreshold = 80; // 0 <= no smoke < 80, 80 < thin smoke < 200, 200 < thick smoke <= 1023

define DEBUG 0 // 0=disable, 1=enable

if DEBUG

include

SoftwareSerial debugSerial(8, 9); // 8=RX, 9=TX

endif

void setup()
{
pinMode(buzzerPin, OUTPUT);
Serial.begin(115200); // for LoRa Node

if DEBUG

debugSerial.begin(115200); // for debug

endif

}

void loop()
{
// perfect interval for Arduino watchdog timer is: 15, 30, 60, 120, 250, 500, 1000, 2000, 4000, 8000

define FAST_SAMPLE_INTERVAL 120 // 120ms

define NORMAL_SAMPLE_INTERVAL 1000 // 1000ms

define SAMPLE_NUMBER 16

int val, sum;
int array[1];

val = analogRead(photodiodePin);

if DEBUG

debugSerial.println(val);

endif

if (smokeThreshold < val) // sentry observation
{
// Check fire danger after sentry alert
sum = 0;
for (int count = 0; count < SAMPLE_NUMBER; ++count)
{
val = analogRead(photodiodePin);
sum += val;
delay(FAST_SAMPLE_INTERVAL);
}

val = sum / SAMPLE_NUMBER;  // get the average value
if (smokeThreshold < val)
{
  array[0] = val;
  LoRa.write(array, sizeof(array));

  digitalWrite(buzzerPin, HIGH);
  delay(3000);
  digitalWrite(buzzerPin, LOW);

#if DEBUG
  debugSerial.print("get fired, val = ");
  debugSerial.println(val);
#endif
}

}

delay(NORMAL_SAMPLE_INTERVAL);
}

或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区