Basınç Ölçme ve KPa yı Atm birimine çevirmek ÇÖZÜLDÜ

Merhaba, Arduino yu ISIS programında simule ederek öğrenmeye çalışıyorum. ISIS üzerindeki MPX4250 basınç sensörüden elde ettiğim değerleri Atm birimine nasıl çevirebilirim. Teşekkürler.

internette mevcut. http://www.srh.noaa.gov/images/epz/wxcalc/pressureConversion.pdf

Teşekkür ederim. fakat yazılımda formule dökemiyorum. SensorValue = analogRead(SensorPort); ResultkPa = (SensorValue * (.00488) / (.022) + 20); Atm = (ResultkPa * 0.01) - 1.0172; //multiply (1 kPa x 0.01 bar) and deduct atmospheric pressure digitalWrite(Atm, HIGH); lcd.setCursor(0, 3); lcd.print("Atm "); delay(250); böyle bir formul buldum fakat çalıştıramadım.

şurada bir dönüşüm serisi yapmışlar bakarsınız https://gist.github.com/csete/813836 koduda kopyalayım şuraya belki bir bakan olur işe yarar

/* The setup for this code:
   http://www.oz9aec.net/index.php/arduino/343-mpx4115a-pressure-sensor-with-arduino
*/
#include LiquidCrystal.h>
#include Wire.h>

#define kpa2atm 0.00986923267

// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// pin defs
int pressurePin = 0;
int ledPin = 13;

// variables
byte res;
byte msb;
byte lsb;
int val;
float tC; // temperature in Celsius
float tF; // temperature in Fahrenheit
float pkPa; // pressure in kPa
float pAtm; // pressure in Atm

unsigned long time;


void setup()
{
  // set up led pin as output
  pinMode(ledPin, OUTPUT);
  
  // set up the LCD's number (col,row): 
  lcd.begin(20, 2);
  lcd.print("Temp");

  Serial.begin(9600);
  Wire.begin();
}

void loop()
{
  /* turn led ON */
  //digitalWrite(ledPin, HIGH);
  
  lcd.clear();

  /* get and print current time */
  time = millis()/1000;
  //lcd.print(time);
  Serial.print(time);
  Serial.print(": ");

  /* get the pressure */
  val = analogRead(pressurePin);
  pkPa = ((float)val/(float)1023+0.095)/0.009;
  pAtm = kpa2atm*pkPa;
  
  /* show pressure in kPa on LCD */
  lcd.setCursor(0,0);
  lcd.print(pkPa);
  lcd.print("kPa");
  lcd.setCursor(0,1);
  lcd.print(pAtm);
  lcd.print(" Atm");
  
  /* send pressure to serial port */
  Serial.print(pkPa);
  Serial.print("kPa ");
  Serial.print(pAtm);
  Serial.print("Atm ");
  
  /* get temperature from TMP102 */
  res = Wire.requestFrom(72,2);
  
  if (res == 2) {
    
    msb = Wire.receive(); /* Whole degrees */ 
    lsb = Wire.receive(); /* Fractional degrees */ 
    val = ((msb) << 4); /* MSB */
    val |= (lsb >> 4); /* LSB */
    
    /* calculate temperature */
    tC = val*0.0625;
    tF = (tC * 9/5) + 32;
    
    /* show temperatures on display */
    lcd.setCursor (12,0);
    lcd.print(tC);
    lcd.print("\xdf""C");

    lcd.setCursor(12, 1);
    lcd.print(tF);
    lcd.print("\xdf""F");


    Serial.print(tC);
    Serial.print("C ");
    Serial.print(tF);
    Serial.println("F");

  }
  else {
    lcd.print("ERR");
    Serial.println("ERROR");
  }
  
  /* turn led off */
  //digitalWrite(ledPin, LOW);
  
  delay(1000);
}

İlginize çok teşekkür ederim. Deneyeceğim, sonucu yine yazarım. :slight_smile:

Sayın Okoman, verdiğiniz kodları denediğimde böyle bir hata almaktayım. Bu sorunu nasıl aşabilirim. (Wire kütüphanesi yüklü olmasına rağmen) Derlemede hata: include Wire.h> sketch_feb22a:5: error: include expects “FILENAME” or

include OneWire.h>

      ^

exit status 1
include expects “FILENAME” or

Sanırım Wire kütüphanesi yok, libraries klasöründe sadece OneWire mevcut

wire standart kutuphanedir olması lazım klasorunde. siz isisle test yapıyordunuz sanırım isis den kaynaklanan bir sorun da olabilir

Arduino yazılımını yeniden yükledim, şu an wire kütüphanesi görünüyor fakat yine aynı mesajı alıyorum. Daha henüz isis aşamasına geçemedim. kütüphane çağırma kodunu şu şekilde değiştirdiğim zaman (Not: parantezleri burada gözükmesi için ekledim) include <(LiquidCrystal.h)> include <(Wire.h)> hata bu satıda çıkmayıp bu satırda gözükmekte. lsb = Wire.receive(); /* Fractional degrees */ hata mesajı ise şuna dönüyor. Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire exit status 1 Wire.receive() has been renamed Wire.read(). Bir dostum bana bir amerikan ata sözünden bahsetmişti, yaşlı köpek yeni oyun öğreniyor diye, bende şu an o durumdayım. İlginize tekrar teşekkürler.

şöyle bir durum varmış As of Arduino 1.0, the library inherits from the Stream functions, making it consistent with other read/write libraries. Because of this, send() and receive() have been replaced with read() and write(). https://www.arduino.cc/en/Reference/Wire receive gordugun yere read yazman lazım anlaşılan.

Receive yerine read yazınca derleme hatası vermedi, isis üzerinde simulasyonuda çalıştı. İlgilenen arkadaşlara çok teşekkür ederim, sağolun.