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.
main.cpp
00001 #include "mbed.h" 00002 00003 // veranderd! 00004 00005 // Read temperature from TH06 00006 00007 // p6 PA_8 / XBEE_PWM0 / XBEE_RSSI / I2C_SCL D15 00008 // p7 PC_9 / XBEE_PWM1 / I2C_SDA D14 00009 I2C i2c(PC_9,PA_8); 00010 00011 const int addr = 0x80; 00012 00013 int main() { 00014 char cmd[2]; 00015 00016 while (1) { 00017 cmd[0] = 0xf3; 00018 i2c.write(addr, cmd, 1); 00019 00020 wait(0.5); 00021 00022 i2c.read(addr, cmd, 2); 00023 00024 float temp_code = (cmd[0]<<8)|cmd[1]; 00025 float temp = 175.72*temp_code/65535.0-46.85; 00026 00027 printf("Temp = %.2f\r\n", temp); 00028 } 00029 }
Generated on Wed Jul 13 2022 15:13:42 by
1.7.2