You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.5 KiB
79 lines
2.5 KiB
#ifndef MAIN_H
|
|
#define MAIN_H
|
|
|
|
// Messages on the pump command topic have format
|
|
// {"id" : <id> , "enable" : <enable> , "timeout" : <timeout>}
|
|
// Allows external control of the pumps
|
|
#define TOPIC_PUMP_COMMAND "home/devices/autowaterer/pump_command"
|
|
#define TOPIC_COMMAND_RESULT "home/devices/autowaterer/command_result"
|
|
|
|
#define CMD_OK "0"
|
|
#define PUMP_CMD_ERR_INVALID_JSON "1"
|
|
#define PUMP_CMD_ERR_INVALID_PUMP_ID "2"
|
|
#define PUMP_CMD_ERR_TOO_MANY_PUMPS "3"
|
|
#define PUMP_CMD_ERR_PUMP_ALREADY_ON "4"
|
|
#define BURST_CMD_TOO_MANY_ITERATIONS "5"
|
|
#define CALRST_CMD_INVALID_SENSOR_ID "6"
|
|
|
|
// Messages on the moisture sensor topic have format
|
|
/*
|
|
* {
|
|
* "sensor_a" : {"level" : <level%>},
|
|
* "sensor_b" : {"level" : <level%>},
|
|
* "sensor_c" : {"level" : <level%>},
|
|
* "sensor_d" : {"level" : <level%>},
|
|
* "sensor_e" : {"level" : <level%>},
|
|
* "sensor_f" : {"level" : <level%>},
|
|
* }
|
|
*/
|
|
|
|
#define TOPIC_LOG "home/devices/autowaterer/log" // General log messages
|
|
|
|
#define MAX_PUMP_TIMEOUT 30
|
|
|
|
#define GPIO_PUMPS_PORT GPIO_EXPANDER_PORT_A
|
|
#define GPIO_PUMP_ENABLE_1 0
|
|
#define GPIO_PUMP_ENABLE_2 1
|
|
#define GPIO_PUMP_ENABLE_3 2
|
|
#define GPIO_PUMP_ENABLE_4 3
|
|
#define GPIO_PUMP_ENABLE_5 4
|
|
#define GPIO_PUMP_ENABLE_6 5
|
|
#define PUMPS_COUNT 8
|
|
#define MAX_ACTIVE_PUMPS 4
|
|
|
|
#define TOPIC_MOISTURE_SENSORS "home/devices/autowaterer/moisture_sensors/" // Topic stub for publishing availability and values of sensors
|
|
#define SENSOR_A_ADDR 0x61
|
|
#define SENSOR_B_ADDR 0x62
|
|
#define SENSOR_C_ADDR 0x63
|
|
#define SENSOR_D_ADDR 0x64
|
|
#define SENSOR_E_ADDR 0x65
|
|
#define SENSOR_F_ADDR 0x66
|
|
#define SENSOR_ADDR_START 'a'
|
|
#define SENSORS_COUNT 6
|
|
#define SENSORS_UPDATE_INTERVAL 60
|
|
|
|
#define TOPIC_SENSOR_BURST "home/devices/autowaterer/moisture_sensors/burst" // Publishing a number n here will cause the device to read sensors faster for n loop cycles
|
|
#define TOPIC_CALIBRATION_RESET "home/devices/autowaterer/moisture_sensors/cal_reset" // Publishing an address here will reset the min/max values for the sensor at that address
|
|
|
|
#define ONLINE 1
|
|
#define OFFLINE 0
|
|
|
|
#define GPIO_EXPANDER_ADDR 0x20
|
|
#define GPIO_EXPANDER_PORT_A 0x12
|
|
#define GPIO_EXPANDER_PORT_B 0x13
|
|
#define GPIO_EXPANDER_DIR_A 0x00
|
|
#define GPIO_EXPANDER_DIR_B 0x01
|
|
|
|
#define I2C_SUCCESS 0
|
|
#define I2C_ADDRESS_NACK 2
|
|
#define I2C_DATA_NACK 3
|
|
|
|
#define RS485_OUTPUT_ENABLE D5
|
|
#define RS485_ERROR_TIMEOUT 0xFFFF
|
|
#define RS485_MAX_INT 0x0FFF
|
|
|
|
#define NTP_OFFSET 60 * 60 // In seconds
|
|
#define NTP_INTERVAL 60 * 1000 // In miliseconds
|
|
#define NTP_ADDRESS "europe.pool.ntp.org"
|
|
|
|
#endif |