Opinions on Arduino based cable connection

Others (MiLight, Hue, Toon etc...)
Post Reply
febalci
Posts: 339
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Opinions on Arduino based cable connection

Post by febalci » Saturday 14 October 2017 14:40

Hi all,

Planning a Domoticz installation on Raspberry Pi. For sensors, i have cabled reed switches and cabled PIRs. What i am planning is to collect all sensor cables to an Arduino Mega IO, and send all switch status from the Arduino to Rpi from ethernet shield. I have no intention of using wireless in any sensors or Domoticz connections. So;

May i get your suggestions on the protocol for the Arduino Mega+ Ethernet Shield to Raspberry Pi connection? Should i use direct JSON calls from arduino to domoticz, or should i use MQTT or anything else? Which would be the more efficient way? As i understand from mysensors, it is mainly for wireless sensors. What would be the way to go for wired sensors?

freijn
Posts: 387
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

Re: Opinions on Arduino based cable connection

Post by freijn » Saturday 14 October 2017 19:28

EASY ESP ?

Exactly as you wanted only not an ethernetshield but Wifi instead and no programming skills required.

I have several ones and one with 4 sensors connected to my domotics.

https://www.letscontrolit.com/

febalci
Posts: 339
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Opinions on Arduino based cable connection

Post by febalci » Sunday 15 October 2017 13:11

freijn wrote:
Saturday 14 October 2017 19:28
EASY ESP ?

Exactly as you wanted only not an ethernetshield but Wifi instead and no programming skills required.

I have several ones and one with 4 sensors connected to my domotics.

https://www.letscontrolit.com/
Thanks frejin,

i checked it out; looks great. However, any wireless protocol is not wanted specifically. The cables for the sensors in the house are already laid out and it is specifically wanted that these cables are to be used. As i understand from Easy ESP it is wifi connected with ESP8266. So, unfortunately it won't be of use for me in this project, but it is great for my own usage in other projects, i will try it. Thanks again...

freijn
Posts: 387
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

Re: Opinions on Arduino based cable connection

Post by freijn » Monday 16 October 2017 10:39

aha,

understand your goal..

Perhaps.. as the sources are available you can use that to rewrite from wifi to serial communication ?

User avatar
bbqkees
Posts: 512
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 3.8x
Location: The Netherlands
Contact:

Re: Opinions on Arduino based cable connection

Post by bbqkees » Monday 16 October 2017 11:25

I have several Arduino's with Ethernet connected to Domoticz.
One reads my electricity meter, one my boiler, one another controller and there are 3 others used for sensors/actuators.

All of them work with JSON GET requests, but I am am going to reprogram one of them for MQTT to test the difference.
The problem I have with JSON is that although sending data from the Arduino to Domoticz works fine every time, sending a command back to the Arduino from Domoticz is not fail safe in my case.

In my opinion MQTT is not really superior to JSON.
MQTT does have more overhead than a simple GET request with JSON.
The major benefit of MQTT is that it is not specific to Domoticz.
So if you create a MQTT device it can interact with many systems, whereas the JSON type is fixed to Domoticz.

My advice would also be to stick with the Wiznet ethernet shields, these have the best compatibility with Arduino.
Intel NUC-> Philips Hue, Aeon Zwave stick V2, Qubino, Fibaro, Everspring, Philio, RFXCom, X10, Harmony Hub, Xiaomi Flora + Gateway, BS440. And P1 / Resol VBus / Nefit EMS bus / DHT21 / DS18B20 / Sonoff / I2C display, all via Arduino/ESP8266.

febalci
Posts: 339
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Opinions on Arduino based cable connection

Post by febalci » Monday 30 October 2017 19:16

bbqkees wrote:
Monday 16 October 2017 11:25
I have several Arduino's with Ethernet connected to Domoticz.
One reads my electricity meter, one my boiler, one another controller and there are 3 others used for sensors/actuators.

All of them work with JSON GET requests, but I am am going to reprogram one of them for MQTT to test the difference.
The problem I have with JSON is that although sending data from the Arduino to Domoticz works fine every time, sending a command back to the Arduino from Domoticz is not fail safe in my case.

