Dependencies:   DS1820 Sigfox_Com mbed

Fork of DS1820_HelloWorld by Erik -

Committer:
Aureb29
Date:
Mon Oct 16 13:04:25 2017 +0000
Revision:
5:055a7eab58d6
Parent:
3:f483abe4bc57

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 0:e069f9f26768 1 #define MULTIPLE_PROBES
Sissors 2:d644c874ea0c 2 #define DATA_PIN A0
Sissors 0:e069f9f26768 3
Sissors 0:e069f9f26768 4
Sissors 0:e069f9f26768 5 #ifdef MULTIPLE_PROBES
Sissors 0:e069f9f26768 6
Sissors 0:e069f9f26768 7 #include "mbed.h"
Sissors 0:e069f9f26768 8 #include "DS1820.h"
Sissors 0:e069f9f26768 9
Sissors 0:e069f9f26768 10 #define MAX_PROBES 16
Aureb29 5:055a7eab58d6 11
Aureb29 5:055a7eab58d6 12 Serial sigfox(A7,A2);
Aureb29 5:055a7eab58d6 13
Sissors 0:e069f9f26768 14 DS1820* probe[MAX_PROBES];
Sissors 0:e069f9f26768 15
Sissors 0:e069f9f26768 16 int main() {
Sissors 0:e069f9f26768 17 // Initialize the probe array to DS1820 objects
Sissors 0:e069f9f26768 18 int num_devices = 0;
Sissors 0:e069f9f26768 19 while(DS1820::unassignedProbe(DATA_PIN)) {
Sissors 0:e069f9f26768 20 probe[num_devices] = new DS1820(DATA_PIN);
Sissors 0:e069f9f26768 21 num_devices++;
Sissors 0:e069f9f26768 22 if (num_devices == MAX_PROBES)
Sissors 0:e069f9f26768 23 break;
Sissors 0:e069f9f26768 24 }
Sissors 0:e069f9f26768 25
Aureb29 5:055a7eab58d6 26 sigfox.printf("AT$SF=%3.1f\r\n");
Aureb29 5:055a7eab58d6 27
Sissors 0:e069f9f26768 28 while(1) {
Sissors 0:e069f9f26768 29 probe[0]->convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready
Sissors 0:e069f9f26768 30 for (int i = 0; i<num_devices; i++)
Aureb29 5:055a7eab58d6 31 printf("La temperature du sol est de %3.1f oC\r\n", i, probe[i]->temperature());
Sissors 0:e069f9f26768 32 printf("\r\n");
Sissors 0:e069f9f26768 33 wait(1);
Sissors 0:e069f9f26768 34 }
Sissors 0:e069f9f26768 35
Sissors 0:e069f9f26768 36 }
Sissors 0:e069f9f26768 37
Sissors 0:e069f9f26768 38 #else
Sissors 0:e069f9f26768 39 #include "mbed.h"
Sissors 0:e069f9f26768 40 #include "DS1820.h"
Sissors 0:e069f9f26768 41
Sissors 0:e069f9f26768 42 DS1820 probe(DATA_PIN);
Sissors 0:e069f9f26768 43
Sissors 0:e069f9f26768 44 int main() {
Sissors 0:e069f9f26768 45 while(1) {
Sissors 0:e069f9f26768 46 probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready
Sissors 0:e069f9f26768 47 printf("It is %3.1foC\r\n", probe.temperature());
Sissors 0:e069f9f26768 48 wait(1);
Sissors 0:e069f9f26768 49 }
Sissors 0:e069f9f26768 50 }
Sissors 0:e069f9f26768 51
Sissors 0:e069f9f26768 52 #endif