config.public.h 7.08 KB
Newer Older
1
2
3
4
#ifndef CONFIG_H_INCLUDED
#  define CONFIG_H_INCLUDED

// This file is a config template, and can be copied to config.h. Please don't save any important password in this template.
5
6
7
// NOTE: Every parameter can be modified and saved later via the web-config.
// Some of those parameters can also be modified via commands in the Serial monitor :
//    e.g. 'wifi 0' to turn WiFi off, or 'csv 60' to log data in csv every minute.
8
9
10
11
12

/**
 * SERVICES
 */

13
14
15
16
17
// Define the default for corresponding services. They can be enabled/disabled later in the web-config.
#  define AMPEL_WIFI    true   // Should ESP connect to WiFi? It allows the Ampel to get time from an NTP server.
#  define AMPEL_MQTT    true   // Should data be sent over MQTT? (AMPEL_WIFI should be enabled too)
#  define AMPEL_CSV     true   // Should data be logged as CSV, on the ESP flash memory?
#  define AMPEL_LORAWAN false  // Should data be sent over LoRaWAN? (Requires ESP32 + LoRa modem, and "MCCI LoRaWAN LMIC library")
18
19
20
21
22

/**
 * WIFI
 */

23
#  define WIFI_SSID     "MY_SSID"
24
#  define WIFI_PASSWORD "P4SSW0RD"
Eric Duminil's avatar
Eric Duminil committed
25
#  define WIFI_TIMEOUT  30 // [s]
26
27
28
29
30
31

/**
 * Sensor
 */

// How often should measurement be performed, and displayed?
32
33
34
//WARNING: On some sensors, measurements become very unreliable when timestep is set to 2s.
//NOTE: 10s or longer should be fine in order to get reliable results.
//NOTE: SCD30 timer does not seem to be very precise. Time variations may occur.
35
36
37
38
#  define MEASUREMENT_TIMESTEP 60 // [s] Value between 2 and 1800 (range for SCD30 sensor)

// How often should measurements be appended to CSV ?
// Set to 0 if you want to send values after each measurement
39
// WARNING: Writing too often might damage the ESP memory
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#  define CSV_INTERVAL 300 // [s]

// Residual heat from CO2 sensor seems to be high enough to change the temperature reading. How much should it be offset?
// NOTE: Sign isn't relevant. The returned temperature will always be shifted down.
#  define TEMPERATURE_OFFSET -3 // [K]

// Altitude above sea level
// Used for CO2 calibration
// here: Stuttgart, Schellingstr. 24. (Source: Google Earth)
#  define ALTITUDE_ABOVE_SEA_LEVEL 260 // [m]

// The reference CO2 concentration has to be within the range 400 ppm ≤ cref(CO2) ≤ 2000 ppm.
// Used for CO2 calibration
// here : measured concentration in Stuttgart
#  define ATMOSPHERIC_CO2_CONCENTRATION 425 // [ppm]

// Should the sensor try to calibrate itself?
// Sensirion recommends 7 days of continuous readings with at least 1 hour a day of 'fresh air' for self-calibration to complete.
58
#  define AUTO_CALIBRATE_SENSOR false // [true / false]
59
60
61
62
63
64

/**
 * LEDs
 */

// LED brightness, which can vary between min and max brightness ("LED breathing")
Eric Duminil's avatar
Eric Duminil committed
65
// MAX_BRIGHTNESS must be defined, and should be between 0 and 255.
66
#  define MAX_BRIGHTNESS 255
Eric Duminil's avatar
Eric Duminil committed
67
68
// MIN_BRIGHTNESS, if defined, should be between 0 and MAX_BRIGHTNESS - 1
// If MIN_BRIGHTNESS is not set, or if it is set to MAX_BRIGHTNESS, breathing is disabled.
69
#  define MIN_BRIGHTNESS 60
70
71
// How many LEDs in the ring? 12 and 16 are currently supported. If undefined, 12 is used as default.
#  define LED_COUNT 12
72
73

/**
74
75
76
 * AMPEL PASSWORD
 * will be used for Access Point (without username), and for web-server available at http://local_ip
 * with user 'admin', without quotes.
77
78
 */

79
80
81
// If left empty, the password will be set during the first configuration, via access point.
// In order to be set successfully, it should have at least 8 characters.
#  define AMPEL_PASSWORD ""
82
83

/**
84
 * MQTT
85
86
87
 */

