ขออนุญาตทุกคนหน่อยนะครับ
ผมจะขอความแนะนำ/และสอบจากทุกคนหน่อยครับ
ตอนนี้ผมทำตัวโครงงานจบ อยู่ ครับ แล้วตอนนี้ในโครงงานผมมีตัวเซนเซอร์วัดค่าPHอยู่
แล้ววันนี้ผมลองเซนเซอร์PHสรุปผลคือมันค่ามันคงที่ครับ ลองโค๊ดจากแหล่งอื่นแล้วค่ามันคงที่อยู่
ผมจะขอความแนะนำจากพวกพี่ๆทุกคนหน่อยครับ
-บอร์ดmodule,เซนเซอร์ มีปัญหาหรือไม่?
-โค๊ดมีปัญหา ?
ตัวบอร์ดที่ต่อกับเซนเซอร์จะเป็น esp32 ขา 32 ต่อกับ Po ครับ
ผมอยากได้วิธีเช็คเซนเซอร์ตัวนี้มากครับ เพือ ไว้เช็คไว้ครั้งหน้าครับ
โค๊ดที่ผมเอามาลองครับ ครับ
/#define BLYNK_TEMPLATE_ID "TMPL4yDpPzsU" เกี่ยวกับบลิ้ง
//#define BLYNK_DEVICE_NAME "Smart Dustbin"
//#define BLYNK_FIRMWARE_VERSION "0.1.0"
//#define BLYNK_PRINT Serial
//#include "BlynkEdgent.h"
#define SensorPin 32 //pH meter Analog output to Arduino Analog Input กำหนดขา
unsigned long int avgValue; //Store the average value of the sensor feedback
float b;
int buf[10],temp;
int f; // for float value to string converstion
float val; // also works with double.
char buff2[10];
String valueString = "";
String Value = "";
void PH_Value()
{
for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf=analogRead(SensorPin);
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf>buf[j])
{
temp=buf;
buf=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf;
float phValue=(float)avgValue*3.3/1024/6; //convert the analog into millivolt
phValue=3.5*phValue; //convert the millivolt into pH value
Value = dtostrf(phValue, 4, 2, buff2); //4 is mininum width, 6 is precision
Serial.print(Value);
valueString = "";
delay(1000);
//Blynk.virtualWrite(V0, 7.06);
}
void setup()
{
Serial.begin(9600);
//BlynkEdgent.begin();
delay(2000);
}
void loop()
{
//BlynkEdgent.run();
PH_Value();
}
สอบถาม เรื่อง เซนเซอร์ PH ครับ
ผมจะขอความแนะนำ/และสอบจากทุกคนหน่อยครับ
ตอนนี้ผมทำตัวโครงงานจบ อยู่ ครับ แล้วตอนนี้ในโครงงานผมมีตัวเซนเซอร์วัดค่าPHอยู่
แล้ววันนี้ผมลองเซนเซอร์PHสรุปผลคือมันค่ามันคงที่ครับ ลองโค๊ดจากแหล่งอื่นแล้วค่ามันคงที่อยู่
ผมจะขอความแนะนำจากพวกพี่ๆทุกคนหน่อยครับ
-บอร์ดmodule,เซนเซอร์ มีปัญหาหรือไม่?
-โค๊ดมีปัญหา ?
ตัวบอร์ดที่ต่อกับเซนเซอร์จะเป็น esp32 ขา 32 ต่อกับ Po ครับ
ผมอยากได้วิธีเช็คเซนเซอร์ตัวนี้มากครับ เพือ ไว้เช็คไว้ครั้งหน้าครับ
โค๊ดที่ผมเอามาลองครับ ครับ
/#define BLYNK_TEMPLATE_ID "TMPL4yDpPzsU" เกี่ยวกับบลิ้ง
//#define BLYNK_DEVICE_NAME "Smart Dustbin"
//#define BLYNK_FIRMWARE_VERSION "0.1.0"
//#define BLYNK_PRINT Serial
//#include "BlynkEdgent.h"
#define SensorPin 32 //pH meter Analog output to Arduino Analog Input กำหนดขา
unsigned long int avgValue; //Store the average value of the sensor feedback
float b;
int buf[10],temp;
int f; // for float value to string converstion
float val; // also works with double.
char buff2[10];
String valueString = "";
String Value = "";
void PH_Value()
{
for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf=analogRead(SensorPin);
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf>buf[j])
{
temp=buf;
buf=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf;
float phValue=(float)avgValue*3.3/1024/6; //convert the analog into millivolt
phValue=3.5*phValue; //convert the millivolt into pH value
Value = dtostrf(phValue, 4, 2, buff2); //4 is mininum width, 6 is precision
Serial.print(Value);
valueString = "";
delay(1000);
//Blynk.virtualWrite(V0, 7.06);
}
void setup()
{
Serial.begin(9600);
//BlynkEdgent.begin();
delay(2000);
}
void loop()
{
//BlynkEdgent.run();
PH_Value();
}