Commit 040a160a authored by user2684's avatar user2684 Committed by GitHub
Browse files

Use enum instead of define for defining each sensor #121 (#122)

parent a34db13e
...@@ -82,6 +82,23 @@ ...@@ -82,6 +82,23 @@
#define BATTERY_SENSOR 1 #define BATTERY_SENSOR 1
#endif #endif
// the child id used to allow remote configuration
#ifndef CONFIGURATION_CHILD_ID
#define CONFIGURATION_CHILD_ID 200
#endif
// the child id used to report the battery voltage to the controller
#ifndef BATTERY_CHILD_ID
#define BATTERY_CHILD_ID 201
#endif
// define the maximum number of sensors that can be managed
#ifndef MAX_SENSORS
#define MAX_SENSORS 10
#endif
/***********************************
Default module settings
*/
// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ACS712 // Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ACS712
#ifndef MODULE_ANALOG_INPUT #ifndef MODULE_ANALOG_INPUT
#define MODULE_ANALOG_INPUT 0 #define MODULE_ANALOG_INPUT 0
...@@ -139,101 +156,89 @@ ...@@ -139,101 +156,89 @@
#define MODULE_MCP9808 0 #define MODULE_MCP9808 0
#endif #endif
// the child id used to allow remote configuration
#ifndef CONFIGURATION_CHILD_ID
#define CONFIGURATION_CHILD_ID 200
#endif
// the child id used to report the battery voltage to the controller
#ifndef BATTERY_CHILD_ID
#define BATTERY_CHILD_ID 201
#endif
// define the maximum number of sensors that can be managed
#ifndef MAX_SENSORS
#define MAX_SENSORS 10
#endif
/*********************************** /***********************************
Sensors types Supported Sensors
*/ */
#if MODULE_ANALOG_INPUT == 1 enum supported_sensors {
// Generic analog sensor, return a pin's analog value or its percentage #if MODULE_ANALOG_INPUT == 1
#define SENSOR_ANALOG_INPUT 1 // Generic analog sensor, return a pin's analog value or its percentage
// LDR sensor, return the light level of an attached light resistor in percentage SENSOR_ANALOG_INPUT,
#define SENSOR_LDR 2 // LDR sensor, return the light level of an attached light resistor in percentage
// Thermistor sensor, return the temperature based on the attached thermistor SENSOR_LDR,
#define SENSOR_THERMISTOR 3 // Thermistor sensor, return the temperature based on the attached thermistor
// MQ2 air quality sensor SENSOR_THERMISTOR,
#define SENSOR_MQ 19 // MQ2 air quality sensor
// ML8511 UV sensor SENSOR_MQ,
#define SENSOR_ML8511 20 // ML8511 UV sensor
// Current sensor SENSOR_ML8511,
#define SENSOR_ACS712 24 // Current sensor
// rain gauge sensor SENSOR_ACS712,
#define SENSOR_RAIN_GAUGE 26 // rain gauge sensor
#endif SENSOR_RAIN_GAUGE,
#if MODULE_DIGITAL_INPUT == 1 #endif
// Generic digital sensor, return a pin's digital value #if MODULE_DIGITAL_INPUT == 1
#define SENSOR_DIGITAL_INPUT 4 // Generic digital sensor, return a pin's digital value
#endif SENSOR_DIGITAL_INPUT,
#if MODULE_DIGITAL_OUTPUT == 1 #endif
// Generic digital output sensor, allows setting the digital output of a pin to the requested value #if MODULE_DIGITAL_OUTPUT == 1
#define SENSOR_DIGITAL_OUTPUT 5 // Generic digital output sensor, allows setting the digital output of a pin to the requested value
// Relay sensor, allows activating the relay SENSOR_DIGITAL_OUTPUT,
#define SENSOR_RELAY 6 // Relay sensor, allows activating the relay
// Latching Relay sensor, allows activating the relay with a pulse SENSOR_RELAY,
#define SENSOR_LATCHING_RELAY 7 // Latching Relay sensor, allows activating the relay with a pulse
#endif SENSOR_LATCHING_RELAY,
#if MODULE_DHT == 1 #endif
// DHT11/DHT22 sensors, return temperature/humidity based on the attached DHT sensor #if MODULE_DHT == 1
#define SENSOR_DHT11 8 // DHT11/DHT22 sensors, return temperature/humidity based on the attached DHT sensor
#define SENSOR_DHT22 9 SENSOR_DHT11,
#endif SENSOR_DHT22,
#if MODULE_SHT21 == 1 #endif
// SHT21 sensor, return temperature/humidity based on the attached SHT21 sensor #if MODULE_SHT21 == 1
#define SENSOR_SHT21 10 // SHT21 sensor, return temperature/humidity based on the attached SHT21 sensor
#define SENSOR_HTU21D 15 SENSOR_SHT21,
#endif SENSOR_HTU21D,
#if MODULE_SWITCH == 1 #endif
// Generic switch, wake up the board when a pin changes status #if MODULE_SWITCH == 1
#define SENSOR_SWITCH 11 // Generic switch, wake up the board when a pin changes status
// Door sensor, wake up the board and report when an attached magnetic sensor has been opened/closed SENSOR_SWITCH,
#define SENSOR_DOOR 12 // Door sensor, wake up the board and report when an attached magnetic sensor has been opened/closed
// Motion sensor, wake up the board and report when an attached PIR has triggered SENSOR_DOOR,
#define SENSOR_MOTION 13 // Motion sensor, wake up the board and report when an attached PIR has triggered
#endif SENSOR_MOTION,
#if MODULE_DS18B20 == 1 #endif
// DS18B20 sensor, return the temperature based on the attached sensor #if MODULE_DS18B20 == 1
#define SENSOR_DS18B20 14 // DS18B20 sensor, return the temperature based on the attached sensor
#endif SENSOR_DS18B20,
#if MODULE_BH1750 == 1 #endif
// BH1750 sensor, return light in lux #if MODULE_BH1750 == 1
#define SENSOR_BH1750 16 // BH1750 sensor, return light in lux
#endif SENSOR_BH1750,
#if MODULE_MLX90614 == 1 #endif
// MLX90614 sensor, contactless temperature sensor #if MODULE_MLX90614 == 1
#define SENSOR_MLX90614 17 // MLX90614 sensor, contactless temperature sensor
#endif SENSOR_MLX90614,
#if MODULE_BME280 == 1 #endif
// MLX90614 sensor, contactless temperature sensor #if MODULE_BME280 == 1
#define SENSOR_BME280 18 // MLX90614 sensor, contactless temperature sensor
#endif SENSOR_BME280,
#if MODULE_SONOFF == 1 #endif
// Sonoff wireless smart switch #if MODULE_SONOFF == 1
#define SENSOR_SONOFF 21 // Sonoff wireless smart switch
#endif SENSOR_SONOFF,
#if MODULE_BMP085 == 1 #endif
// BMP085/BMP180 sensor, return temperature and pressure #if MODULE_BMP085 == 1
#define SENSOR_BMP085 22 // BMP085/BMP180 sensor, return temperature and pressure
#endif SENSOR_BMP085,
#if MODULE_HCSR04 == 1 #endif
// HC-SR04 sensor, return the distance between the sensor and an object #if MODULE_HCSR04 == 1
#define SENSOR_HCSR04 23 // HC-SR04 sensor, return the distance between the sensor and an object
#endif SENSOR_HCSR04,
#if MODULE_MCP9808 == 1 #endif
// MCP9808 sensor, precision temperature sensor #if MODULE_MCP9808 == 1
#define SENSOR_MCP9808 25 // MCP9808 sensor, precision temperature sensor
#endif SENSOR_MCP9808,
// last Id: 26 #endif
};
/*********************************** /***********************************
Libraries Libraries
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment