Outils pour utilisateurs

Outils du site


Panneau latéral

FOLLOW ...

Linux, freeBSD

Python

Plugins WP

Informatique et robotique

En classe
KTURTLE
Arduino

Shell/php scripts

arduiro:php-meter

Ceci est une ancienne révision du document !


/*

int ph_pin = A0; //This is the pin number connected to Po
void setup() {
Serial.begin(9600);

void loop() {

int measure = analogRead(ph_pin);

Serial.print("Measure: ");
Serial.print(measure);
double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
Serial.print("\tVoltage: ");
Serial.print(voltage, 3);
// PH_step = (voltage@PH7 - voltage@PH4) / (PH7 - PH4)
// PH_probe = PH7 - ((voltage@PH7 - voltage@probe) / PH_step)
float Po = 7 + ((2.5 - voltage) / 0.18);
Serial.print("\tPH: ");
Serial.print(Po, 3);
Serial.println("");
delay(2000);

} */

const int phPin = A0; int sensorValue = 0; unsigned long int avgValue; float b; int buf[10],temp;

void setup () {

  Serial.begin(9600);

}

void loop () {

for (int i=0;i<10;i++) {
  buf[i]=analogRead(phPin);
  delay(10);

}

for (int i=0;i<9;i++) {
  for (int j=i+1;j<10;j++) {
    if (buf[i]>buf[j]) {
      temp=buf[i];
      buf[i]=buf[j];
      buf[j]=temp;
    }
  }
}
avgValue=0;
for(int i=2;i<8;i++) 
avgValue+=buf[i];
float phVol = (float)avgValue*5.0/1024/6;
float phValue = -5.70 * phVol + 21.34 ;
Serial.print("Sensor = ");
Serial.println(phValue);
delay(20);

}

arduiro/php-meter.1547981556.txt.gz · Dernière modification : 2019/07/17 19:24 (modification externe)