国产精品久久久aaaa,日日干夜夜操天天插,亚洲乱熟女香蕉一区二区三区少妇,99精品国产高清一区二区三区,国产成人精品一区二区色戒,久久久国产精品成人免费,亚洲精品毛片久久久久,99久久婷婷国产综合精品电影,国产一区二区三区任你鲁

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何將此ESP32 LORA模塊用作發(fā)送方和接收方

454398 ? 來(lái)源:網(wǎng)絡(luò)整理 ? 作者:網(wǎng)絡(luò)整理 ? 2019-11-14 17:14 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

步驟1:操作(數(shù)據(jù)傳輸)

這是裝配體工作原理圖。

步驟2:使用的資源

2 ESP32 LORA OLED顯示屏

1 Arduino Nano ATmega328

1 Arduino以太網(wǎng)模塊ENC28J60

1氣體傳感器模塊MQ2

1濕度和溫度傳感器DHT22( AM2302)

2330歐姆電阻

1 4k7歐姆電阻

1蜂鳴器5V

1個(gè)綠色LED

1紅色LED

跳線

步驟3:功能-發(fā)送方

1 ESP32 LORA Display

1氣體傳感器模塊MQ2

1濕度和溫度傳感器DHT22(AM2302)

1個(gè)4k7歐姆電阻器

跳線

第4步:使用的功能-接收器

1個(gè)ESP32 LORA OLED顯示屏

1個(gè)Arduino Nano ATmega328

1個(gè)用于Arduino的以太網(wǎng)模塊ENC28J60

2330 ohm r電阻器

1個(gè)蜂鳴器5V

1個(gè)綠色LED

1個(gè)紅色LED

跳線

步驟5:MQ-2氣體傳感器靈敏度

傳感器的電阻(Rs/Ro)根據(jù)現(xiàn)有的氣體濃度(ppm)更高或更低。此濃度可以通過(guò)引腳A0的輸出來(lái)顯示。

MQ-2氣體傳感器對(duì)氣體具有高靈敏度:

?LPG(液化石油氣);

?丙烷(C3H8);

?氫氣(H2);

?甲烷(CH4);

?燃料氣體,例如丙烷, CO,酒精和丁烷(用于打火機(jī))。

步驟6:發(fā)送器安裝--- Pinout ESP32 LORA OLED

步驟7 :發(fā)送器電路

步驟8:發(fā)送器安裝

步驟9:安裝接收器---引腳排列Arduino Nano ATmega328

步驟10:接收器電路

步驟11:接收器安裝

綠色LED指示Arduino已連接到以太網(wǎng)客戶端。

紅色LED指示已發(fā)送SMS。

發(fā)送SMS時(shí),Arduino已斷開連接,因此不再發(fā)送任何消息。

步驟12:DHT庫(kù)安裝

1。轉(zhuǎn)到草圖-》包含庫(kù)-》庫(kù)管理器。

2。搜索SimpleDHT,然后單擊“安裝”。

步驟13:發(fā)件人-代碼的組織

設(shè)置 》

循環(huán)

-readDhtSensor:負(fù)責(zé)讀取傳感器和獲取溫度和濕度值。

-gasDetected:負(fù)責(zé)讀取傳感器并驗(yàn)證是否已檢測(cè)到氣體的功能。

-sendPacket:負(fù)責(zé)通過(guò)LORA發(fā)送包裹的功能

-showDisplay:負(fù)責(zé)顯示在顯示屏上獲得的消息和值的功能。

步驟14:發(fā)件人代碼[包含和定義]

首先,我們將包含定義引腳的庫(kù)。

#include //serial peripheral interface (SPI) library

#include //wifi lora library

#include //communication i2c library

#include “SSD1306.h” //display communication library

#include //dht communication library

//Descomment the line below which dht sensor type are you using

//#define DHTTYPE DHT11 // DHT 11

//#define DHTTYPE DHT21 // DHT 21 (AM2301)

#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321

我們將處理

// DHT Sensor

const int DHTPin = 23;

int analog_value; //variable used to receive the analog signal from sensor (from 100 to 10000)

