use Dussolved_oxygen_sensor_on_wifi
Dependencies: watersenor_and_temp_code MQTT NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed
Fork of DS1820_IDW01M1 by
BME280/BME280.hpp
- Committer:
- e58136782000
- Date:
- 2017-11-08
- Revision:
- 7:8eaef8890eee
- Parent:
- 5:42113ea1b319
File content as of revision 7:8eaef8890eee:
#include "mbed.h" #ifndef BME280_HPP #define BME280_HPP #define BME280_size 6 Serial sensor(PA_11,PA_12);// Tx,Rx Serial pc(USBTX,USBRX); class BME280{ public: void judgement_data(char buf[]); int data_read(); int datareadfuiction(int data); void receive(); private: char buf[BME280_size]; void send_AT(); int data; }; 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"); //i++;//go to data type if(buf[i] == 0x15){ //pc.printf("Lux type\n"); i++;//04 Lux = ((buf[i+1]<<24) | (buf[i+2]<<16) | (buf[i+3]<<8) | buf[i+4])/100; //Lux = (0x00<<24) | (0x00<<16) | (0xFE<<8) | 0x40;//test //pc.printf("Lux = %d\n", Lux); }else if(buf[i] == 0x45){ //pc.printf("temp type\n"); i++;//0A Temp = ((buf[i+1]<<8)|(buf[i+2]))/100; Preesure = ((buf[i+3]<<24)|(buf[i+4]<<16)|(buf[i+5]<<8)|(buf[i+6]))/100; Hum = ((buf[i+7]<<8)|(buf[i+8]))/100; Height = ((buf[i+9]<<8)|(buf[i+10])); //pc.printf("Temp = %d\n", Temp); //pc.printf("Preesure = %d\n", Preesure); //pc.printf("Hum = %d\n", Hum); //pc.printf("Height = %d\n", Height); } } }*/ } void BME280::receive() { pc.printf("start receive \n"); for(int i=0;i<BME280_size;i++) { sensor.gets(buf,9); } } int BME280::data_read() { receive(); //wait(0.2); judgement_data(this->buf); return data; } #endif