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.
Diff: main.cpp
- Revision:
- 0:87de77e861fc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jun 22 17:19:53 2022 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+#define IrThermo_Addr (0x5A<<1)
+#define Tamb 0x06
+#define Tobj 0x07
+I2C i2c(D14, D15);
+Serial pc(USBTX, USBRX);
+
+int temperature=0;
+char data_read[2];
+char data_write[1]= {Tobj};
+char data_write1[1]={Tamb};
+char data_add[1]= {(0x2E)};
+
+char counter = 0;
+uint32_t cc=0;
+uint32_t cc1=0;
+int main() {
+ //i2c.start();
+ while(1) {
+ i2c.write(IrThermo_Addr, data_write, 1, 1);
+ i2c.read(IrThermo_Addr, data_read, 2, 0);
+ temperature = (int) ((int)data_read[1] << 8) | data_read[0];
+ temperature = (temperature * 0.02 - 273.15);
+ pc.printf("Tobj=%d, ",temperature);
+
+ i2c.write(IrThermo_Addr,data_write1 , 1, 1);
+ i2c.read(IrThermo_Addr, data_read, 2, 0);
+ temperature = (int) ((int)data_read[1] << 8) | data_read[0];
+ temperature = (temperature * 0.02 - 273.15);
+ pc.printf("Tamb=%d\n",temperature);
+
+ }
+}
\ No newline at end of file