turbidity sensor

Dependencies:   watersenor_and_temp_code MQTT NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed

Fork of Dissolved_oxygen_sensor_online by wang tang

Revision:
5:42113ea1b319
Parent:
3:30d9b8d9adc9
--- a/BME280/BME280.hpp	Sat Nov 04 00:14:23 2017 +0800
+++ b/BME280/BME280.hpp	Mon Nov 06 15:04:43 2017 +0000
@@ -1,28 +1,34 @@
 #include "mbed.h"
-
 #ifndef BME280_HPP
 #define BME280_HPP
 
-#define BME280_size 14
+#define BME280_size 5
 
-Serial sensor(PA_11,PA_12);
+Serial sensor(PA_11,PA_12);// Tx,Rx
 Serial pc(USBTX,USBRX);
-int AT[3] = {0xA5,0x52,0xF7};
 class BME280{
 public:
     void judgement_data(char buf[]);
-    int Temp_read();
+    int data_read();
 
+    int datareadfuiction(int data);
+    void receive();   
 private:
-    void receive();
+    char buf[BME280_size];
     void send_AT();
-    char buf[BME280_size];
-    int Lux,Temp,Preesure,Hum,Height;
+
+    int data;
 
 };
-void BME280::judgement_data(char buf[]){
-    int i=0;
-    if(buf[i++]== 0x5A){
+int BME280::datareadfuiction(int data)
+{
+   return  buf[data];
+}
+void BME280::judgement_data(char buf[])
+{
+//    int i=0;
+    
+/*    if(buf[i++]== 0x5A){
         //pc.printf("first_step\n");
         if(buf[i++]== 0x5A){
             //pc.printf("second_step\n");
@@ -46,30 +52,25 @@
                 //pc.printf("Height = %d\n", Height);
             }
         }
-    }
+    }*/
 }
 void BME280::receive()
 {
-    for(int i=0;i<BME280_size;i++){
-        buf[i] = sensor.getc();  
-        //pc.putc(buf[i]);
+    pc.printf("start receive \n");
+    for(int i=0;i<BME280_size;i++)
+    {
+        sensor.gets(buf,8); 
     }
     
 }
-void BME280::send_AT(){
-    for(int i=0;i<3;i++){
-        sensor.putc(AT[i]);
-        //pc.putc(AT[i]);
-    }
-}
-int BME280::Temp_read(){
-    send_AT();
-    //wait(0.2);
+
+int BME280::data_read()
+{
     receive();
     //wait(0.2);
     judgement_data(this->buf);
     
-    return Temp;
+    return data;
 }
 
 #endif