From fd2537884bd55805018a2443dee0fa9be760af58 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Sat, 26 Dec 2020 18:12:33 +0100 Subject: [PATCH] Finalized mqtt topics and pin assignements --- src/main.cpp | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ccf874b..5aedadf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,30 @@ /****************************************************** * (C) 2020 Dirk Jahnke (dirk.jahnke@mailbox.org) + * Uses Arduino with Ethernet Shield. + * Thus the GPIO usage is limited, because the shield + * needs the SPI pns: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). + * + * If the SD card is to be used, then pin 4 is used as SS + * for the SD card. + * + * We use 2 outputs to control Relays for + * - switching LED at the mailbox (light on/off) and + * - trigger the internal bell (gong). + * Following pins can be used as I/O: + * - 1 + * - 2 + * - 3 + * - 5 + * - 6 + * - 7 + * - 8 + * - 9 + * - 14 (A0) + * - 15 (A1) + * - 16 (A2) + * - 17 (A3) + * - 18 (A4) + * - 19 (A5) ******************************************************/ #include @@ -15,24 +40,24 @@ IPAddress mqttServerIP(192, 168, 89, 95); const char *mqttUser = "default"; const char *mqttPassword = "12345678"; -const char *doorBellTopic = "doorBell"; -const char *postboxFlapTopic = "postboxFlap"; -const char *postboxDoorTopic = "postboxDoor"; -const char *doorBellTriggerSoundTopic = "doorBellTrigger"; -const char *postboxLightTopic = "postboxLight"; -const char *doorLightRequestTopic = "doorLightRequest"; +const char *doorBellTopic = "doorBellGW/doorbell"; +const char *postboxFlapTopic = "doorBellGW/mailboxFlap"; +const char *postboxDoorTopic = "doorBellGW/mailboxDoor"; +const char *doorBellTriggerSoundTopic = "doorBellGW/doorbellTrigger"; +const char *postboxLightTopic = "doorBellGW/light"; +const char *doorLightRequestTopic = "doorBellGW/lightRequest"; EthernetClient ethClient; EthernetServer server(80); PubSubClient mqttClient(ethClient); -#define DOOR_BELL_BUTTON_PIN 7 -#define POSTBOX_FLAP_PIN 5 -#define POSTBOX_DOOR_PIN 3 -#define LIGHT_REQUEST_BUTTON_PIN 2 +#define DOOR_BELL_BUTTON_PIN 9 +#define LIGHT_REQUEST_BUTTON_PIN 8 +#define POSTBOX_FLAP_PIN 7 +#define POSTBOX_DOOR_PIN 6 // Output pins #define LED_PIN 13 -#define DOOR_BELL_BUZZER_PIN 6 -#define POSTBOX_LIGHT_PIN 4 +#define DOOR_BELL_BUZZER_PIN 14 +#define POSTBOX_LIGHT_PIN 15 #define OUTPUT_NONE 0xff