|
1 /***************************************************************************** |
|
2 * Copyright (C) 2014 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of the mbsePi-apps |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * mbsePi-apps is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with EC-65K; see the file COPYING. If not, write to the Free |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 #include "../lib/mbselib.h" |
|
24 #include "dht11.h" |
|
25 |
|
26 #ifdef HAVE_WIRINGPI_H |
|
27 |
|
28 extern int dht11_valid; |
|
29 extern int dht11_temperature; |
|
30 extern int dht11_humidity; |
|
31 |
|
32 int main(int argc, char *argv[]) { |
|
33 |
|
34 int PIN = 3; |
|
35 |
|
36 if (wiringPiSetup() == -1) |
|
37 return 0; |
|
38 |
|
39 dht11Init(PIN, 0, 6); |
|
40 dht11Read(); |
|
41 if (dht11_valid) { |
|
42 fprintf(stdout, "DHT11: temperature %d degrees, humidity %d%%\n", dht11_temperature, dht11_humidity); |
|
43 } else { |
|
44 fprintf(stdout, "DHT11: no valid data or sensor not connected\n"); |
|
45 } |
|
46 |
|
47 exit(0); |
|
48 } |
|
49 |
|
50 #else |
|
51 |
|
52 int main(int argc, char *argv[]) { |
|
53 fprintf(stderr, "This program does nothing without the wiringPi library\n"); |
|
54 return 0; |
|
55 } |
|
56 |
|
57 #endif |
|
58 |