herkse merhaba. 5 loradan ısı nem verisi almak istiyorum. 1 alıcı dan veri almak tamam. alıcı kısmında çoklu loradan veri almayı başaramadım. hangi loradan veri geldiğini alıcıda nasıl ayırt edeceğim. esp32 kullanıyorum bununla ilgili bir kod varsa lütfen paylaşırmısınız..
Soru yeni cevaplara kapalıdır.
Mehmet En iyi cevap olarak seçildi Ağustos 1, 2022
//// ALICI #include "LoRa_E22.h" #include <SoftwareSerial.h> //SoftwareSerial mySerial(A0, A1); SoftwareSerial fixSerial(10, 11); // RX, TX /* Pinler Arduino MEGA Lora E32 433T20d A8 3 A9 4 */ #define DS3231_ADDRESS 0x68 #define M0 7 #define M1 6 LoRa_E22 e22(&fixSerial); #include <Wire.h> #include "TWILiquidCrystal.h" //#include <LiquidCrystal_I2C.h> uint8_t m_addr = 55; LiquidCrystal lcd(m_addr); int sayici=0; byte zero = 0x00; //****************************************************** byte karakter0[8] = { 0x00, 0x0E, 0x11, 0x10, 0x11, 0x0E, 0x04, 0x00 }; // ç byte karakter2[8] = { 0x0C, 0x12, 0x12, 0x0C, 0x00, 0x00, 0x00, 0x00 }; // Derece byte karakter1[8] = { 0x0A, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00 }; // ö byte karakter3[8] = { 0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F }; // kare byte karakter4[8] = { 0xE, 0x11, 0x10, 0x10, 0x10, 0x11, 0xE, 0x4 }; // Ç byte karakter5[8] = { 0xE,0x0,0xE,0x11,0xF,0x1,0xE,0x0 }; // ğ byte karakter6[8] = { 0x0,0x0,0xC,0x4,0x4,0x4,0xE,0x0}; // ı byte karakter7[8] = { 0xE,0x0,0xF,0x10,0x13,0x11,0xF,0x0 }; // Ğ byte karakter8[8] = { 0xF,0x10,0x10,0xE,0x1,0x1,0x1E,0x4 }; // Ş byte karakter9[8] = {0xE,0xE,0x4,0x5,0xE,0x14,0x6,0x1B }; //adam //******************************************************** //LiquidCrystal_I2C lcd(0x25,20,4); struct Signal { char type[80]; byte temp[4]; byte nem[4]; byte id[4]; } data; void setup() { Wire.begin(); pinMode(M0, OUTPUT); pinMode(M1, OUTPUT); digitalWrite(M0, LOW); digitalWrite(M1, LOW); Serial.begin(9600); e22.begin(); delay(800); lcd.begin(40, 4); lcd.clear(); lcd.createChar(0, karakter0); lcd.createChar(2, karakter2); lcd.createChar(1, karakter1); lcd.createChar(3, karakter3); lcd.createChar(4, karakter4); lcd.createChar(5, karakter5); lcd.createChar(6, karakter6); lcd.createChar(7, karakter7); lcd.createChar(8, karakter8); lcd.createChar(9, karakter9); //lcd.backlight(); lcd.setContrast(5); //lcd.saveContrast(20); lcd.setBrightness(250); //lcd.saveBrightness(250); lcd.setCursor(10, 1); lcd.println(" ISI TAKiP"); Serial.begin(9600); delay(1500); lcd.clear(); } void loop() { //atecihaz(); // mg2022(); // atedepo(); //kalibre(); //savdepo(); while (e22.available() > 1) { // Gelen mesaj okunuyor ResponseStructContainer rsc = e22.receiveMessage(sizeof(Signal)); struct Signal data = *(Signal*) rsc.data; delay(1000); Serial.println(*(float*)(data.id)); if (*(float*)(data.id)=1){ atecihaz(); } if (*(float*)(data.id)=2){ mg2022(); } if (*(float*)(data.id)==3) atedepo(); if (*(float*)(data.id)==4) kalibre(); if (*(float*)(data.id)==5) savdepo(); } } void atecihaz() { while (e22.available() > 1) { // Gelen mesaj okunuyor ResponseStructContainer rsc = e22.receiveMessage(sizeof(Signal)); struct Signal data = *(Signal*) rsc.data; lcd.setCursor(2,0); lcd.print("ATE"); if (*(float*)(data.temp) == 125.00){ lcd.setCursor(0,1); lcd.print("--.--"); lcd.write(byte(2));lcd.print("C"); } else lcd.setCursor(0,1); lcd.print(*(float*)(data.temp));lcd.write(byte(2));lcd.print("C"); lcd.setCursor(0,2); lcd.print("% "); lcd.print(*(float*)(data.nem)); Serial.println(*(float*)(data.temp)); Serial.println(*(float*)(data.nem)); Serial.flush(); rsc.close(); Serial.flush(); } } void mg2022() { while (e22.available() > 1) { // Gelen mesaj okunuyor ResponseStructContainer rsc = e22.receiveMessage(sizeof(Signal)); struct Signal data = *(Signal*) rsc.data; lcd.setCursor(8,0); // lcd.print("Yer: "); //lcd.setCursor(8,0); lcd.print("MG2022"); //Serial.print("Yer: "); //Serial.println(data.type); lcd.setCursor(8,1); //lcd.print("ISI: "); //lcd.setCursor(6,2); lcd.print(*(float*)(data.temp));lcd.write(byte(2));lcd.print("C"); lcd.setCursor(8,2); //lcd.print("NEM: "); //lcd.setCursor(6,3); lcd.print("% "); lcd.print(*(float*)(data.nem)); Serial.flush(); rsc.close(); Serial.flush(); } } void atedepo() { while (e22.available() > 1) { // Gelen mesaj okunuyor ResponseStructContainer rsc = e22.receiveMessage(sizeof(Signal)); struct Signal data = *(Signal*) rsc.data; lcd.setCursor(16,0); // lcd.print("Yer: "); //lcd.setCursor(8,0); lcd.print("ATE DEP"); //Serial.print("Yer: "); //Serial.println(data.type); lcd.setCursor(16,1); //lcd.print("ISI: "); //lcd.setCursor(6,2); lcd.print(*(float*)(data.temp));lcd.write(byte(2));lcd.print("C"); lcd.setCursor(16,2); //lcd.print("NEM: "); //lcd.setCursor(6,3); lcd.print("% "); lcd.print(*(float*)(data.nem)); Serial.flush(); rsc.close(); Serial.flush(); } } void kalibre() { while (e22.available() > 1) { // Gelen mesaj okunuyor ResponseStructContainer rsc = e22.receiveMessage(sizeof(Signal)); struct Signal data = *(Signal*) rsc.data; lcd.setCursor(24,0); // lcd.print("Yer: "); //lcd.setCursor(8,0); lcd.print("KALBRE"); //Serial.print("Yer: "); //Serial.println(data.type); lcd.setCursor(24,1); //lcd.print("ISI: "); //lcd.setCursor(6,2); lcd.print(*(float*)(data.temp));lcd.write(byte(2));lcd.print("C"); lcd.setCursor(24,2); //lcd.print("NEM: "); //lcd.setCursor(6,3); lcd.print("% "); lcd.print(*(float*)(data.nem)); Serial.flush(); rsc.close(); Serial.flush(); } } void savdepo() { while (e22.available() > 1) { // Gelen mesaj okunuyor ResponseStructContainer rsc = e22.receiveMessage(sizeof(Signal)); struct Signal data = *(Signal*) rsc.data; lcd.setCursor(32,0); // lcd.print("Yer: "); //lcd.setCursor(8,0); lcd.print("SAVS DEP"); //Serial.print("Yer: "); //Serial.println(data.type); lcd.setCursor(32,1); //lcd.print("ISI: "); //lcd.setCursor(6,2); lcd.print(*(float*)(data.temp));lcd.write(byte(2));lcd.print("C"); lcd.setCursor(32,2); //lcd.print("NEM: "); //lcd.setCursor(6,3); lcd.print("% "); lcd.print(*(float*)(data.nem)); Serial.flush(); rsc.close(); Serial.flush(); } }
couger star Düzenlenmiş cevap Haziran 29, 2022