Conner Hensley / phread

Dependents:   595_Project2_Hydro

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers phread.cpp Source File

phread.cpp

00001 #include "phread.h"
00002 
00003 PHread::PHread (PinName data_pin) : 
00004     _datapin (data_pin)
00005 {}
00006 
00007 float PHread::get_pH(){
00008   float mv_voltage = 0;
00009   float ph_val=0;
00010 
00011     
00012   for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
00013   { 
00014     mv_voltage += (_datapin.read() * 3.1); 
00015     wait_ms(10);
00016   }
00017   mv_voltage /= 10;
00018   
00019   //formuala to convert from voltage signal to ph
00020   //from atlasScientific
00021   ph_val = (-5.6548 * mv_voltage) + 15.509; 
00022   
00023   
00024   
00025     return ph_val;
00026 }