mysensors.cpp 1.32 KB
Newer Older
Nelso Jost's avatar
Nelso Jost committed
1
2
3
4
5
6
7
8
9
10
11
12
13
/*------------------------------------------------------------------------------
 * AUTO-GENERATED CODE FROM CTA-EMM-WEB
 * EDIT ONLY IF YOU KNOW WHAT YOU ARE DOING
 *----------------------------------------------------------------------------*/
#include "mysensors.h"
#include "utils.h"

// === LDR SETUP =======================================

#define  LDR_PIN     0   // analog

String read_LDR()
{
Nelso Jost's avatar
Nelso Jost committed
14
    return String(100/1023.0 - analogRead(LDR_PIN));
Nelso Jost's avatar
Nelso Jost committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
}

// === DHT22 SETUP =======================================

// https://github.com/adafruit/DHT-sensor-library

#include "DHT.h"
#define DHT22_PIN        4   // digital
#define DHTTYPE DHT22
DHT dht(DHT22_PIN, DHTTYPE);

String read_DHT22_TEMP()
{
    return FloatToString(dht.readTemperature());
}

String read_DHT22_AH()
{
    return FloatToString(dht.readHumidity());
}

// === BMP085 SETUP ===============================================

// https://github.com/adafruit/Adafruit-BMP085-Library

#include "Adafruit_BMP085.h"
Adafruit_BMP085 bmp;
bool is_bmp085_connected=false;

String read_BMP085_PRESSURE()
{
    if (is_bmp085_connected)
        return String(bmp.readPressure());
    else
        return String("<bmp085_not_found>");
}
// ----------------------------------------------------------------

void mysensors_setup()
{
    dht.begin();
    is_bmp085_connected = bmp.begin();
}