pai icon indicating copy to clipboard operation
pai copied to clipboard

Interface with Arduino Uno and W5100 from ESP32 telnet source code

Open proasnet opened this issue 4 years ago • 16 comments

Hi yozik04 Now I trying telnet interface with Arduino Uno and W5100 shield for EVOHD connection. Have you yourself working no wirelles project for direct ethernet connection, which I can not edit current settings in HA PAI? Now, I am using ESP connection, I thing that Arduino Ethernet may by very similar, but If I edit code for ESP, go out all wifi functions as next code:

#include <SPI.h>
#include <Ethernet.h>
#define MAX_SRV_CLIENTS 1
byte mac[] = { 0xF0, 0x08, 0xD1, 0xC5, 0xC7, 0x2C };
#define MAX_SRV_CLIENTS 1
EthernetServer server(23);
EthernetClient serverClients[MAX_SRV_CLIENTS];

void setup() {
  Serial.begin(57600);
  Ethernet.begin(mac);
  server.begin();
}

void loop() {
  uint8_t i;
  //  EthernetClient client = server.available();


  //check clients for data - funguje dobře
  for (i = 0; i < MAX_SRV_CLIENTS; i++) {
    //find free/disconnected spot
    if (!serverClients[i] || !serverClients[i].connected()) {
      if (serverClients[i]) serverClients[i].stop();
      serverClients[i] = server.available();
      break;
    }
  }
  for (i = 0; i < MAX_SRV_CLIENTS; i++) {
    if (serverClients[i] && serverClients[i].connected()) {
      if (serverClients[i].available()) {
        //get data from the telnet client and push it to the UART
        while (serverClients[i].available()) Serial.write(serverClients[i].read());
      }
    }
    else {
      if (serverClients[i]) {
        serverClients[i].stop();
      }
    }
  }

  //check UART for data
  if (Serial.available()) {
    size_t len = Serial.available();
    uint8_t sbuf[len];
    Serial.readBytes(sbuf, len);
    //push UART data to all connected telnet clients
    for (i = 0; i < MAX_SRV_CLIENTS; i++) {
      if (serverClients[i] && serverClients[i].connected()) {
        serverClients[i].write(sbuf, len);
        delay(1);
      }
    }
  } else {
    for (i = 0; i < MAX_SRV_CLIENTS; i++) {
      if (serverClients[i]) serverClients[i].stop();
    }
    delay(1000);
  }
}

Then no working. Data goes only one direct... Very Thanks

proasnet avatar Mar 02 '21 11:03 proasnet

Hi,

  1. https://www.markdownguide.org/extended-syntax#fenced-code-blocks
  2. What you are asking?

yozik04 avatar Mar 02 '21 11:03 yozik04

I am sorry for bad include code. My ask is, thay you have your own tested sketch for Arduino Uno with ethernet shield as replacement for ESP32. I have working ESP32 interface, but only for this I have one wifi AP. The better will be wired connection. I trying edit working ESP32 sketch for use with UNO. not working yet. So that I don't invent what may already exist. I tried other telnet servers for arduino, but none of them worked with PAI, probably some is special.

proasnet avatar Mar 02 '21 13:03 proasnet

Hmm, I do not remember if anybody tried to use it with Arduino. Are you sure baud rate matches setting in panel? It should not be any special.

yozik04 avatar Mar 02 '21 13:03 yozik04

Yes. I have 57600 Bauds, in panel and in the code. I found some another request here https://gitter.im/paradox-alarm-interface/community?at=5e5d1071376d882250c7be84 but your answer was link to ESP32 interface. Thank you.

montyx99 @montyx99 mar 02 2020 14:20 hello guys I'd like to ask 2 questions:

  1. my uncle can replace my EVO192 to any Spectra panel. I have a flat, with 10 sensors and 1 sirene. Is the spectra devices more reliable with the PAI? If yes, which spectra panel that you recommend to choose?
  2. is there any working solution for TTL to Ethernet devices? Such an arduino with a w5100 shield, or a ttl2lan modul? I'd like to avoid the usage of Wifi in case of communication. My flat is brand new, and I've requested a CAT6 cable to build in between my alarm box and my giganet switch.

_ Jevgeni Kiski @yozik04 mar 02 2020 14:56

I Use EVO and it is way better than any SP/MG
https://github.com/ParadoxAlarmInterface/pai/wiki/Connection-methods#serial-over-ip-esp32

proasnet avatar Mar 02 '21 13:03 proasnet

I had made this setup for two Paradox Alarm models (SP4000/5500 and EVO48). I use an arduino mega 2560 with Ethernet Shield. Then arduino serial port is directly connected to Alarm panels.

I can post implementation for anyone who needs/wants to interconnect Paradox Alarm with PAI over Ethernet wire.

295922916_639011177844919_7119595746886632874_n 297248787_442188497853836_6051159011051769049_n

dmylnka avatar Aug 25 '22 14:08 dmylnka

@dmylnka It is great! Please share! I had many requests for that.

PS: you can edit wiki and put you knowledge directly there.

Thank you!

yozik04 avatar Aug 25 '22 14:08 yozik04

@yozik04 i will collect all files (arduino code , STL 3D Print etc) and post to wiki. i am going to add some instructions as supports different serial baudrate (configurable throught Telnet CLI).

dmylnka avatar Aug 25 '22 14:08 dmylnka

@yozik04 , after trying to find some time to gather all staff you can find all required files and a sort description to the following repository. https://github.com/dmylnka/Paradox-Ethernet-USB-Interface

I am going to write a more detailed description and instructions how to use.

Regards, Dimitris.

dmylnka avatar Sep 16 '22 22:09 dmylnka

@dmylnka Really cool. Great work. Thank you for sharing!

yozik04 avatar Sep 17 '22 06:09 yozik04

wiki updated with ethernet usb interface to Paradox Control Panels. https://github.com/ParadoxAlarmInterface/pai/wiki/Connection-methods

dmylnka avatar Jan 07 '23 21:01 dmylnka

Wow. Great write up. Thank you!

yozik04 avatar Jan 07 '23 23:01 yozik04