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.
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
DS18B20_SensorTemperatura.cpp
00001 #include "DS18B20_SensorTemperatura.h" 00002 00003 DS1820* probe[MAX_PROBES]; 00004 int num_temperatureSensors = 0; 00005 float temperaturas[MAX_PROBES]; 00006 00007 void inicializaSensoresTemperatura(){ 00008 // Initialize the probe array to DS1820 objects 00009 while(DS1820::unassignedProbe(DATA_PIN)) { 00010 probe[num_temperatureSensors] = new DS1820(DATA_PIN); 00011 num_temperatureSensors++; 00012 if (num_temperatureSensors == MAX_PROBES) 00013 break; 00014 } 00015 printf("Found %d device(s)\r\n\n", num_temperatureSensors); 00016 refreshSensoresTemperatura(); 00017 } 00018 00019 void refreshSensoresTemperatura(){ 00020 float aux; 00021 if(num_temperatureSensors){ 00022 probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready 00023 for (int i = 0; i<num_temperatureSensors; i++){ 00024 if((aux = probe[i]->temperature()) != -1000.0){ 00025 temperaturas[i] = aux; 00026 } 00027 if(debug){printf("Device %d returns %3.1foC\r\n", i, temperaturas[i]);} 00028 } 00029 } 00030 } 00031
Generated on Wed Jul 13 2022 12:46:24 by
1.7.2