OULOUTECH / Mbed 2 deprecated DS1820_HelloWorld

Dependencies:   DS1820 Sigfox_Com mbed

Fork of DS1820_HelloWorld by Erik -

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #define MULTIPLE_PROBES
00002 #define DATA_PIN        A0
00003 
00004 
00005 #ifdef MULTIPLE_PROBES
00006 
00007 #include "mbed.h"
00008 #include "DS1820.h"
00009 
00010 #define MAX_PROBES      16
00011 
00012 Serial sigfox(A7,A2);
00013 
00014 DS1820* probe[MAX_PROBES];
00015  
00016 int main() {  
00017     // Initialize the probe array to DS1820 objects
00018     int num_devices = 0;
00019     while(DS1820::unassignedProbe(DATA_PIN)) {
00020         probe[num_devices] = new DS1820(DATA_PIN);
00021         num_devices++;
00022         if (num_devices == MAX_PROBES)
00023             break;
00024     }
00025     
00026     sigfox.printf("AT$SF=%3.1f\r\n");
00027     
00028     while(1) {
00029         probe[0]->convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
00030         for (int i = 0; i<num_devices; i++)
00031             printf("La temperature du sol est de %3.1f oC\r\n", i, probe[i]->temperature());
00032         printf("\r\n");
00033         wait(1);
00034     }
00035     
00036 }
00037 
00038 #else
00039 #include "mbed.h"
00040 #include "DS1820.h"
00041  
00042 DS1820 probe(DATA_PIN);
00043  
00044 int main() {
00045     while(1) {
00046         probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
00047         printf("It is %3.1foC\r\n", probe.temperature());
00048         wait(1);
00049     }
00050 }
00051 
00052 #endif