int dig_value; //variable used to receive the digital signal from sensor

int gas_limit = 0; //used to indicates the minimum value to active the gas sensor (that value changes as the sensor screw is adjusted)

//h = humidity; c = Celsius temperature

float h, c;

String packSize; //variable used to receive the size of package converted in string

String packet = “OK”; //part of packet, that informs the status of sensor. That variable will be concatenate with the string “values”

String values = “|-|-”; //humidity and temperature values, separated by pipe

//parameters: address,SDA,SCL

SSD1306 display(0x3c, 4, 15); //display object

SimpleDHT22 dht22;

// Pins definition

#define SCK 5 // GPIO5 -- SX127x‘s SCK

#define MISO 19 // GPIO19 -- SX127x’s MISO

#define MOSI 27 // GPIO27 -- SX127x‘s MOSI

#define SS 18 // GPIO18 -- SX127x’s CS

#define RST 14 // GPIO14 -- SX127x‘s RESET

#define DI00 26 // GPIO26 -- SX127x’s IRQ(Interrupt Request)

#define MQ_analog 12 //analog gas sensor pin

#define MQ_dig 13 //digital gas sensor pin

#define BAND 433E6 //Radio frequency, we can still use: 433E6, 868E6, 915E6

步驟15:發(fā)送方除了定義氣體傳感器的最小觸發(fā)值外,還帶有用于接收模擬數(shù)字信號(hào)的變量的傳感器。代碼[設(shè)置]

在設(shè)置中,我們將首先配置引腳和顯示。

void setup()

{

//set the humidity and temperature values with zero

h = c = 0;

//initialize the Serial with 9600b per second

Serial.begin(9600);

//configures analog pin as input

pinMode(MQ_analog, INPUT);

//configures digital pin as input

pinMode(MQ_dig, INPUT);

//configures oled pins as output

pinMode(16,OUTPUT);

//reset oled

digitalWrite(16, LOW);

//wait 50ms

delay(50);

//while the oled is on, GPIO16 must be HIGH

digitalWrite(16, HIGH);

//initializes the display

display.init();

//flip vertically the display

display.flipScreenVertically();

接下來(lái),我們將在顯示屏上定義打印特性,并開始與LORA進(jìn)行串行通信。然后,我們將繼續(xù)進(jìn)行配置。

//set display font

display.setFont(ArialMT_Plain_10);

//wait 1500ms

delay(1500);

//clear the display

display.clear();

//initializes serial interface

SPI.begin(SCK,MISO,MOSI,SS);

//set Lora pins

LoRa.setPins(SS,RST,DI00);

//initializes the lora, seting the radio frequency

if (!LoRa.begin(BAND))

{

//draw in the position 0,0 the message in between quotation marks

display.drawString(0, 0, “Starting LoRa failed!”);

//turns on the LCD display

display.display();

//do nothing forever

while (true);

}

}

步驟16:發(fā)件人代碼[循環(huán)]

在循環(huán)中,我們還使用顯示器的特性,并指示讀取傳感器的步驟以及LORA的氣體檢測(cè)和警報(bào)發(fā)送的方法。

void loop()

{

//clear the display

display.clear();

//set the text alignment to left

display.setTextAlignment(TEXT_ALIGN_LEFT);

//sets the text font

display.setFont(ArialMT_Plain_16);

//draw in the position 0,0 the message in between quotation marks

display.drawString(0, 0, “Running.。.”);

//reads temperature sensor values

readDhtSensor();

//it concatenates on string the humidity and temperature values separated by pipe

values=“|”+String(h)+“|”+String(c);

//if the digital signal of sensor is lower, it means gas detected (inverse logic

if(gasDetected())

{

//sets the value of the packet string to “ALARM

packet = “ALARM”;

//it concatenates the packet with the values

packet+=values;

//sends package by LoRa

sendPacket();

//shows display, true = gas detected

showDisplay(true);

}

我們定義了將通過(guò)SMS發(fā)送的信息。

else

{

//sets the value of the packet string to “OK”

packet = “OK”;

//it concatenates the packet with the values

packet+=values;

//sends package by LoRa

sendPacket();

//shows display, false = no gas detected

showDisplay(false);

}

//waits 250ms

delay(250);

}

