Hola Kike_GL,
Muchas gracias por la respuesta y el código
Ya perdonarás, cierto es que no puse todo el código. Utilicé el único ejemplo que encontré por internet del grupo Industrial Shields.
He probado tu ejemplo y nada, me sale este error, y ya son cosas que se me escapan.
C:\Users\PC\Documents\Arduino\05 ftp\ejemplo_de_escritura_archivo_y_lectura_de_archivo\ejemplo_de_escritura_archivo_y_lectura_de_archivo.ino: In function 'void loop()':
ejemplo_de_escritura_archivo_y_lectura_de_archivo:67:51: error: no matching function for call to 'FTP::store(const char*&, char&, size_t)'
ftp.store(fileName, contenido, strlen(contenido));
^
In file included from C:\Users\PC\Documents\Arduino\05 ftp\ejemplo_de_escritura_archivo_y_lectura_de_archivo\ejemplo_de_escritura_archivo_y_lectura_de_archivo.ino:4:0:
C:\Users\PC\Documents\Arduino\libraries\arduino-FTP-master\src/FTP.h:38:10: note: candidate: size_t FTP::store(const char*, Stream&)
size_t store(const char *fileName, Stream &stream);
^~~~~
C:\Users\PC\Documents\Arduino\libraries\arduino-FTP-master\src/FTP.h:38:10: note: candidate expects 2 arguments, 3 provided
He intentado modificar las librerías por los tipos de datos Stream que espera la función y nada, tb soy valiente pensando q es eso.
Lo que quiero hacer exactamente es como el ejemplo que hay de datalogger, que es añadir filas, pero vía FTP, para guardar los datos en un servidor, pero creo que ya para mi poca experiencia se va un poco de las manos. Solo con poder escribir todos los datos en una línea y un archivo me valdría para empezar.
No quería depender de la SD y que fuera el Arduino más independiente, ya que si funciona quitaré de en medio unos cuantos Logos (16), que tenemos en la empresa ahora mismo, haciendo eso, capturando datos cada 20sg aprox, pero los guardan dentro.
Seguiremos probando hasta que dé con la tecla :-), y si veis algo que se pueda probar, lo intentaré tb.
Muchas gracias¡¡
Código Original:
// FTP library example
// by Industrial Shields
#include <FTP.h>
#include <Ethernet.h>
uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 0, 100);
IPAddress namesServer(192, 198, 0, 1);
IPAddress gateway(192, 168, 0, 1);
IPAddress netmask(255, 255, 255, 0);
IPAddress server(192, 168, 0, 18);
const char *user = "FTP";
const char *pass = "FTP";
const char *fileName = "IMV 100.txt";
char contenido = "Lo que tu quieras...";
EthernetClient ftpControl;
EthernetClient ftpData;
FTP ftp(ftpControl, ftpData);
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(57600);
Ethernet.begin(mac, ip, namesServer, gateway, netmask);
Serial.print("IP address: ");
Serial.println(Ethernet.localIP());
if (!ftp.connect(server, user, pass)) {
Serial.println("Error connecting to FTP server");
while (true);
}
delay(100);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
String dataString = "";
// read three sensors and append to the string:
for (int analogPin = 0; analogPin < 6; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 6) {
dataString += ";";
}
}
//Intrucciones para escribir en el FTP SERVER
Serial.println("You have 10 seconds to write something...");
delay(1000UL);
// Send the written content to the FTP file
//ftp.store(fileName, Serial); // >>>>>>>>>> ORIGINAL, Q escribo en la consola y lo guarda en el archivo con la instrucción
ftp.store(fileName, contenido, strlen(contenido));
Serial.println("The written content is sent to the FTP file");
delay(1000UL);
// Print FTP file content to Serial
Serial.println("FTP file content: ");
Serial.println(fileName);
//size_t len = ftp.retrieve(fileName, Serial);
size_t len = ftp.retrieve(fileName, Serial);
Serial.println();
Serial.print("FTP file size: ");
Serial.println(len);
delay(10000UL);
//************************************************** END PROGRAM ***********************************
}