Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 2 of 2   [ 12 posts ]
Go to page Previous  1, 2
Author Message
 Post subject: Re: Código "getActuators" Opengarden
PostPosted: Tue Jan 23, 2018 1:25 pm 

Joined: Tue Feb 07, 2017 1:37 pm
Posts: 37
Hola he probado sólo este código y sigue sin funcionar:

$$$set dns name 34.251.228.1
set ip adress 0
set i r 80
set com remote 0
open
GET /get_actuators.php?actuators
Received:HTTP/1.1 400 Bad Request
Date: Tue, 23 Jan 2018 12:13:38 GMT

Irrigation 1 ON
Irrigation 2 BAD DATA
Irrigation 3 ON



Adjunto os envío el mismo para que podáis comprobar qué está fallando:

#include <OpenGarden.h>
#include "Wire.h"

//Enter here your data
const char server[] = "34.251.228.1";
const char server_port[] = "80";
const char wifi_ssid[] = "ONOE1E6";
const char wifi_password[] = "4414131084";

char recv[512];
int cont;

char irrigation1_wf;
char irrigation2_wf;
char irrigation3_wf;

void setup() {
Serial.begin(9600);
OpenGarden.initIrrigation(1); //Initialize irrigation number 1
OpenGarden.initIrrigation(2); //Initialize irrigation number 2
OpenGarden.initIrrigation(3); //Initialize irrigation number 3
OpenGarden.irrigationOFF(1);
OpenGarden.irrigationOFF(2);
OpenGarden.irrigationOFF(3);
cleanVector();
wificonfig();
}


void loop() {
getActuators();

Serial.println();
if (irrigation1_wf == '0'){
OpenGarden.irrigationOFF(1); //Turn OFF the irrigation number 1
Serial.println("Irrigation 1 OFF");
}
else if (irrigation1_wf == '1'){
OpenGarden.irrigationON(1); //Turn ON the irrigation number 1
Serial.println("Irrigation 1 ON");
}
else{
Serial.println("Irrigation 1 BAD DATA");
}


if (irrigation2_wf == '0'){
OpenGarden.irrigationOFF(2); //Turn OFF the irrigation number 2
Serial.println("Irrigation 2 OFF");
}
else if (irrigation2_wf == '1'){
OpenGarden.irrigationON(2); //Turn ON the irrigation number 2
Serial.println("Irrigation 2 ON");
}
else{
Serial.println("Irrigation 2 BAD DATA");
}


if (irrigation3_wf == '0'){
OpenGarden.irrigationOFF(3); //Turn OFF the irrigation number 3
Serial.println("Irrigation 3 OFF");
}
else if (irrigation3_wf == '1'){
OpenGarden.irrigationON(3); //Turn ON the irrigation number 3
Serial.println("Irrigation 3 ON");
}
else{
Serial.println("Irrigation 3 BAD DATA");
}

cleanVector();
enterCMD();

delay(5000);
}


//*********************************************************************
//*********************************************************************


void cleanVector(){
recv[5] = 0;
recv[6] = 0;
recv[7] = 0;
}


void wificonfig() {
while (Serial.available() > 0) {
}

enterCMD();
// Sets DHCP and TCP protocol
Serial.print(F("set ip dhcp 1\r"));
check();
Serial.print(F("set ip protocol 18\r"));
check();

// Configures the way to join the network AP, sets the encryption of the
// network and joins it
Serial.print(F("set wlan join 0\r")); //The auto-join feature is disabled
check();
Serial.print(F("set wlan phrase "));
Serial.print(wifi_password);
Serial.print(F("\r"));
check();
Serial.print(F("join "));
Serial.print(wifi_ssid);
Serial.print(F("\r"));
check();
}

void getActuators(){

//Configures HTTP connection
Serial.print(F("set dns name "));
Serial.print(server);
Serial.print(F("\r"));
check();

Serial.print("set ip adress 0\r");
check();

Serial.print(F("set i r "));
Serial.print(server_port);
Serial.print(F("\r"));

check();
Serial.print("set com remote 0\r");
check();
Serial.print("open\r");
check();
Serial.flush();
Serial.print("GET /get_actuators.php?actuators\r");
checkData();


}

void enterCMD() {
Serial.println("");
// Enters in command mode
Serial.print(F("$$$"));
delay(100);
check();
Serial.flush();
}


void check(){
delay(1500);
autoflush();
}


void checkData(){
cont=0;
delay(3000);
while (Serial.available()>0)
{
recv[cont]=Serial.read();
delay(10);
cont++;
}
recv[cont]='\0';

irrigation1_wf= recv[5];
irrigation2_wf= recv[6];
irrigation3_wf= recv[7];

Serial.print("Received:");
Serial.print(recv);

autoflush();
delay(100);
}


void autoflush()
{
while (Serial.available()>0)
{
Serial.read();
}
}


Top
 Profile  
 
 Post subject: Re: Código "getActuators" Opengarden
PostPosted: Wed Jan 24, 2018 8:52 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hola Maria43,

nosotros hemos comprobado varias veces que el código funciona correctamente por lo que desconocemos la razón por la cual no está funcionando en ese servidor en concreto.

¿Podrías probar con otro servidor?

Un saludo


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 2 of 2   [ 12 posts ]
Go to page Previous  1, 2


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.