步驟17:發(fā)件人代碼[showDisplay]

同樣,我們處理LORA顯示屏上的數(shù)據(jù)顯示。

void showDisplay(bool gasDetected)

{

//clear the display

display.clear();

//set the text alignment to left

display.setTextAlignment(TEXT_ALIGN_LEFT);

//sets the text font

display.setFont(ArialMT_Plain_16);

//draw in the position 0,0 the message in between quotation marks

display.drawString(0, 0, “Running.。.”);

//if flag = true

if(gasDetected)

{

//draw in the position 0,20 the message in between quotation marks

display.drawString(0, 20, “Status: ALARM”);

//draw in the position 0,40 the message in between quotation marks

display.drawString(0, 40, “Gas detected!”);

//turns on the LCD display

display.display();

}

else

{

//draw in the position 0,20 the message in between quotation marks

display.drawString(0, 20, “Status: OK”);

//draw in the position 0,40 the message in between quotation marks

display.drawString(0, 40, “H: ”+String(h)+“ T: ”+String(c)+“°”);

//turns on the LCD display

display.display();

}

}

步驟18:發(fā)件人代碼[gasDetected]

在這里,如果傳感器檢測(cè)到某種類型的氣體泄漏,我們具有觸發(fā)消息的功能。

bool gasDetected()

{

//reads the analog value of the sensor

analog_value = analogRead(MQ_analog);

//reads the digital value of the sensor

dig_value = digitalRead(MQ_dig);

//obs: the serial views in this code do not influence the operation of the prototype

//shows value to the serial

Serial.print(analog_value);

//shows tab “||” to the serial

Serial.print(“ || ”);

//inverse logic

if(dig_value == 0)

{

//sets the minimum analog value

if(gas_limit == 0 || gas_limit 》 analog_value)

gas_limit = analog_value;

//shows ‘gas detected’ to the serial

Serial.println(“GAS DETECTED !!!”);

//shows the minimum gas limit to the serial

Serial.println(“Gas limit: ”+String(gas_limit));

//gas detected

return true;

}

else

{

//shows ‘no gas detected’ to the serial

Serial.println(“No gas detected.。.”);

//if first time, shows ‘X’ to the serial

if(gas_limit == 0)

Serial.println(“Gas limit: X”);

else //shows gas limit to the serial

Serial.println(“Gas limit: ”+String(gas_limit));

//no gas detected

return false;

}

}

第19步:發(fā)送方代碼[readDhtSensor]

void readDhtSensor()

{

// declaration of variables that will receive the new temperature and humidity

float novoC, novoH;

//waits 250ms

delay(250);

//set dht22 sensor values tovariables &novoC and &novoH

int err = dht22.read2(DHTPin, &novoC, &novoH, NULL);

//checks for an error

if (err != SimpleDHTErrSuccess)

{

//shows error in the serial

Serial.print(“Read DHT22 failed, err=”);

Serial.println(err);

return;

}

//if no error

//sets the variable values

c = novoC;

h = novoH;

//shows values in the serial

Serial.print((float)c); Serial.println(“ *C ”);

Serial.print((float)h); Serial.println(“ H”);

//waits 250ms

delay(250);

}

第20步:發(fā)送方代碼[sendPacket]

最后,我們打開了一個(gè)程序包,以添加用于SMS發(fā)送的數(shù)據(jù)。

void sendPacket()