In my opinion MQTT is not really superior to JSON.
MQTT does have more overhead than a simple GET request with JSON.
The major benefit of MQTT is that it is not specific to Domoticz.
So if you create a MQTT device it can interact with many systems, whereas the JSON type is fixed to Domoticz.

My advice would also be to stick with the Wiznet ethernet shields, these have the best compatibility with Arduino.
Hi bbqkees, is it possible if you can send sample arduino sketches with the JSON calls? Thanks...

User avatar
bbqkees
Posts: 512
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 3.8x
Location: The Netherlands
Contact:

Re: Opinions on Arduino based cable connection

Post by bbqkees » Wednesday 01 November 2017 10:38

febalci wrote:
Monday 30 October 2017 19:16
Hi bbqkees, is it possible if you can send sample arduino sketches with the JSON calls? Thanks...
See my Github page.
Intel NUC-> Philips Hue, Aeon Zwave stick V2, Qubino, Fibaro, Everspring, Philio, RFXCom, X10, Harmony Hub, Xiaomi Flora + Gateway, BS440. And P1 / Resol VBus / Nefit EMS bus / DHT21 / DS18B20 / Sonoff / I2C display, all via Arduino/ESP8266.

ILoveIOT
Posts: 2
Joined: Sunday 25 March 2018 17:47
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Opinions on Arduino based cable connection

Post by ILoveIOT » Sunday 25 March 2018 18:01

There is a plugin available for the Nodo-Mega V3.7, with nodo shield and Ethernet shield, I use it for many years.

http://www.nodo-domotica.nl/forum/viewt ... 120#p15109

The forum is dutch, not sure how google translate will solve it, and they stopped working on it.

febalci
Posts: 339
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Opinions on Arduino based cable connection

Post by febalci » Sunday 25 March 2018 21:46

In the end i managed to do it. Connected a total of 24 reed and PIR sensors to an arduino mega. The arduino reads on/off status of the sensors with GPIO ports and sends to domoticz with json calls. Since some of the sensor cables are long, the they required an optocoupler before connecting to the GPIO ports; because of the length related noise on the cables. The sensors were sending nanosecond on/off signals before the optocouplers.

For the lights, another arduino mega is used (a total of 20 lights, cable connection again). This time i used mysensors, stripping out the wireless parts in the .ino. Works perfectly so far. Anyone needing the .ino files and details, just ask for it...

Jan Jansen
Posts: 166
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Opinions on Arduino based cable connection

Post by Jan Jansen » Monday 24 September 2018 15:28

febalci wrote:
Sunday 25 March 2018 21:46
Works perfectly so far. Anyone needing the .ino files and details, just ask for it...
Hello febalci,

I'am interested and need some help. I want to start simple. What do I want to achieve first?

Code: Select all

doorcontact  >>>>>>                                
                      <---> Arduino nano <-> ethernet (ENC28J60) <-----------------------> Domoticz
relay        <<<<<<
I'am interested in your ino (s). What else is necessary on the side of Domoticz?


Thanks in advance.

Jan

febalci
Posts: 339
Joined: Monday 03 July 2017 19:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Opinions on Arduino based cable connection

Post by febalci » Tuesday 25 September 2018 9:02

Jan Jansen wrote:
Monday 24 September 2018 15:28
febalci wrote:
Sunday 25 March 2018 21:46
Works perfectly so far. Anyone needing the .ino files and details, just ask for it...
Hello febalci,

I'am interested and need some help. I want to start simple. What do I want to achieve first?

Code: Select all

doorcontact  >>>>>>                                
                      <---> Arduino nano <-> ethernet (ENC28J60) <-----------------------> Domoticz
relay        <<<<<<
I'am interested in your ino (s). What else is necessary on the side of Domoticz?


Thanks in advance.

Jan
Hello Jen,

