Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- christodoulos
- Date:
- 2019-08-09
- Revision:
- 5:6ad8bceabbfe
- Parent:
- 3:3d51f8870e91
File content as of revision 5:6ad8bceabbfe:
#include "mbed.h"
I2C i2c(A4,A5);
int readDelay=0.5;
int measureDelay=10;
const int ADDR_8bit = 0x15;
const int ADDR_6700 = 0x15 << 1;
int getCO2PPM() {
char data[5];
char measure[5]={0x04,0x13,0x8B,0x00,0x01};
i2c.start();
i2c.write(ADDR_6700,measure,5);
i2c.stop();
wait(readDelay);
i2c.read(ADDR_6700,data,4);
return ((data[2]&0x3F)<<8)|data[3];
}
int main()
{
while(1){
int co2PPM=getCO2PPM()*100;
float co2percentage=(float)co2PPM/10000;
printf("%f\n", co2percentage);
}
}