I am trying to get an Arduino to be able to control the position of a security camera. I have a Vaddio ClearVIEW HD-19 camera (manual), Arduino Uno, and ethernet shield. The camera accepts VISCA commands through an RJ45 RS232 connector to change the camera position. I am trying to have the Arduino send these commands with the help of the ethernet shield. Currently I have the following code but the camera is not responding at all. The Tx LED on the ethernet shield blinks and I can receive data in the terminal window. I have not worked with the ethernet shield before and am not sure if I am setting it up correctly. The connection between the shield and the camera is an ethernet cable.
#include <SPI.h>
#include <Ethernet.h>
// MAC address for Arduino
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
// telnet defaults to port 23
EthernetClient client;
// Camera Commands
// Default message 8x 01 04 3F 02 0p FF where x is camera number and p is preset number
byte preset1[7] = {0x81, 0x01, 0x04, 0x3F, 0x02, 0x01, 0xFF}; // camera position 1 command
byte preset2[7] = {0x81, 0x01, 0x04, 0x3F, 0x02, 0x02, 0xFF}; // camera position 2 command
byte address_command[4] = {0x88, 0x30, 0x01, 0xFF}; // send camera address command
byte if_clear[5] = {0x88, 0x01, 0x00, 0x01, 0xFF}; // check if the serial is clear command
void setup()
{
Ethernet.begin(mac);
Serial.begin(9600); // Open the serial port at 9600 bps
while (!Serial)
{
; // wait for serial port to connect.
}
//Send Address command
for (int i = 0; i < 4; i++)
{
Serial.write(address_command[i]);
}
delay(500); //delay to allow camera time for next command
//Send IF_clear command
for (int i = 0; i < 5; i++)
{
Serial.write(if_clear[i]);
}
}
void loop()
{
for (int i = 0; i < (sizeof(preset1)); i++) // sizeof returns a count of bytes
{
Serial.write(preset1[i]); // moves to camera to position 1
}
delay(5000); // waits 5 seconds to send next command
for (int i = 0; i < (sizeof(preset2)); i++)
{
Serial.write(preset2[i]); // moves camera to position 2
}
delay(5000);
}
The camera's data settings are as follows:
Communication Speed: 9600 bps (default)
Start bit: 1
Stop bit: 1
Data bits: 8
Parity: None
No Flow control
Any help or suggestions would be very much appreciated. Thank you.