First you need to make hardware connection of doorcontacts to arduino. Prefer digital pins and don't forget to put resistors. You can find info on this on the internet.
Then you have to create Dummy Switch devices in Domoticz, one per doorcontact.

On Arduino i used this .ino (For 24 door contacts and PIR sensors):

Code: Select all

// ALARM DOMOTICZ Connection
// 09.11.2017, v4.0

// SPI and Ethernet is needed for Ethernet shield

#include <SPI.h>
#include <Ethernet.h>

//DEBUG 1 Sends output to SerialPort

#define DEBUG                   1
#define OPEN                    1     // HIGH
#define CLOSED                  0     // LOW
#define UNKNOWN                 2     // --- reset / force update

//INPUT PIN Numbers on Arduino
#define PIN_MUTFAK_SU               4
#define PIN_EBEVEYN_BANYO_SU        6
#define PIN_BANYO_SU                8
#define PIN_PANO_ISI_DUMAN          10
#define PIN_OTURMA_PEN_MK           12
#define PIN_SALON_KPEN_MK           14
#define PIN_SALON_BPEN_1_MK         16
#define PIN_SALON_BPEN_2_MK         18
#define PIN_BALKON_PEN_1_MK         20
#define PIN_BALKON_PEN_2_MK         22
#define PIN_MUTFAK_PEN_MK           24
#define PIN_EBEVEYN_PEN_A_MK        26
#define PIN_EBEVEYN_PEN_G_MK        28
#define PIN_COCUK_MK                30
#define PIN_GIRISKAPI_MK            32
#define PIN_OTURMA_PIR              34
#define PIN_SALON_PIR               36
#define PIN_BALKON_PIR              38
#define PIN_MUTFAK_PIR              40
#define PIN_EBEVEYN_PIR             42
#define PIN_EBEVEYN_BANYO_PIR       44
#define PIN_COCUK_PIR               46
#define PIN_KORIDOR_PIR             48
#define PIN_BUYUK_BANYO_PIR         50

// Last Statuıs of the Sensors
int MUTFAK_SUStatus	=               UNKNOWN;
int EBEVEYN_BANYO_SUStatus =        UNKNOWN;
int BANYO_SUStatus =                UNKNOWN;
int PANO_ISI_DUMANStatus =          UNKNOWN;
int OTURMA_PEN_MKStatus =           UNKNOWN;
int SALON_KPEN_MKStatus =           UNKNOWN;
int SALON_BPEN_1_MKStatus =         UNKNOWN;
int SALON_BPEN_2_MKStatus =         UNKNOWN;
int BALKON_PEN_1_MKStatus =         UNKNOWN;
int BALKON_PEN_2_MKStatus =         UNKNOWN;
int MUTFAK_PEN_MKStatus =           UNKNOWN;
int EBEVEYN_PEN_A_MKStatus =        UNKNOWN;
int EBEVEYN_PEN_G_MKStatus =        UNKNOWN;
int COCUK_MKStatus =                UNKNOWN;
int GIRISKAPI_MKStatus =            UNKNOWN;
int OTURMA_PIRStatus =              UNKNOWN;
int SALON_PIRStatus =               UNKNOWN;
int BALKON_PIRStatus =              UNKNOWN;
int MUTFAK_PIRStatus =              UNKNOWN;
int EBEVEYN_PIRStatus =             UNKNOWN;
int EBEVEYN_BANYO_PIRStatus =       UNKNOWN;
int COCUK_PIRStatus =               UNKNOWN;
int KORIDOR_PIRStatus =             UNKNOWN;
int BUYUK_BANYO_PIRStatus =         UNKNOWN;

// IDX numbers of PIR and Magnetc Contacts on Domoticz-Devices Page

