Çözüldü2.71K görüntülenmeLorae32 433T20D lora e32 433t30d
0

Merhabalar kütüphanesiz haberleşmede byte olarak sadece int veri mi gönderilebiliyor? Deneme olarak 1.23 verisini göndermeye çalıştığımda 1.0 verisi olarak aldım bu konuda yardımcı olabilir misiniz? byte türünden float a çevirdiğim denemede de aynı sorunla karşılaştım.

Soru yeni cevaplara kapalıdır.
Mehmet En iyi cevap olarak seçildi Mart 27, 2022
0
#include <SoftwareSerial.h>
#include "LoRa_E32.h"
#include <TinyGPS.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
SoftwareSerial mySerial(10, 11); // Arudino RX <-- e32 TX, Arduino TX --> e32 RX
LoRa_E32 e32ttl(&mySerial);
TinyGPS gps;
SoftwareSerial ss(6, 5);
LiquidCrystal_I2C lcd(0x27, 16, 2);
 unsigned long previousTime = 0.0;
unsigned long currentTime  = 0.0;
 float sample1 = 0, sample2 = 0, sample3 = 0;
float flat = 0, flon = 0;
unsigned long age;
unsigned long age2;
float voltage1 = 0.0, voltage2 = 0.0, watt = 0.0, energy = 0.0, current = 0.0;
int Vo1;
int Vo2;
float R1 = 10000, R3 = 10000;
float logR2, R2, T1, Tc1, logR4, R4, T2, Tc2;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
volatile byte half_revolutions;
unsigned int rpm;
unsigned long timeold;
float hizrpm = 0.0;
 struct Signal {
  float message[10];
} data;
 void setup() {
  Serial.begin(9600);
  e32ttl.begin();
  mySerial.begin(9600);
  ss.begin(9600);
  attachInterrupt(digitalPinToInterrupt(3), magnet_detect, RISING);//intterrupt pin (Arduino digital pin 2)
  lcd.begin();
  lcd.clear();
  half_revolutions = 0;
  rpm = 0;
  timeold = 0;
}
 void loop() {
  unsigned long currentTime = millis(); //calculate time in milliseconds
   for (int i = 0; i < 50; i++) // taking 200 samples from data collected
  {
    sample1 = sample1 + analogRead(A0); //read the voltage
    sample2 = sample2 + analogRead(A1);//read the second voltage
    sample3 = sample3 + analogRead(A2) + 1; //read the current and  subtract -6 bit(-29) for optimizing
    delay(2);//wait 2ms
  }
  sample1 = sample1 / 50; //Measurement Part
  voltage1 = (sample1 * (5.0 / 1024.0)) * (503.0 / 33.0); //avarage voltage value from bit and divider to unit of V
   sample2 = sample2 / 50;
  voltage2 = (sample2 * (5.0 / 1024.0)) * (503.0 / 33.0); //avarage voltage value from bit and divider to unit of V
   sample3 = sample3 / 50;
  current = ((5.0 / 1024.0) * sample3) / 0.04 ; //avarage current value from bit to unit of A
   /*sample2 = sample2 / 200;
    current = (4.8828125 * sample2 / 40); //avarage current value from bit to unit of A*/
   watt = voltage1 * current;
  energy = energy + ((watt * (currentTime - previousTime)) / 3600000); //wh convert //save last time value
   previousTime = currentTime;
   Serial.print(voltage1);
  Serial.print(" V ;");
  /*Serial.print(voltage2);
    Serial.print(" V ;");*/
  Serial.print(current);
  Serial.print(" A ;");
  Serial.print(watt);
  Serial.print(" W ;");
  Serial.print(energy);
  Serial.print(" Wh ;");
  Serial.println("");
  delay(100);// wait 100ms for the analog-to-digital converter to settle
   Vo1 = analogRead(A6);  //Thermistor(Sıcaklık ölçme)
  R2 = R1 * (1023.0 / (float)Vo1 - 1.0);
  logR2 = log(R2);
  T1 = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
  Tc1 = T1 - 273.15;
   Vo2 = analogRead(A7);  //Thermistor(Sıcaklık ölçme)
  R4 = R3 * (1023.0 / (float)Vo2 - 1.0);
  logR4 = log(R4);
  T2 = (1.0 / (c1 + c2 * logR4 + c3 * logR4 * logR4 * logR4));
  Tc2 = T2 - 273.15;
   Serial.print("Environment Temperature: ");
  Serial.print(Tc1);
  Serial.println(" C");
   Serial.print("Motor Temperature: ");
  Serial.print(Tc2);
  Serial.println(" C");
   if (half_revolutions >= 5) { //Rpm
    rpm = 60 * 1000 / (millis() - timeold) * half_revolutions;
    timeold = millis();
    half_revolutions = 0;
  }
  hizrpm = rpm * 60 * 0.001477;
  if ((millis() - timeold) >= 3000) {
    hizrpm = 0.0;
    rpm = 0;
  }
   Serial.print("Speed;");
  Serial.println(hizrpm, 1);
  Serial.print("RPM;");
  Serial.println(rpm, 1);
  smartdelay(100); //Gps Part
  Serial.println();
  gps.f_get_position(&flat, &flon, &age);
  int alt = gps.f_altitude();
  int gpsspd = gps.f_speed_kmph();
  Serial.print("lat:"); Serial.println(flat, 8);
  Serial.print("lon:"); Serial.println(flon, 8);
  Serial.print("alt:"); Serial.println(alt);
  Serial.print("spd:"); Serial.println(gpsspd);
   Serial.print("Rpm:"); Serial.println(rpm);
   lcd.setCursor(0, 0); //LCD screening part
  lcd.print("S:");
  lcd.setCursor(2, 0);
  lcd.print(gpsspd);
  lcd.setCursor(7, 0);
  lcd.print("R:");
  lcd.setCursor(9, 0);
  lcd.print(rpm);
  lcd.setCursor(0, 1);
  lcd.print("V:");
  lcd.setCursor(2, 1);
  lcd.print(voltage1);
  lcd.setCursor(7, 1);
  lcd.print("A:");
  lcd.setCursor(9, 1);
  lcd.print(current);
    data.message[0]  = voltage1, 1; //writing inside the structure array
  data.message[1]  = current, 2;
  data.message[2]  = watt, 2;
  data.message[3]  = energy, 1;
  data.message[4]  = flat, 8;
  data.message[5]  = flon, 8;
  data.message[6]  = alt;
  data.message[7]  = gpsspd  ;
  data.message[8]  = rpm , 0;
  data.message[9]  = hizrpm, 1;
  //data.message[10]  = Tc1;
  //data.message[11] = Tc2;
   ResponseStatus rs = e32ttl.sendFixedMessage(0, 63, 23, &data, sizeof(Signal)); //message sending part
}
static void smartdelay(unsigned long ms)
{
  unsigned long start  = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  }
  while (millis() - start < ms);
}
void magnet_detect()
{
  half_revolutions++;
  //Serial.print("detect:");
}

Mehmet bey kütüphaneli olarak kullandığım kod bu sizin kodunuzu buna entegre ettiğimde çalışmadı sizin bakma şansınız var mı gönderilmesi gereken veriler data.message[] olarak belirtilen kısım alıcıyı sizden gördüğüm şekilde yazdığım halde veri alamadım.

Eray Yılmaz Cevaplanan soru Şubat 18, 2022
6 cevaptan 1'ini inceliyorsun, tüm cevapları görmek için buraya tıklayın.
Whatsapp'tan Yaz
1
Ürün Danışmanı Burada!
fixaj.com Ürün Danışmanı
Merhaba,

Ben sadece "Satın Alma" konularında destek vermekteyim.

Kodlama yardımı, haberleşme hataları, bağlantı şemaları vb. konularla ilgili "Soru&Cevap" https://fixaj.com/sorucevap/ sayfamızı ziyaret edebilirsiniz.