{

//starts a connection to write UDP data

LoRa.beginPacket();

//send packet

LoRa.print(packet);

//returns an int: 1 if the packet was sent successfully, 0 if there was an error

LoRa.endPacket();

}
責(zé)任編輯:wv

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 傳感器
    +關(guān)注

    關(guān)注

    2576

    文章

    55069

    瀏覽量

    791553
  • 蜂鳴器
    +關(guān)注

    關(guān)注

    12

    文章

    900

    瀏覽量

    47773
  • ESP32
    +關(guān)注

    關(guān)注

    26

    文章

    1197

    瀏覽量

    21801
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    ESP32驅(qū)動(dòng)TFmini-S紅外激光測(cè)距ToF模塊進(jìn)行測(cè)距

    本文介紹了TFmini-S紅外激光測(cè)距ToF模塊的基本特性,然后用ESP32開發(fā)板驅(qū)動(dòng)TFmini-S模塊進(jìn)行測(cè)距,并在串口助手上顯示出測(cè)距數(shù)據(jù)。
    的頭像 發(fā)表于 03-06 14:43 ?59次閱讀
    <b class='flag-5'>ESP32</b>驅(qū)動(dòng)TFmini-S紅外激光測(cè)距ToF<b class='flag-5'>模塊</b>進(jìn)行測(cè)距

    ESP32 Wi-Fi 控制 LED 燈的原理

    在智能家居、物聯(lián)網(wǎng)設(shè)備中,用手機(jī)通過(guò)Wi-Fi控制燈光、風(fēng)扇或插座,已經(jīng)非常普遍。而在嵌入式開發(fā)中,ESP32是最常用的Wi-Fi模塊之一。本文將帶你系統(tǒng)理解:ESP32是如何通過(guò)Wi-Fi實(shí)現(xiàn)遠(yuǎn)程
    的頭像 發(fā)表于 01-09 19:04 ?311次閱讀
    <b class='flag-5'>ESP32</b> Wi-Fi 控制 LED 燈的原理

    ESP32藍(lán)牙驅(qū)動(dòng)MAX98357對(duì)音頻音樂(lè)播放

    本文介紹了MAX98357音頻模塊的基本特性,并利用ESP32的藍(lán)牙功能程序驅(qū)動(dòng)此模塊,最后用手機(jī)藍(lán)牙連接ESP32播放手機(jī)音樂(lè)
    的頭像 發(fā)表于 12-19 19:55 ?2708次閱讀
    <b class='flag-5'>ESP32</b>藍(lán)牙驅(qū)動(dòng)MAX98357對(duì)音頻音樂(lè)播放

    樂(lè)鑫科技ESP32-S3開發(fā)板+超聲波霧化,給智能魚缸整點(diǎn)美學(xué)氛圍

    我們?yōu)槭裁匆o智能魚缸弄上霧化?美學(xué)氛圍當(dāng)然是一面,但更重要的功能是局部加濕,為水面植物與周圍空氣提供柔和濕度。因此我們特意推出本期內(nèi)容:用樂(lè)鑫科技ESP32-S3開發(fā)板和超聲波霧化模塊讓水面形成
    的頭像 發(fā)表于 12-08 18:04 ?639次閱讀
    樂(lè)鑫科技<b class='flag-5'>ESP32</b>-S3開發(fā)板+超聲波霧化,給智能魚缸整點(diǎn)美學(xué)氛圍

    VSCode + ESP-IDF環(huán)境下給ESP32-S3項(xiàng)目添加頭文件

    VSCode + ESP-IDF環(huán)境下給ESP32-S3項(xiàng)目添加頭文件
    的頭像 發(fā)表于 11-28 07:27 ?2395次閱讀

    ESP32-WROOM-32 技術(shù)規(guī)格書

    電子發(fā)燒友網(wǎng)站提供《ESP32-WROOM-32 技術(shù)規(guī)格書.pdf》資料免費(fèi)下載
    發(fā)表于 11-11 17:27 ?0次下載

    ESP8266和ESP32開發(fā)板常見(jiàn)的2種下載方式

    ESP32ESP8266是性價(jià)比很高而且使用較為廣泛的的Wi-Fi模塊,在物聯(lián)網(wǎng)(IoT)領(lǐng)域的DIY項(xiàng)目中可以首先考慮這2款產(chǎn)品。 兩款芯片都屬于32位處理器。ESP32是低功耗
    的頭像 發(fā)表于 11-10 20:30 ?996次閱讀
    <b class='flag-5'>ESP</b>8266和<b class='flag-5'>ESP32</b>開發(fā)板常見(jiàn)的2種下載方式

    ESP32usart接收中斷求助

    我的項(xiàng)目需要ESP32USART使用串口接收中斷工作,用IDF5.12版本編譯所有例程均未能通過(guò),希望有高手幫幫我,謝謝。
    發(fā)表于 11-02 22:51

    樂(lè)鑫ESP32-C6和ESP32-C61究竟該如何選擇?一文讀懂本質(zhì)區(qū)別

    樂(lè)鑫科技推出的ESP32-C6和ESP32-C61均支持Wi-Fi6,但定位不同。ESP32-C6是多協(xié)議樞紐,集成Wi-Fi6、藍(lán)牙5、Zigbee和Thread,適合智能家居網(wǎng)關(guān)和Matter
    的頭像 發(fā)表于 10-28 14:17 ?2109次閱讀
    樂(lè)鑫<b class='flag-5'>ESP32</b>-C6和<b class='flag-5'>ESP32</b>-C61究竟該如何選擇?一文讀懂本質(zhì)區(qū)別

    LoRa1120模塊ESP32點(diǎn)對(duì)點(diǎn)LoRa通信實(shí)現(xiàn)實(shí)踐指南

    本報(bào)告系統(tǒng)地闡述了使用LoRa1120模塊ESP32微控制器實(shí)現(xiàn)基礎(chǔ)點(diǎn)對(duì)點(diǎn)LoRa通信的全過(guò)程。內(nèi)容涵蓋了從模塊技術(shù)特性分析、硬件系統(tǒng)連接
    的頭像 發(fā)表于 08-28 17:21 ?7166次閱讀
    <b class='flag-5'>LoRa</b>1120<b class='flag-5'>模塊</b>與<b class='flag-5'>ESP32</b>點(diǎn)對(duì)點(diǎn)<b class='flag-5'>LoRa</b>通信實(shí)現(xiàn)實(shí)踐指南

    ESP32開發(fā)板元件資料

    ESP32開發(fā)板元件
    發(fā)表于 07-21 14:47 ?15次下載

    ESP32用作經(jīng)典藍(lán)牙串口透?jìng)?b class='flag-5'>模塊與手機(jī)進(jìn)行串口通信

    本文介紹了如何把ESP32用作一個(gè)藍(lán)牙串口透?jìng)髟O(shè)備使用,其功能和常用的HC-05/06串口藍(lán)牙設(shè)備一樣。并與手機(jī)藍(lán)牙串口APP進(jìn)行雙向藍(lán)牙通信。
    的頭像 發(fā)表于 06-20 17:45 ?3028次閱讀
    <b class='flag-5'>ESP32</b><b class='flag-5'>用作</b>經(jīng)典藍(lán)牙串口透?jìng)?b class='flag-5'>模塊</b>與手機(jī)進(jìn)行串口通信

    ESP32驅(qū)動(dòng)MFRC522 RFID模塊讀寫IC卡數(shù)據(jù)

    本文將介紹ESP32開發(fā)板驅(qū)動(dòng)MFRC522 RFID模塊,讀取RFID卡原始數(shù)據(jù)、獲取RFID卡的UID,并將個(gè)人數(shù)據(jù)添加到RFID卡中。
    的頭像 發(fā)表于 05-28 15:52 ?1451次閱讀
    <b class='flag-5'>ESP32</b>驅(qū)動(dòng)MFRC522 RFID<b class='flag-5'>模塊</b>讀寫IC卡數(shù)據(jù)

    ESP32-CAM帶OV2640攝像頭視頻顯示

    本文介紹了如何在Arduino IDE上開發(fā)實(shí)現(xiàn)ESP32-CAM模塊獲取實(shí)時(shí)圖像視頻
    的頭像 發(fā)表于 05-23 10:47 ?1743次閱讀
    <b class='flag-5'>ESP32</b>-CAM帶OV2640攝像頭視頻顯示

    樂(lè)鑫ESP32-C5全面進(jìn)入量產(chǎn)

    樂(lè)鑫信息科技 (688018.SH) 宣布,ESP32-C5 現(xiàn)已全面進(jìn)入量產(chǎn)。
    的頭像 發(fā)表于 05-06 16:50 ?1421次閱讀