int IDX_MUTFAK_SU =             31;
int IDX_EBEVEYN_BANYO_SU =      30;
int IDX_BANYO_SU =              29;
int IDX_PANO_ISI_DUMAN =        32;
int IDX_OTURMA_PEN_MK =         6;
int IDX_SALON_KPEN_MK =         7;
int IDX_SALON_BPEN_1_MK =       8;
int IDX_SALON_BPEN_2_MK =       9;
int IDX_BALKON_PEN_1_MK =       11;
int IDX_BALKON_PEN_2_MK =       10;
int IDX_MUTFAK_PEN_MK =         12;
int IDX_EBEVEYN_PEN_A_MK =      13;
int IDX_EBEVEYN_PEN_G_MK =      14;
int IDX_COCUK_MK =              15;
int IDX_GIRISKAPI_MK =          16;
int IDX_OTURMA_PIR =            17;
int IDX_SALON_PIR =             18;
int IDX_BALKON_PIR =            25;
int IDX_MUTFAK_PIR =            22;
int IDX_EBEVEYN_PIR =           23;
int IDX_EBEVEYN_BANYO_PIR =     21;
int IDX_COCUK_PIR =             24;
int IDX_KORIDOR_PIR =           19;
int IDX_BUYUK_BANYO_PIR =       20;
  
// Arduino MAC ve IP addresses

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0x30, 0x39, 0x01};//Random address
IPAddress ip(192,168,31,40); //IP Address of Arduino

IPAddress domoticz(192,168,31,20); // Domoticz IP Address
int port = 8080; // Domoticz Port No
EthernetClient client;


//httprequest functions, sends status info to Domoticz

// /json.htm?type=command&param=switchlight&idx=XX&switchcmd=On
void httpRequestswitch(int IDX, String status) {
  // When the connection is successful:
  if (client.connect(domoticz, port)) {
#if DEBUG  
    Serial.print("GET /json.htm?type=command&param=switchlight&idx=");
    Serial.print(IDX);
    Serial.print("&switchcmd=");
    Serial.println(status);
#endif 
    client.print( "GET /json.htm?type=command&param=switchlight&idx=");
    client.print(IDX);
    client.print("&switchcmd=");
    client.print(status);
    client.println( " HTTP/1.1");
    client.print( "Host: ");
    client.println(ip);
    client.println( "Connection: close");
    client.println();

    client.println();
    client.stop();
    delay(150);
  } 
  else {
    client.stop();
  }
}

void httpRequestvalue(int IDX, float value) {
  if (client.connect(domoticz, port)) {
  // When the connection is successful:
#if DEBUG  
    Serial.print("GET /json.htm?type=command&param=udevice&idx=");
    Serial.print(IDX);
    Serial.print("&nvalue=0&svalue=");
    Serial.println(value,1);
#endif 
    client.print( "GET /json.htm?type=command&param=udevice&idx=");
    client.print(IDX);
    client.print("&nvalue=0&svalue=");
    client.print(value,1);
    client.println( " HTTP/1.1");
    client.print( "Host: ");
    client.println(ip);
    client.println( "Connection: close");
    client.println();

    client.println();
    client.stop();
    delay(150);
  } 
  else {
    client.stop();
  }
}

int contactState(int pin)
{
  // LOW  -> CLOSED
  // HIGH -> OPEN
  return (digitalRead(pin) == HIGH)?OPEN:CLOSED;
}

