@@ -40,20 +40,20 @@ String macToStr(const uint8_t* mac)
40
40
void setup () {
41
41
Serial.begin (115200 );
42
42
delay (10 );
43
-
43
+
44
44
Serial.println ();
45
45
Serial.println ();
46
46
Serial.print (" Connecting to " );
47
47
Serial.println (ssid);
48
-
48
+
49
49
WiFi.begin (ssid, password);
50
-
50
+
51
51
while (WiFi.status () != WL_CONNECTED) {
52
52
delay (500 );
53
53
Serial.print (" ." );
54
54
}
55
55
Serial.println (" " );
56
- Serial.println (" WiFi connected" );
56
+ Serial.println (" WiFi connected" );
57
57
Serial.println (" IP address: " );
58
58
Serial.println (WiFi.localIP ());
59
59
@@ -70,7 +70,7 @@ void setup() {
70
70
Serial.print (server);
71
71
Serial.print (" as " );
72
72
Serial.println (clientName);
73
-
73
+
74
74
if (client.connect ((char *) clientName.c_str ())) {
75
75
Serial.println (" Connected to MQTT broker" );
76
76
}
@@ -87,12 +87,12 @@ void loop() {
87
87
byte type_s;
88
88
byte data[12 ];
89
89
byte addr[8 ];
90
-
90
+
91
91
92
92
// Loop through all DS1820
93
93
94
94
while (ds.search (addr))
95
- {
95
+ {
96
96
Serial.print (" ROM =" );
97
97
98
98
// Topic is built from a static String plus the ID of the DS18B20
@@ -108,7 +108,7 @@ while(ds.search(addr))
108
108
return ;
109
109
}
110
110
Serial.println ();
111
-
111
+
112
112
// the first ROM byte indicates which chip
113
113
switch (addr[0 ]) {
114
114
case 0x10 :
@@ -126,17 +126,17 @@ while(ds.search(addr))
126
126
default :
127
127
Serial.println (" Device is not a DS18x20 family device." );
128
128
return ;
129
- }
129
+ }
130
130
131
131
ds.reset ();
132
132
ds.select (addr);
133
133
ds.write (0x44 , 1 ); // start conversion, with parasite power on at the end
134
-
134
+
135
135
delay (1000 ); // maybe 750ms is enough, maybe not
136
136
// we might do a ds.depower() here, but the reset will take care of it.
137
-
137
+
138
138
present = ds.reset ();
139
- ds.select (addr);
139
+ ds.select (addr);
140
140
ds.write (0xBE ); // Read Scratchpad
141
141
142
142
Serial.print (" Data = " );
@@ -190,5 +190,3 @@ Serial.println("End of Onewire Bus");
190
190
ds.reset_search ();
191
191
return ;
192
192
}
193
-
194
-
0 commit comments