Arduino Forum

Using Arduino => Project Guidance => Topic started by: davides98 on Feb 09, 2017, 09:44 pm

Title: Arduino + Ethernet shield send GET data to a motor
Post by: davides98 on Feb 09, 2017, 09:44 pm
Hello, I wanted to ask how I could get from a url address of the variables which then went to set the operation of a stepper motor.

I followed guide link: http://idledev.com/2015/04/http-get-parameters-with-arduino-part-1/

In a few words I should get from url (es. 190.168.1.100?val1=10) the number 10 that Arduino will interpret this as a pause time for the start of the stepper

I have already created that generates me the url website lacks only communication through the ethernet shield and import of the variables into the delay ()
 
Stepper code
Code: [Select]

#include <Stepper.h>

const int passi_motore = 200; // cambia questo numero in base ai passi che compie il motore
 // che hai collegato

// inizializza la libreria con i pin utilizzati da Arduino:
Stepper motore(passi_motore,5,4,3,2);

void setup() {
 // imposta la velocit√† di rotazione a 60 giri al minuto:
 motore.setSpeed(60);
 // apre la porta seriale di comunicazione:
 Serial.begin(9600);
// attiva i motori:
 pinMode(10, OUTPUT);
 digitalWrite(10, HIGH);
 pinMode(9, OUTPUT);
 digitalWrite(9, HIGH);
}

void loop() {
 // compie un giro in una direzione:
 Serial.println("clockwise");
 motore.step(passi_motore);
 delay(500); // ritardo
 
 // compie un giro nella direzione opposta:
 Serial.println("counterclockwise");
 motore.step(-passi_motore);
 delay(500); // ritardo
}


Title: Re: Arduino + Ethernet shield send GET data to a motor
Post by: davidrh on Feb 10, 2017, 01:25 am
I think you are confusing URL query string parameters and the HTTP response body.  Query string parameters will be passed from the Arduino to your HTTP server.  Given that you want to get the answer 10 from the server, the Arduino can't include the answer in the query string.

You want a URL on your HTTP server that when you hit http://190.168.1.100 returns the value 10 in the body of the request.

The Arduino code then needs to issue a HTTP get, and parse the response that comes back to extract the value you want from the body.
Title: Re: Arduino + Ethernet shield send GET data to a motor
Post by: PaulS on Feb 10, 2017, 01:48 am
If the Arduino is the server. what you want to do is easy. If the Arduino is a client, what you want to do is impossible.
Title: Re: Arduino + Ethernet shield send GET data to a motor
Post by: davidrh on Feb 10, 2017, 02:03 am
Quote
I have already created that generates me the url website
Sorry, I may have misunderstood what you say you have already generated. Do you want the website to call the Arduino or the Arduino to call the website?  Is the IP address 190.168.1.100 your Arduino?

Is this only going to be on your local network or ultimately do you want to control the Arduino from the internet?