Go Down

Topic: Integration with ethernet based Crestron home Automation processor (Read 11051 times) previous topic - next topic

zoomkat

Quote
This seem like it should be pretty simple where do I start?


Sounds complex to me if you are wanting to operate the arduino in both client and server modes.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

SIATRON

I know its been a few years since anyone posted anything here, but I have the solution to this problem. If anyone is interested let me know and i will reply

johann_m

I have MEGA2560 + Ethernet Shield + 8 Relay Module and QM-RMC. Arduino is the server and CRESTRON is client.
You need a module "arduino.umc" (for example) to send strings (commands to activate the relay) and  receive the state of each Relay.


Code: [Select]

/*
  Creado por Johann Miranda
  + Arduino MEGA2560
  + Ethernet Shield
  + 8 Relay
 */

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

int pin[]       = { 22, 23, 24, 25, 26, 27, 28, 29 };
int i           = 0;
byte mac[]      = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[]       = { 192, 168, 7, 11 };
byte gateway[]  = { 192, 168, 7, 2 };
byte subnet[]   = { 255, 255, 255, 0 };
String readString;
String powerOn;
String powerOff;
EthernetServer server(41799);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  for( i = 0; i < 8; i++) {
    pinMode(pin[i], OUTPUT);
  }
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.println(Ethernet.localIP());
}


void loop()
{
  EthernetClient client = server.available();
  if (client)
  {
    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();
        //read char by char HTTP request
        if (readString.length() < 20)
        {
          //store characters to string
          if (c != '\n') {
            readString += c;
          }
        }
        // http finalizado
        if (c == '\n') {
          // se presionó algún botón, escanea todas las posibilidades
          for( i = 0; i < 8; i++) {
            powerOn      = "pin"+String(pin[i])+"On";
            powerOff     = "pin"+String(pin[i])+"Off";
            if (readString == powerOn) {
              Serial.println("<CRESTRON COMMAND REQUEST pin" + String(pin[i]) + " HIGH>"); //para debuging
              digitalWrite(pin[i], HIGH);
            }
            if (readString==powerOff) {
              Serial.println("<CRESTRON COMMAND REQUEST pin" + String(pin[i]) + " LOW>"); //para debuging
              digitalWrite(pin[i], LOW);
            }
          }
         // actualiza todos los botones
         Serial.println("  <STATUS SEND TO CRESTRON>");
         for( i = 0; i < 8; i++) {
            if (digitalRead(pin[i]) == HIGH ) {
              client.println("pin"+String(pin[i])+"OnFb");
              Serial.println("    <pin"+String(pin[i])+"OnFb>");
            }
            else {
              client.println("pin"+String(pin[i])+"OffFb");
              Serial.println("    <pin"+String(pin[i])+"OffFb>");
           }
          }
          Serial.println("  </STATUS>");
          readString="";
          delay(1);
          client.stop();
          Serial.println("</CRESTRON COMMAND>");
        }
      }
    }
  }
}



Everything works fine, but sometimes you must push 2-3 times a button. (I NEED HELP FOR THIS).

Attached is a very elemental Usrmacro and Simpl. You must to delete the TXT extension.


Johann.


johann_m

SIATRON, I would like to know how you solved.


Attached a screenshot XPanel example. Johann.




emosbek

I know its been a few years since anyone posted anything here, but I have the solution to this problem. If anyone is interested let me know and i will reply
Hello Siatron!

If you are willing to share the world would be a better place and the-internet-of-things would be our slaves :D

/e

jancio

Maybe new project with Crestron and ESP8266 (like NodeMCU) 8 Relay?
HELP! :)

Go Up