/*
88
 * If AMPEL_MQTT is enabled, co2ampel will publish data every MQTT_SENDING_INTERVAL seconds.
89
90
91
 * An MQTT subscriber can then get the data from the corresponding broker, either encrypted or unencrypted:
 *
 *  ❯ mosquitto_sub -h 'test.mosquitto.org' -p 8883 -t 'CO2sensors/#' --cafile mosquitto.org.crt -v
92
93
 *  CO2sensors/ESPd03cc5 {"time":"2020-12-13 13:14:37+01", "co2":571, "temp":18.9, "rh":50.9}
 *  CO2sensors/ESPd03cc5 {"time":"2020-12-13 13:14:48+01", "co2":573, "temp":18.9, "rh":50.2}
94
95
96
 *  ...
 *
 *  ❯ mosquitto_sub -h 'test.mosquitto.org' -t 'CO2sensors/#' -v
97
98
 *  CO2sensors/ESPd03cc5 {"time":"2020-12-13 13:15:09+01", "co2":568, "temp":18.9, "rh":50.1}
 *  CO2sensors/ESPd03cc5 {"time":"2020-12-13 13:15:20+01", "co2":572, "temp":18.9, "rh":50.3}
99
100
101
102
103
104
105
106
107
108
109
 *  ...
 */

/*
 * Allow sensor to be configured over MQTT? Very useful for debugging. For example:
 *   mosquitto_pub -h 'test.mosquitto.org' -t 'CO2sensors/ESPe08dc9/control' -m 'timer 30'
 *   mosquitto_pub -h 'test.mosquitto.org' -t 'CO2sensors/ESPe08dc9/control' -m 'calibrate'
 *   mosquitto_pub -h 'test.mosquitto.org' -t 'CO2sensors/ESPe08dc9/control' -m 'reset'
 */
#  define ALLOW_MQTT_COMMANDS false

Eric Duminil's avatar
Eric Duminil committed
110
// How often should measurements be sent to MQTT server?
111
112
113
// Set to 0 if you want to send values after each measurement
// #  define MQTT_SENDING_INTERVAL MEASUREMENT_TIMESTEP * 5 // [s]
#  define MQTT_SENDING_INTERVAL 60 // [s]
114
115
#  define MQTT_SERVER "test.mosquitto.org"  // MQTT server URL or IP address
#  define MQTT_PORT 8883
116
#  define MQTT_ENCRYPTED true // Set to false for unencrypted MQTT (e.g. with port 1883). If undefined, MQTT_ENCRYPTED will be set to true.
117
118
119
#  define MQTT_USER ""
#  define MQTT_PASSWORD ""

120
121
122
123
/**
 * LoRaWAN
 */

Eric Duminil's avatar
Eric Duminil committed
124
// 1) Requires "MCCI LoRaWAN LMIC library", which will be automatically used with PlatformIO but should be added in "Arduino IDE".
125
126
127
128
// 2) Region and transceiver type should be specified in:
//     * Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/lmic_project_config.h for Arduino IDE
//     * platformio.ini for PlatformIO
//    See https://github.com/mcci-catena/arduino-lmic#configuration for more information
Eric Duminil's avatar
Eric Duminil committed
129
130
// 3) It has been tested with "TTGO ESP32 SX1276 LoRa 868" and will only work with an ESP32 + LoRa modem
// 4) In order to use LoRaWAN, a gateway should be close to the co2ampel, and an account, an application and a device should be registered,
131
//      e.g. on https://www.thethingsindustries.com/docs/integrations/
Eric Duminil's avatar
Eric Duminil committed
132
// 5) The corresponding keys should be defined in LORAWAN_DEVICE_EUI, LORAWAN_APPLICATION_EUI and LORAWAN_APPLICATION_KEY
133
// How often should measurements be sent over LoRaWAN?
Eric Duminil's avatar
Notes    
Eric Duminil committed
134
#  define LORAWAN_SENDING_INTERVAL 300 // [s] This value should not be too low. See https://www.thethingsnetwork.org/docs/lorawan/duty-cycle.html#maximum-duty-cycle
Eric Duminil's avatar
Eric Duminil committed
135

136
// WARNING: If AMPEL_LORAWAN is true, you need to modify the 3 following constants!
137
138
139
140
// This EUI must be in little-endian format, so least-significant-byte first.
// When copying an EUI from ttnctl output, this means to reverse the bytes.
#  define LORAWAN_DEVICE_EUI      {0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11}
// This should also be in little endian format, see above.
141
#  define LORAWAN_APPLICATION_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
142
143
144
145
146
// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
#  define LORAWAN_APPLICATION_KEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }

147
148
149
150
151
/**
 * NTP
 */

#  define NTP_SERVER "pool.ntp.org"
152
#  define UTC_OFFSET_IN_SECONDS 7200 // [s] 3600 for UTC+1, 7200 for UTC+1 and daylight saving time
153
154

#endif