Fix for 1Wire sensor reading. Only 1value per loop step
This commit is contained in:
		
							parent
							
								
									6a608aba5c
								
							
						
					
					
						commit
						2b885ec915
					
				| 
						 | 
				
			
			@ -328,6 +328,7 @@ void sensorTask(void *param){
 | 
			
		|||
    double voffset = (api->getConfig()->getConfigItem(api->getConfig()->vOffset,true)->asString()).toFloat();
 | 
			
		||||
    double vslope = (api->getConfig()->getConfigItem(api->getConfig()->vSlope,true)->asString()).toFloat();
 | 
			
		||||
 | 
			
		||||
    static long loopCounter = 0;    // Loop counter for 1Wire data transmission
 | 
			
		||||
    long starttime0 = millis();     // GPS update all 100ms
 | 
			
		||||
    long starttime5 = millis();     // Voltage update all 1s
 | 
			
		||||
    long starttime6 = millis();     // Environment sensor update all 1s
 | 
			
		||||
| 
						 | 
				
			
			@ -390,6 +391,8 @@ void sensorTask(void *param){
 | 
			
		|||
            float tempC;
 | 
			
		||||
            ds18b20.requestTemperatures();  // Collect all temperature values (max.8)
 | 
			
		||||
            for(int i=0;i<numberOfDevices; i++){
 | 
			
		||||
                // Send only one 1Wire data per loop step (time reduction)
 | 
			
		||||
                if(i == loopCounter % numberOfDevices){
 | 
			
		||||
                    if(ds18b20.getAddress(tempDeviceAddress, i)){
 | 
			
		||||
                        // Read temperature value in Celsius
 | 
			
		||||
                        tempC = ds18b20.getTempC(tempDeviceAddress); 
 | 
			
		||||
| 
						 | 
				
			
			@ -403,6 +406,8 @@ void sensorTask(void *param){
 | 
			
		|||
                    }
 | 
			
		||||
                }    
 | 
			
		||||
            }
 | 
			
		||||
            loopCounter++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If GPS not ready or installed then send RTC time on bus all 500ms
 | 
			
		||||
        if(millis() > starttime12 + 500){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue