I have been working with arduino for some time but not i am stuck in a problem.
In a project that i am developing i want to send http stings to control a position of a speed dome camera using push buttons.
If i send the correct string in a browser it work ok and replay to me the actual position.
Thanks for the answer, is that the only chance?
I was expecting a simple solution, send the string and that's it.
Can you point me a direction to follow.
here what i could do until now
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x35, 0x6C }; // define mac
EthernetServer server = EthernetServer(80); // define server port
void setup(){
Serial.begin(9600); // activat serial port
pinMode(2, OUTPUT); // LED indicator for camera ON
pinMode(3, OUTPUT); // LED indicator for position 1
pinMode(4, OUTPUT); // LED indicator for position 2
pinMode(5, OUTPUT); // LED indicator for position 3
pinMode(6, OUTPUT); // LED indicator for position 4
pinMode(14, INPUT); // Push button for camera ON
pinMode(15, INPUT); // Push button for position 1
pinMode(16, INPUT); // Push button for position 2
pinMode(17, INPUT); // Push button for position 3
pinMode(18, INPUT); // Push button for position 4
Ethernet.begin(mac); // register mac with DHCP
server.begin(); //start net server
Serial.println(Ethernet.localIP()); // print IP local
}
void loop(){
//test buttons
testCAM(14);
testinput(15);
testinput(16);
testinput(17);
testinput(18);
}
void testCAM(int pin){
//test input and activate output.
if (digitalRead(pin) == LOW){
digitalWrite (2, HIGH);} //activate LED
//http://192.168.1.100:8081/?L1=1 //Send string
else{
digitalWrite (2, LOW);}
//http://192.168.1.100:8081/?L1=0 //Send string
}
void testinput(int pin){
//test input and activate output.
if (digitalRead(pin) == LOW){
digitalWrite ((pin-12), HIGH);} //activate LED
//http://192.168.1.100:8085/Set?Func=PresetCntPos&Kind=1 //Send string
else{
digitalWrite ((pin-12), LOW);}
}
I don't understand your problem. It sounds as if the camera has some sort of web control interface and you can control it by sending it HTTP requests - is that right? If not, can you describe your setup in more detail?
Correct is an IP speed dome.
You can see the video using the web and contrl it send HTTP strings.
I have a 6 push buttons control, one to turn on and off the camera (using another arduino ethernet as server and data logger conected to the camera) and the other 5 are to send the camera to preset positions.
Using one explorer and send the strings directly is ok.
The only part that i have missing is the way to send that strings using the arduino.
Can you help? Or point me in a direction.
Thanks.
Timóteo
The only part that i have missing is the way to send that strings using the arduino.
So, the camera acts as a server, and you need the Arduino to act as a client. Load the Web Client example, change the server name/IP to that of the camera, and change the script to execute to whatever the script is running on the camera.
Is not that simple i have already trie to use the arduino as server and as client.
Change the code from the examples, but could not find a solution.
Can you provide me an example based on the code i wrote before? So i could test if that option work.
Thanks
//zoomkat 4-04-12
//simple client test
//for use with IDE 1.0
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// http://code.google.com/p/arduino/issues/detail?id=605
//the arduino lan IP address { 192, 168, 1, 102 } may need
//to be modified modified to work with your router.
#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 assigned to arduino
//byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
//byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address
EthernetClient client;
//////////////////////
void setup(){
Ethernet.begin(mac, ip);
//Ethernet.begin(mac, ip, gateway, gateway, subnet);
Serial.begin(9600);
Serial.println("Better client test 4/04/12"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
}
void loop(){
// check for serial input
if (Serial.available() > 0) //if something in serial buffer
{
byte inChar; // sets inChar as a byte
inChar = Serial.read(); //gets byte from buffer
if(inChar == 'e') // checks to see byte is an e
{
sendGET(); // call sendGET function below when byte is an e
}
}
}
//////////////////////////
void sendGET() //client function to send/receive GET request data.
{
if (client.connect(myserver, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text
client.println(); //end of get request
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
}
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================");
Serial.println();
client.stop(); //stop client
}