File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
examples/LM75BTemperature Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Breakout Carrier - LM75BTemperature
3
+
4
+ The sketch shows how to read temperature from LM75B using I2C bus of the BreakoutCarrier.
5
+
6
+ The circuit:
7
+ - Portenta H7
8
+ - Breakout Carrier
9
+
10
+ This example code is in the public domain.
11
+ */
12
+
13
+ #include < Arduino_PortentaBreakoutCarrier.h>
14
+
15
+ void setup () {
16
+ Serial.begin (9600 );
17
+ while (!Serial);
18
+
19
+ // Join I2C_1 bus
20
+ Breakout.I2C_1 .begin ();
21
+
22
+ }
23
+
24
+ void loop () {
25
+
26
+ // Transmit to device 0x48 LM75B default address and select register 0x00
27
+ Breakout.I2C_1 .beginTransmission (0x48 );
28
+ Breakout.I2C_1 .write (0x00 );
29
+ Breakout.I2C_1 .endTransmission ();
30
+
31
+ // Read 2 bytes from temperature register 0x00
32
+ Breakout.I2C_1 .requestFrom (0x48 , 2 );
33
+
34
+ // Convert data into human readable format
35
+ word regdata = (Breakout.I2C_1 .read () << 8 ) | Breakout.I2C_1 .read ();
36
+ float temp = (float (regdata) / 256 );
37
+
38
+ // Print temperature
39
+ Serial.println (temp);
40
+
41
+ delay (1000 );
42
+ }
You can’t perform that action at this time.
0 commit comments