Integration with ethernet based Crestron home Automation processor

With out getting too technical on the Crestron side, I will tell you what I need.

Basically I have an Arduino D. and an Ethernet shield. I want to be able to send strings over Ethernet to the Arduino such as "g1o" which would translate to Garage 1 Open and trigger a relay. I also want do the opposite and use the Arduino as an input device for Crestron and send a string to Crestron such as "db1" for door bell pressed. Do you think this can be done easily? I have to tell you there are so many ways to do this but I think it would be fun to do it with Arduino.

I just need some guidance on sending and receiving string via the Ethernet shield and I am pretty confident that I can do the rest.

Thanks in advance

Scott Portocarrero

Have you got all the Crestron software?

Yes that is not the problem, I am a Crestron Programmer, are you looking for it?

I just need some guidance on sending and receiving string via the Ethernet shield and I am pretty confident that I can do the rest.

Well, most of what has been posted network wise is the arduino being used as a telnet application, email client, and as a seperate web server or web client. I'm not about code combining both web applications. What you posted indicates you may need both web applications combined. Seperate they are pretty simple.

If they are separate can you give me some guidance. Basically I use a module in Crestron called a Serial IO from where I can send any serial string to a serial port or a TCP/IP URL. So with that said I just need the Arduino to be listening for a certain string, whatever it is, and execute a function based on the string. ie. Crestron sends "g1o" Arduino enables relay on DO1. I hope I am being clear.

Thanks for you help.......any help is much appreciated

If you just need the arduino to receive serial input from the cerston and operate relays, that should be simple. What is being sent from the creston?

It would be a serial string over Ethernet

The problem I am having is setting up the Ethernet Shield to recognize the string coming from Crestron.

415porto: It would be a serial string over Ethernet

You've got a bit of a conceptual hurdle here. Serial is point-to-point communications -- the transmit line of device A connects to the receive line of device B, and vice versa, and they just send bytes to each other.

Ethernet is a network communication, where multiple devices share the same cable, and every communication has to specify which device on the network it is meant for. The Arduino Ethernet shield is hardwired to use the TCP/IP protocol, which allows each device to have multiple simultaneous conversations with other devices. Each device on the network is identified by a number called the IP address; each conversation is identified by a number called a port. To communicate with another device you have to specify the IP address and the port.

In each conversation one device is the server and one device is the client. All conversations are initiated by clients. The server opens a port and waits for a connection. The client connects, specifying the IP address of the server and the port number. Once the connection is created either side can send data and either side can close the connection.

In order to integrate with the Creston you need to know whether it wants to be a client or a server, and what port it expects to use. Often the port number can be configured. You also need to know the IP address of the arduino and the Creston.

Basically I use a module in Crestron called a Serial IO from where I can send any serial string to a serial port or a TCP/IP URL.

"TCP/IP URL" isn't the right term because URL isn't a TCP/IP concept, but this is probably where the answer lies. A URL can be an address/port pair. How is it asking for this URL?

Thank you for the information. I understand how Ethernet works. With that said say my Crestron Processor is operating as a Client. The IP Address is 192.168.1.19 port 71900. Once communication is open I will be sending bytes from Crestron using something called a symbol called Serial IO( I think this is where the confusion is) from that symbol I can send anything ASCII,HEX,etc. Where would I start on the Arduino side to take this information and make the Arduino do something(for lack of better words)? ]:D

:roll_eyes:

Then you set the arduino with an ethernet shield as a server. Below is some simple server code you can use to see what is sent to the arduino using the serial monitor.

//zoomkat 12-18-10
//routerbot code
//for use with IDE 0021
//open serial monitor to see what the arduino receives
// 

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port

String readString; 
 
 //////////////////////

void setup(){

//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();

//enable serial data print 
Serial.begin(9600); 
Serial.println("servertest1"); // so I can keep track of what is loaded
}

void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();

//read char by char HTTP request
if (readString.length() < 100) {

//store characters to string 
readString += c; 
Serial.print(c);
} 

//if HTTP request has ended
if (c == '\n') {

///////////////
Serial.println(readString);

  //now output HTML data header
  client.println("HTTP/1.1 204 Zoomkat");
  client.println();
  client.println();
  delay(1);
  //stopping client
client.stop();

/////////////////////
//clearing string for next read
readString="";
  
}}}}}

That’s an excellent start thank you

OK lets make this much simpler 8)

I want to send DI*3,DI*4,DI*5 as strings to Crestron for Digital Inputs 3,4,5. I also want to be able to send DO*7,DO*8,DO*9 as strings from Crestron for Digital Outputs 7,8,9.

In it's purest form I want to use the Arduino as an IO gateway for Crestron passing IOs through Arduino to/from Crestron via Ethernet. All of the programming will be handled in the Crestron Processor.

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

uh... port 71900??

max tcp/udp port is 65535 sure you are speaking tcp???

better stop smokin that shite :) (unless you a patient of course!!) gwen

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.

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

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.

/*
  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.

arduino.smw.txt (12.8 KB)

arduino.umc.txt (12.2 KB)

SIATRON, I would like to know how you solved.

Attached a screenshot XPanel example. Johann.

arduino_Xpanel_vtp.jpg

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

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