@@ -226,7 +226,7 @@ bool addDevice(deviceType_e deviceType, uint8_t address, uint8_t muxAddress, uin
226226 }
227227 break ;
228228 default :
229- Serial.printf (" addDevice Device type not found: %d\n " , deviceType);
229+ Serial.printf (" addDevice Device type not found: %d\r\ n " , deviceType);
230230 break ;
231231 }
232232
@@ -252,12 +252,16 @@ bool beginQwiicDevices()
252252{
253253 bool everythingStarted = true ;
254254
255+ waitForQwiicBusPowerDelay (); // Wait while the qwiic devices power up - if required
256+
257+ qwiicPowerOnDelayMillis = settings.qwiicBusPowerUpDelayMs ; // Set qwiicPowerOnDelayMillis to the _minimum_ defined by settings.qwiicBusPowerUpDelayMs. It will be increased if required.
258+
255259 // Step through the list
256260 node *temp = head;
257261
258262 if (temp == NULL )
259263 {
260- Serial. println (F (" beginQwiicDevices: No devices detected" ));
264+ printDebug (F (" beginQwiicDevices: No devices detected\r\n " ));
261265 return (true );
262266 }
263267
@@ -277,20 +281,24 @@ bool beginQwiicDevices()
277281 case DEVICE_MULTIPLEXER:
278282 {
279283 QWIICMUX *tempDevice = (QWIICMUX *)temp->classPtr ;
284+ struct_multiplexer *nodeSetting = (struct_multiplexer *)temp->configPtr ; // Create a local pointer that points to same spot as node does
285+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
280286 temp->online = tempDevice->begin (temp->address , qwiic); // Address, Wire port
281287 }
282288 break ;
283289 case DEVICE_LOADCELL_NAU7802:
284290 {
285291 NAU7802 *tempDevice = (NAU7802 *)temp->classPtr ;
286292 struct_NAU7802 *nodeSetting = (struct_NAU7802 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
293+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
287294 temp->online = tempDevice->begin (qwiic); // Wire port
288295 }
289296 break ;
290297 case DEVICE_DISTANCE_VL53L1X:
291298 {
292299 SFEVL53L1X *tempDevice = (SFEVL53L1X *)temp->classPtr ;
293300 struct_VL53L1X *nodeSetting = (struct_VL53L1X *)temp->configPtr ; // Create a local pointer that points to same spot as node does
301+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
294302 if (tempDevice->begin () == 0 ) // Returns 0 if init was successful. Wire port passed in constructor.
295303 temp->online = true ;
296304 }
@@ -300,6 +308,7 @@ bool beginQwiicDevices()
300308 qwiic.setPullups (0 ); // Disable pullups for u-blox comms.
301309 SFE_UBLOX_GPS *tempDevice = (SFE_UBLOX_GPS *)temp->classPtr ;
302310 struct_uBlox *nodeSetting = (struct_uBlox *)temp->configPtr ; // Create a local pointer that points to same spot as node does
311+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
303312 temp->online = tempDevice->begin (qwiic, temp->address ); // Wire port, Address
304313 qwiic.setPullups (settings.qwiicBusPullUps ); // Re-enable pullups.
305314 }
@@ -308,86 +317,113 @@ bool beginQwiicDevices()
308317 {
309318 VCNL4040 *tempDevice = (VCNL4040 *)temp->classPtr ;
310319 struct_VCNL4040 *nodeSetting = (struct_VCNL4040 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
320+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
311321 temp->online = tempDevice->begin (qwiic); // Wire port
312322 }
313323 break ;
314324 case DEVICE_TEMPERATURE_TMP117:
315325 {
316326 TMP117 *tempDevice = (TMP117 *)temp->classPtr ;
327+ struct_TMP117 *nodeSetting = (struct_TMP117 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
328+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
317329 temp->online = tempDevice->begin (temp->address , qwiic); // Address, Wire port
318330 }
319331 break ;
320332 case DEVICE_PRESSURE_LPS25HB:
321333 {
322334 LPS25HB *tempDevice = (LPS25HB *)temp->classPtr ;
335+ struct_LPS25HB *nodeSetting = (struct_LPS25HB *)temp->configPtr ; // Create a local pointer that points to same spot as node does
336+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
323337 temp->online = tempDevice->begin (qwiic, temp->address ); // Wire port, Address
324338 }
325339 break ;
326340 case DEVICE_PRESSURE_MS5637:
327341 {
328342 MS5637 *tempDevice = (MS5637 *)temp->classPtr ;
343+ struct_MS5637 *nodeSetting = (struct_MS5637 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
344+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
329345 temp->online = tempDevice->begin (qwiic); // Wire port
330346 }
331347 break ;
332348 case DEVICE_PHT_BME280:
333349 {
334350 BME280 *tempDevice = (BME280 *)temp->classPtr ;
351+ struct_BME280 *nodeSetting = (struct_BME280 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
352+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
335353 tempDevice->setI2CAddress (temp->address );
336354 temp->online = tempDevice->beginI2C (qwiic); // Wire port
337355 }
338356 break ;
339357 case DEVICE_UV_VEML6075:
340358 {
341359 VEML6075 *tempDevice = (VEML6075 *)temp->classPtr ;
360+ struct_VEML6075 *nodeSetting = (struct_VEML6075 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
361+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
342362 temp->online = tempDevice->begin (qwiic); // Wire port
343363 }
344364 break ;
345365 case DEVICE_VOC_CCS811:
346366 {
347367 CCS811 *tempDevice = (CCS811 *)temp->classPtr ;
368+ struct_CCS811 *nodeSetting = (struct_CCS811 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
369+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
348370 temp->online = tempDevice->begin (qwiic); // Wire port
349371 }
350372 break ;
351373 case DEVICE_VOC_SGP30:
352374 {
353375 SGP30 *tempDevice = (SGP30 *)temp->classPtr ;
376+ struct_SGP30 *nodeSetting = (struct_SGP30 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
377+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
354378 temp->online = tempDevice->begin (qwiic); // Wire port
355379 }
356380 break ;
357381 case DEVICE_CO2_SCD30:
358382 {
359383 SCD30 *tempDevice = (SCD30 *)temp->classPtr ;
384+ struct_SCD30 *nodeSetting = (struct_SCD30 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
385+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
360386 temp->online = tempDevice->begin (qwiic); // Wire port
361387 }
362388 break ;
363389 case DEVICE_PHT_MS8607:
364390 {
365391 MS8607 *tempDevice = (MS8607 *)temp->classPtr ;
392+ struct_MS8607 *nodeSetting = (struct_MS8607 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
393+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
366394 temp->online = tempDevice->begin (qwiic); // Wire port
367395 }
368396 break ;
369397 case DEVICE_TEMPERATURE_MCP9600:
370398 {
371399 MCP9600 *tempDevice = (MCP9600 *)temp->classPtr ;
400+ struct_MCP9600 *nodeSetting = (struct_MCP9600 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
401+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
372402 temp->online = tempDevice->begin (temp->address , qwiic); // Address, Wire port
373403 }
374404 break ;
375405 case DEVICE_HUMIDITY_AHT20:
376406 {
377407 AHT20 *tempDevice = (AHT20 *)temp->classPtr ;
408+ struct_AHT20 *nodeSetting = (struct_AHT20 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
409+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
378410 temp->online = tempDevice->begin (qwiic); // Wire port
379411 }
380412 break ;
381413 case DEVICE_HUMIDITY_SHTC3:
382414 {
383415 SHTC3 *tempDevice = (SHTC3 *)temp->classPtr ;
416+ struct_SHTC3 *nodeSetting = (struct_SHTC3 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
417+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
384418 if (tempDevice->begin (qwiic) == 0 ) // Wire port. Returns 0 on success.
385419 temp->online = true ;
386420 }
387421 break ;
388422 case DEVICE_ADC_ADS122C04:
389423 {
390424 SFE_ADS122C04 *tempDevice = (SFE_ADS122C04 *)temp->classPtr ;
425+ struct_ADS122C04 *nodeSetting = (struct_ADS122C04 *)temp->configPtr ; // Create a local pointer that points to same spot as node does
426+ if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis ; // Increase qwiicPowerOnDelayMillis if required
391427 if (tempDevice->begin (temp->address , qwiic) == true ) // Address, Wire port. Returns true on success.
392428 temp->online = true ;
393429 }
@@ -423,7 +459,7 @@ void printOnlineDevice()
423459
424460 if (temp == NULL )
425461 {
426- Serial. println (F (" printOnlineDevice: No devices detected" ));
462+ printDebug (F (" printOnlineDevice: No devices detected" ));
427463 return ;
428464 }
429465
@@ -433,23 +469,23 @@ void printOnlineDevice()
433469 if (temp->online )
434470 {
435471 if (temp->muxAddress == 0 )
436- sprintf (sensorOnlineText, " %s online at address 0x%02X\n " , getDeviceName (temp->deviceType ), temp->address );
472+ sprintf (sensorOnlineText, " %s online at address 0x%02X\r\ n " , getDeviceName (temp->deviceType ), temp->address );
437473 else
438- sprintf (sensorOnlineText, " %s online at address 0x%02X.0x%02X.%d\n " , getDeviceName (temp->deviceType ), temp->address , temp->muxAddress , temp->portNumber );
474+ sprintf (sensorOnlineText, " %s online at address 0x%02X.0x%02X.%d\r\ n " , getDeviceName (temp->deviceType ), temp->address , temp->muxAddress , temp->portNumber );
439475
440476 deviceCount++;
441477 }
442478 else
443479 {
444- sprintf (sensorOnlineText, " %s failed to respond\n " , getDeviceName (temp->deviceType ));
480+ sprintf (sensorOnlineText, " %s failed to respond\r\ n " , getDeviceName (temp->deviceType ));
445481 }
446482 Serial.print (sensorOnlineText);
447483
448484 temp = temp->next ;
449485 }
450486
451487 if (settings.printDebugMessages == true )
452- Serial.printf (" Device count: %d\n " , deviceCount);
488+ Serial.printf (" Device count: %d\r\ n " , deviceCount);
453489}
454490
455491// Given the node number, apply the node's configuration settings to the device
@@ -633,7 +669,7 @@ void configureDevice(node * temp)
633669 }
634670 break ;
635671 default :
636- Serial.printf (" configureDevice: Unknown device type %d: %s\n " , deviceType, getDeviceName ((deviceType_e)deviceType));
672+ Serial.printf (" configureDevice: Unknown device type %d: %s\r\ n " , deviceType, getDeviceName ((deviceType_e)deviceType));
637673 break ;
638674 }
639675}
@@ -1154,14 +1190,14 @@ deviceType_e testDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumb
11541190 default :
11551191 {
11561192 if (muxAddress == 0 )
1157- Serial.printf (" Unknown device at address (0x%02X)\n " , i2cAddress);
1193+ Serial.printf (" Unknown device at address (0x%02X)\r\ n " , i2cAddress);
11581194 else
1159- Serial.printf (" Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\n " , i2cAddress, muxAddress, portNumber);
1195+ Serial.printf (" Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\r\ n " , i2cAddress, muxAddress, portNumber);
11601196 return DEVICE_UNKNOWN_DEVICE;
11611197 }
11621198 break ;
11631199 }
1164- Serial.printf (" Known I2C address but device failed identification at address 0x%02X\n " , i2cAddress);
1200+ Serial.printf (" Known I2C address but device failed identification at address 0x%02X\r\ n " , i2cAddress);
11651201 return DEVICE_UNKNOWN_DEVICE;
11661202}
11671203
@@ -1191,9 +1227,9 @@ deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portN
11911227 default :
11921228 {
11931229 if (muxAddress == 0 )
1194- Serial.printf (" Unknown device at address (0x%02X)\n " , i2cAddress);
1230+ Serial.printf (" Unknown device at address (0x%02X)\r\ n " , i2cAddress);
11951231 else
1196- Serial.printf (" Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\n " , i2cAddress, muxAddress, portNumber);
1232+ Serial.printf (" Unknown device at address (0x%02X)(Mux:0x%02X Port:%d)\r\ n " , i2cAddress, muxAddress, portNumber);
11971233 return DEVICE_UNKNOWN_DEVICE;
11981234 }
11991235 break ;
0 commit comments