void updateContactStatus()
{
  int currentStatus;
  const char* msg = NULL;

  currentStatus = contactState(PIN_MUTFAK_SU);
  if (MUTFAK_SUStatus != currentStatus)
  {
    MUTFAK_SUStatus = currentStatus;
    if(MUTFAK_SUStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_MUTFAK_SU, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_EBEVEYN_BANYO_SU);
  if (EBEVEYN_BANYO_SUStatus != currentStatus)
  {
    EBEVEYN_BANYO_SUStatus = currentStatus;
    if(EBEVEYN_BANYO_SUStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_EBEVEYN_BANYO_SU, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_BANYO_SU);
  if (BANYO_SUStatus != currentStatus)
  {
    BANYO_SUStatus = currentStatus;
    if(BANYO_SUStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_BANYO_SU, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_PANO_ISI_DUMAN);
  if (PANO_ISI_DUMANStatus != currentStatus)
  {
    PANO_ISI_DUMANStatus = currentStatus;
    if(PANO_ISI_DUMANStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_PANO_ISI_DUMAN, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_OTURMA_PEN_MK);
  if (OTURMA_PEN_MKStatus != currentStatus)
  {
    OTURMA_PEN_MKStatus = currentStatus;
    if(OTURMA_PEN_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_OTURMA_PEN_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_SALON_KPEN_MK);
  if (SALON_KPEN_MKStatus != currentStatus)
  {
    SALON_KPEN_MKStatus = currentStatus;
    if(SALON_KPEN_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_SALON_KPEN_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_SALON_BPEN_1_MK);
  if (SALON_BPEN_1_MKStatus != currentStatus)
  {
    SALON_BPEN_1_MKStatus = currentStatus;
    if(SALON_BPEN_1_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_SALON_BPEN_1_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_SALON_BPEN_2_MK);
  if (SALON_BPEN_2_MKStatus != currentStatus)
  {
    SALON_BPEN_2_MKStatus = currentStatus;
    if(SALON_BPEN_2_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_SALON_BPEN_2_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_BALKON_PEN_1_MK);
  if (BALKON_PEN_1_MKStatus != currentStatus)
  {
    BALKON_PEN_1_MKStatus = currentStatus;
    if(BALKON_PEN_1_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_BALKON_PEN_1_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_BALKON_PEN_2_MK);
  if (BALKON_PEN_2_MKStatus != currentStatus)
  {
    BALKON_PEN_2_MKStatus = currentStatus;
    if(BALKON_PEN_2_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_BALKON_PEN_2_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_MUTFAK_PEN_MK);
  if (MUTFAK_PEN_MKStatus != currentStatus)
  {
    MUTFAK_PEN_MKStatus = currentStatus;
    if(MUTFAK_PEN_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_MUTFAK_PEN_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_EBEVEYN_PEN_A_MK);
  if (EBEVEYN_PEN_A_MKStatus != currentStatus)
  {
    EBEVEYN_PEN_A_MKStatus = currentStatus;
    if(EBEVEYN_PEN_A_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_EBEVEYN_PEN_A_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_EBEVEYN_PEN_G_MK);
  if (EBEVEYN_PEN_G_MKStatus != currentStatus)
  {
    EBEVEYN_PEN_G_MKStatus = currentStatus;
    if(EBEVEYN_PEN_G_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_EBEVEYN_PEN_G_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_COCUK_MK);
  if (COCUK_MKStatus != currentStatus)
  {
    COCUK_MKStatus = currentStatus;
    if(COCUK_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_COCUK_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_GIRISKAPI_MK);
  if (GIRISKAPI_MKStatus != currentStatus)
  {
    GIRISKAPI_MKStatus = currentStatus;
    if(GIRISKAPI_MKStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_GIRISKAPI_MK, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_OTURMA_PIR);
  if (OTURMA_PIRStatus != currentStatus)
  {
    OTURMA_PIRStatus = currentStatus;
    if(OTURMA_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_OTURMA_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_SALON_PIR);
  if (SALON_PIRStatus != currentStatus)
  {
    SALON_PIRStatus = currentStatus;
    if(SALON_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_SALON_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_BALKON_PIR);
  if (BALKON_PIRStatus != currentStatus)
  {
    BALKON_PIRStatus = currentStatus;
    if(BALKON_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_BALKON_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_MUTFAK_PIR);
  if (MUTFAK_PIRStatus != currentStatus)
  {
    MUTFAK_PIRStatus = currentStatus;
    if(MUTFAK_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_MUTFAK_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_EBEVEYN_PIR);
  if (EBEVEYN_PIRStatus != currentStatus)
  {
    EBEVEYN_PIRStatus = currentStatus;
    if(EBEVEYN_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_EBEVEYN_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_EBEVEYN_BANYO_PIR);
  if (EBEVEYN_BANYO_PIRStatus != currentStatus)
  {
    EBEVEYN_BANYO_PIRStatus = currentStatus;
    if(EBEVEYN_BANYO_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_EBEVEYN_BANYO_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_COCUK_PIR);
  if (COCUK_PIRStatus != currentStatus)
  {
    COCUK_PIRStatus = currentStatus;
    if(COCUK_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_COCUK_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_KORIDOR_PIR);
  if (KORIDOR_PIRStatus != currentStatus)
  {
    KORIDOR_PIRStatus = currentStatus;
    if(KORIDOR_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_KORIDOR_PIR, msg);
    return; // only one message per loop
  }

  currentStatus = contactState(PIN_BUYUK_BANYO_PIR);
  if (BUYUK_BANYO_PIRStatus != currentStatus)
  {
    BUYUK_BANYO_PIRStatus = currentStatus;
    if(BUYUK_BANYO_PIRStatus == CLOSED) msg = "Off";
    else                     msg = "On";
    httpRequestswitch(IDX_BUYUK_BANYO_PIR, msg);
    return; // only one message per loop
  }

}


void setup() {
  pinMode(PIN_MUTFAK_SU , INPUT);
  pinMode(PIN_EBEVEYN_BANYO_SU , INPUT);
  pinMode(PIN_BANYO_SU , INPUT);
  pinMode(PIN_PANO_ISI_DUMAN , INPUT);
  pinMode(PIN_OTURMA_PEN_MK , INPUT);
  pinMode(PIN_SALON_KPEN_MK , INPUT);
  pinMode(PIN_SALON_BPEN_1_MK , INPUT);
  pinMode(PIN_SALON_BPEN_2_MK , INPUT);
  pinMode(PIN_BALKON_PEN_1_MK , INPUT);
  pinMode(PIN_BALKON_PEN_2_MK , INPUT);
  pinMode(PIN_MUTFAK_PEN_MK , INPUT);
  pinMode(PIN_EBEVEYN_PEN_A_MK , INPUT);
  pinMode(PIN_EBEVEYN_PEN_G_MK , INPUT);
  pinMode(PIN_COCUK_MK , INPUT);
  pinMode(PIN_GIRISKAPI_MK , INPUT);
  pinMode(PIN_OTURMA_PIR , INPUT);
  pinMode(PIN_SALON_PIR , INPUT);
  pinMode(PIN_BALKON_PIR , INPUT);
  pinMode(PIN_MUTFAK_PIR , INPUT);
  pinMode(PIN_EBEVEYN_PIR , INPUT);
  pinMode(PIN_EBEVEYN_BANYO_PIR , INPUT);
  pinMode(PIN_COCUK_PIR , INPUT);
  pinMode(PIN_KORIDOR_PIR , INPUT);
  pinMode(PIN_BUYUK_BANYO_PIR , INPUT);  
  
#if DEBUG  
  Serial.begin(9600);
  Serial.println("Arduino Alarm - Domoticz Connection");
#endif 

  Ethernet.begin(mac, ip);

#if DEBUG
  Serial.print("Arduino IP addresss: ");
  delay(1000);
  Serial.println(ip);
#endif  

}


void loop()
{
  updateContactStatus();
}


Of course, this .ino assumes all the sensor connections are of wired type. There's no wireless connections in this .ino.

Btw i didn't get the usage of relay in your assumption. Door contacts are only one side status devices. And this .ino is working like a Security Alarm. The status is sent only one way to Domoticz. Good Luck.

ben53252642
Posts: 504
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Opinions on Arduino based cable connection

Post by ben53252642 » Tuesday 25 September 2018 9:04

You don't need an arduino for reed switches, it can be done very easily with just a Raspberry Pi.

See: viewtopic.php?f=65&t=24991&p=192239#p192239

I've got a Pi 3 B+ which only monitors a reed switch working very nicely.

Jan Jansen
Posts: 166
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Opinions on Arduino based cable connection

Post by Jan Jansen » Tuesday 25 September 2018 19:37

Thanks for the answers.

@febalci: I will try. At the moment I do not need it immediately because I use a few pifaces. I just want to learn how to connect an arduino with connected sensors and actuators via Ethernet to Domoticz. I think I'am a step further.

Jan

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests