sensores:phmether
Diferencias
Muestra las diferencias entre dos versiones de la página.
sensores:phmether [2015/09/27 02:38] – creado noble | sensores:phmether [2019/06/14 23:00] (actual) – manuel.floresv | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
- | Medidor de PH. | + | ====== |
El pH es una medida de acidez o alcalinidad de una disolución. El pH indica la concentración de iones hidronio [H3O+] presentes en determinadas sustancias. Este kit permite medir de forma sencilla el pH de un líquido gracias a su placa controladora que ofrece un valor analógico proporcional a la medición. El controlador tiene un potenciometro multivuelta que permite la correcta calibración de la sonda. | El pH es una medida de acidez o alcalinidad de una disolución. El pH indica la concentración de iones hidronio [H3O+] presentes en determinadas sustancias. Este kit permite medir de forma sencilla el pH de un líquido gracias a su placa controladora que ofrece un valor analógico proporcional a la medición. El controlador tiene un potenciometro multivuelta que permite la correcta calibración de la sonda. | ||
Línea 24: | Línea 25: | ||
{{: | {{: | ||
+ | <code c> | ||
/* | /* | ||
- | |||
# This sample code is used to test the pH meter V1.0. | # This sample code is used to test the pH meter V1.0. | ||
- | |||
# Editor : YouYou | # Editor : YouYou | ||
- | |||
# Ver : 1.0 | # Ver : 1.0 | ||
- | |||
# Product: analog pH meter | # Product: analog pH meter | ||
- | |||
# SKU : SEN0161 | # SKU : SEN0161 | ||
- | |||
*/ | */ | ||
- | |||
#define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0 | #define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0 | ||
- | |||
#define Offset 0.00 //deviation compensate | #define Offset 0.00 //deviation compensate | ||
- | |||
#define LED 13 | #define LED 13 | ||
- | |||
#define samplingInterval 20 | #define samplingInterval 20 | ||
- | |||
#define printInterval 800 | #define printInterval 800 | ||
- | |||
#define ArrayLenth | #define ArrayLenth | ||
int pHArray[ArrayLenth]; | int pHArray[ArrayLenth]; | ||
- | |||
int pHArrayIndex=0; | int pHArrayIndex=0; | ||
- | |||
void setup(void) | void setup(void) | ||
- | |||
{ | { | ||
- | |||
pinMode(LED, | pinMode(LED, | ||
- | |||
Serial.begin(9600); | Serial.begin(9600); | ||
- | |||
Serial.println(" | Serial.println(" | ||
- | |||
} | } | ||
void loop(void) | void loop(void) | ||
- | |||
{ | { | ||
- | |||
static unsigned long samplingTime = millis(); | static unsigned long samplingTime = millis(); | ||
- | |||
static unsigned long printTime = millis(); | static unsigned long printTime = millis(); | ||
- | |||
static float pHValue, | static float pHValue, | ||
- | |||
if(millis()-samplingTime > samplingInterval) | if(millis()-samplingTime > samplingInterval) | ||
- | |||
{ | { | ||
- | |||
pHArray[pHArrayIndex++]=analogRead(SensorPin); | pHArray[pHArrayIndex++]=analogRead(SensorPin); | ||
- | |||
if(pHArrayIndex==ArrayLenth)pHArrayIndex=0; | if(pHArrayIndex==ArrayLenth)pHArrayIndex=0; | ||
- | |||
voltage = avergearray(pHArray, | voltage = avergearray(pHArray, | ||
- | |||
pHValue = 3.5*voltage+Offset; | pHValue = 3.5*voltage+Offset; | ||
- | |||
samplingTime=millis(); | samplingTime=millis(); | ||
- | |||
} | } | ||
- | |||
if(millis() - printTime > printInterval) | if(millis() - printTime > printInterval) | ||
- | |||
{ | { | ||
- | |||
Serial.print(" | Serial.print(" | ||
- | |||
Serial.print(voltage, | Serial.print(voltage, | ||
- | |||
Serial.print(" | Serial.print(" | ||
- | |||
Serial.println(pHValue, | Serial.println(pHValue, | ||
- | |||
digitalWrite(LED, | digitalWrite(LED, | ||
- | |||
printTime=millis(); | printTime=millis(); | ||
- | |||
} | } | ||
- | |||
} | } | ||
double avergearray(int* arr, int number){ | double avergearray(int* arr, int number){ | ||
- | |||
int i; | int i; | ||
- | |||
int max,min; | int max,min; | ||
- | |||
double avg; | double avg; | ||
- | |||
long amount=0; | long amount=0; | ||
if(number< | if(number< | ||
- | |||
Serial.println(" | Serial.println(" | ||
- | |||
return 0; | return 0; | ||
- | |||
} | } | ||
if(number< | if(number< | ||
- | |||
for(i=0; | for(i=0; | ||
- | |||
amount+=arr[i]; | amount+=arr[i]; | ||
- | |||
} | } | ||
- | |||
avg = amount/ | avg = amount/ | ||
- | |||
return avg; | return avg; | ||
- | |||
}else{ | }else{ | ||
if(arr[0]< | if(arr[0]< | ||
- | |||
min = arr[0]; | min = arr[0]; | ||
- | + | | |
- | | + | |
- | + | ||
- | | + | |
min=arr[1]; | min=arr[1]; | ||
- | |||
} | } | ||
for(i=2; | for(i=2; | ||
- | |||
if(arr[i]< | if(arr[i]< | ||
- | |||
amount+=min; | amount+=min; | ||
- | |||
min=arr[i]; | min=arr[i]; | ||
- | |||
}else { | }else { | ||
- | |||
if(arr[i]> | if(arr[i]> | ||
- | |||
amount+=max; | amount+=max; | ||
- | |||
max=arr[i]; | max=arr[i]; | ||
- | |||
}else{ | }else{ | ||
- | |||
amount+=arr[i]; | amount+=arr[i]; | ||
- | |||
} | } | ||
- | |||
}//if | }//if | ||
- | |||
}//for | }//for | ||
avg = (double)amount/ | avg = (double)amount/ | ||
- | |||
}//if | }//if | ||
return avg; | return avg; | ||
+ | } | ||
- | } | + | </ |
sensores/phmether.1443321498.txt.gz · Última modificación: por noble