IoT_watering project - watering unit
Dependencies: DHT11 mbed-rtos mbed ssWi
config.hpp@2:0b51e6d879df, 2017-02-16 (annotated)
- Committer:
- mariob
- Date:
- Thu Feb 16 22:08:06 2017 +0000
- Revision:
- 2:0b51e6d879df
- Parent:
- 1:7f4af0d73836
release 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mariob | 0:51143a026e2b | 1 | #ifndef __WATERING_CONFIG__ |
mariob | 0:51143a026e2b | 2 | #define __WATERING_CONFIG__ |
mariob | 0:51143a026e2b | 3 | |
mariob | 1:7f4af0d73836 | 4 | // Hardware pins |
mariob | 0:51143a026e2b | 5 | #define HW_PIN_MOISTURE p20 |
mariob | 0:51143a026e2b | 6 | #define HW_PIN_TEMPERATURE p17 |
mariob | 2:0b51e6d879df | 7 | #define HW_PIN_PUMP p25 |
mariob | 0:51143a026e2b | 8 | #define HW_PIN_LOW_WATER_LEVEL p14 |
mariob | 0:51143a026e2b | 9 | |
mariob | 0:51143a026e2b | 10 | // internal signals/events to synchronize threads |
mariob | 0:51143a026e2b | 11 | #define SIGNAL_START_ARRIVED 0x01 |
mariob | 0:51143a026e2b | 12 | #define SIGNAL_STOP_ARRIVED 0x02 |
mariob | 0:51143a026e2b | 13 | #define SIGNAL_WATERING_ARRIVED 0x03 |
mariob | 0:51143a026e2b | 14 | |
mariob | 0:51143a026e2b | 15 | // number of samples to read when the system starts |
mariob | 0:51143a026e2b | 16 | #define NUM_SAMPLES 10 |
mariob | 0:51143a026e2b | 17 | |
mariob | 0:51143a026e2b | 18 | // timeout to wait before starting |
mariob | 0:51143a026e2b | 19 | #define TIMEOUT_CONF 10.0 |
mariob | 0:51143a026e2b | 20 | // timeout to finish the sampling process |
mariob | 0:51143a026e2b | 21 | #define TIMEOUT_SAMPLING 60.0 |
mariob | 0:51143a026e2b | 22 | // timeout to read water quantity |
mariob | 0:51143a026e2b | 23 | #define TIMEOUT_WATERING 30.0 |
mariob | 0:51143a026e2b | 24 | |
mariob | 0:51143a026e2b | 25 | // time to wait between two consecutive samplings |
mariob | 0:51143a026e2b | 26 | #define INTERVAL_SAMPLING 2500 |
mariob | 0:51143a026e2b | 27 | // time between two steps of the watering algorithm |
mariob | 0:51143a026e2b | 28 | #define INTERVAL_WATERING 1000 |
mariob | 0:51143a026e2b | 29 | |
mariob | 0:51143a026e2b | 30 | // COMM VALUES |
mariob | 0:51143a026e2b | 31 | #define COMM_NO_VALUE 0x0000 |
mariob | 0:51143a026e2b | 32 | #define COMM_START_SAMPLING 0xAAAA |
mariob | 0:51143a026e2b | 33 | #define COMM_STOP_SAMPLING 0x1111 |
mariob | 0:51143a026e2b | 34 | #define COMM_START_WATERING_OFFSET 0xFF00 |
mariob | 0:51143a026e2b | 35 | #define COMM_SHUTDOWN 0x00FF |
mariob | 0:51143a026e2b | 36 | #define COMM_EXIT 0x2244 |
mariob | 0:51143a026e2b | 37 | #define COMM_SAMPLING_KO 0x2222 |
mariob | 0:51143a026e2b | 38 | #define COMM_SAMPLING_OUT 0x5555 |
mariob | 0:51143a026e2b | 39 | #define COMM_SAMPLING_OK 0xBBBB |
mariob | 0:51143a026e2b | 40 | #define COMM_WATERING_KO 0x3333 |
mariob | 0:51143a026e2b | 41 | #define COMM_WATERING_OK 0xCCCC |
mariob | 0:51143a026e2b | 42 | #define COMM_LOW_WATER_LEVEL 0x7777 |
mariob | 0:51143a026e2b | 43 | |
mariob | 0:51143a026e2b | 44 | // PORTS |
mariob | 0:51143a026e2b | 45 | #define PORT_COMMANDS 0x00 |
mariob | 0:51143a026e2b | 46 | #define PORT_HUMIDITY_OFFSET 0x01 |
mariob | 0:51143a026e2b | 47 | #define PORT_TEMPERATURE_OFFSET 0x02 |
mariob | 0:51143a026e2b | 48 | #define PORT_MOISTURE_OFFSET 0x03 |
mariob | 0:51143a026e2b | 49 | #define PORT_WATER_OFFSET 0x04 |
mariob | 0:51143a026e2b | 50 | #define PORT_RESPONSE_OFFSET 0x05 |
mariob | 0:51143a026e2b | 51 | #define GET_MOISTURE_PORT(x) (PORT_MOISTURE_OFFSET + (x.address * 5)) |
mariob | 0:51143a026e2b | 52 | #define GET_TEMPERATURE_PORT(x) (PORT_TEMPERATURE_OFFSET + (x.address * 5)) |
mariob | 0:51143a026e2b | 53 | #define GET_HUMIDITY_PORT(x) (PORT_HUMIDITY_OFFSET + (x.address * 5)) |
mariob | 0:51143a026e2b | 54 | #define GET_WATER_PORT(x) (PORT_WATER_OFFSET + (x.address * 5)) |
mariob | 0:51143a026e2b | 55 | #define GET_RESPONSE_PORT(x) (PORT_RESPONSE_OFFSET + (x.address * 5)) |
mariob | 1:7f4af0d73836 | 56 | #define GET_WATERING_COMMAND(x) (COMM_START_WATERING_OFFSET + x.address) |
mariob | 0:51143a026e2b | 57 | |
mariob | 1:7f4af0d73836 | 58 | // NETWORK |
mariob | 1:7f4af0d73836 | 59 | #define PAN_ID 102 |
mariob | 1:7f4af0d73836 | 60 | #define CHANNEL_ID 14 |
mariob | 1:7f4af0d73836 | 61 | #define XBEE_TX_PER_SECOND 3 |
mariob | 1:7f4af0d73836 | 62 | #define XBEE_RX_PER_SECOND 10 |
mariob | 1:7f4af0d73836 | 63 | #define XBEE_PIN_TX p9 |
mariob | 1:7f4af0d73836 | 64 | #define XBEE_PIN_RX p10 |
mariob | 0:51143a026e2b | 65 | |
mariob | 0:51143a026e2b | 66 | struct watering_unit_config_t { |
mariob | 0:51143a026e2b | 67 | int address; |
mariob | 0:51143a026e2b | 68 | int moisture_port; |
mariob | 0:51143a026e2b | 69 | int temperature_port; |
mariob | 0:51143a026e2b | 70 | int humidity_port; |
mariob | 0:51143a026e2b | 71 | int water_port; |
mariob | 0:51143a026e2b | 72 | int response_port; |
mariob | 0:51143a026e2b | 73 | }; |
mariob | 0:51143a026e2b | 74 | |
mariob | 0:51143a026e2b | 75 | #endif //__WATERING_CONFIG__ |