Hola, estoy haciendo un proyecto que consiste en publicar datos de un sensor de temperatura a ThingSpeak mediante un arduino uno con un modulo ENC28J60; Sin embargo, tengo un problema y es que thingspeak no detecta que están ingresando datos y eso que hice bien el canal y le agregue al código la APIkey, además estoy usando un ejemplo de la librería EtherCard para el proyecto, pero no se cual es el problema.
Si alguen sabe me explica por favor que debo hacer para que pueda complir con mi meta.
He trasladado su tema de una categoría de idioma inglés del foro a la categoría International > Español @arley125.
En adelante por favor usar la categoría apropiada a la lengua en que queráis publicar. Esto es importante para el uso responsable del foro, y esta explicado aquí la guía "How to get the best out of this forum".
Este guía contiene mucha información útil. Por favor leer.
De antemano, muchas gracias por cooperar.
Moderador:
Por favor, lee las Normas del foro
Si posteas en el foro en inglés usa idioma inglés para expresarte, eso incluye los comentarios de tu código. Si un código tiene comentarios en español también moverán tu hilo a esta sección en Español.
Si escribes en español debes usar el foro Arduino en español
No has publicado un código de modo que es imposible decir que has hecho mal sin ver el sketch.
hola, perdón por usar incorrectamente el foro, es que apenas soy nuevo y no sabia como funcionaba la plataforma.
Sinceramente me avergüenzo por violar las normas y le juro que no se volverá a repetir.
Supongo que estás usando el ejemplo thinspeak (sino difícil adivinar cuál de los otros veinticuatro ejemplos pueda ser) que fue modificado por última vez hace casi 10 años.
Tal vez, entre tanto, ha habido cambios en la API de ThingSpeak y por eso no te funciona.
hola estoy utilizando arduino uno con un modulo enc28j60 para enviar datos de un sensor de temperatura analogico a thingSpeak. En el codigo uso la libreria etherCard en la cual hay un ejemplo de thingSpeak que se puede modificar dependiendo la informacion que se quiera publicar. Bueno en mi caso es que cuando corro el codigo no me aparece nada en thingspeak; es mas, thingspeak dice que no esta entrando ningun dato. Nose si algo del codigo esta mal o debo hacer una correcion por lo que necesito la ayuda de alguno de ustedes. Se los agradeceria mucho.
Aqui esta el codigo:
// Simple demo for feeding some random data to Pachube.
// 2011-07-08 <jc@wippler.nl>
//
// License: GPLv2
// Handle returning code and reset ethernet module if needed
// 2013-10-22 hneiraf@gmail.com
// Modifing so that it works on my setup for www.thingspeak.com.
// Arduino pro-mini 5V/16MHz, ETH modul on SPI with CS on pin 10.
// Also added a few changes found on various forums. Do not know what the
// res variable is for, tweaked it so it works faster for my application
// 2015-11-09 dani.lomajhenic@gmail.com
#include <EtherCard.h>
#define APIKEY "W439H2J1N87NQ156"
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
const char website[] PROGMEM = "api.thingspeak.com";
byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;
byte session;
//timing variable
int res = 100; // was 0
int SENSOR;
int TEMPERATURA;
void setup () {
Serial.begin(9600);
Serial.println("\n[ThingSpeak example]");
//Initialize Ethernet
initialize_ethernet();
}
void loop () {
SENSOR= analogRead(0);
TEMPERATURA=(-165.0/1023.0)*SENSOR+(125.0);
if (res > 220){
initialize_ethernet();
}
res = res + 1;
ether.packetLoop(ether.packetReceive());
//200 res = 10 seconds (50ms each res)
if (res == 200) {
byte sd = stash.create();
stash.print("field1=");
stash.print(TEMPERATURA);
//stash.print("&field2=");
//stash.print(one);
//stash.print("&field3=");
//stash.print(msje);
stash.save();
//Display data to be sent
Serial.println(TEMPERATURA);
// generate the header with payload - note that the stash size is used,
// and that a "stash descriptor" is passed in as argument using "$H"
Stash::prepare(PSTR("POST /update HTTP/1.0" "\r\n"
"Host: $F" "\r\n"
"Connection: close" "\r\n"
"X-THINGSPEAKAPIKEY: $F" "\r\n"
"Content-Type: application/x-www-form-urlencoded" "\r\n"
"Content-Length: $D" "\r\n"
"\r\n"
"$H"),
website, PSTR(APIKEY), stash.size(), sd);
// send the packet - this also releases all stash buffers once done
session = ether.tcpSend();
// added from: http://jeelabs.net/boards/7/topics/2241
int freeCount = stash.freeCount();
if (freeCount <= 3) { Stash::initMap(56); }
}
const char* reply = ether.tcpReply(session);
if (reply != 0) {
res = 0;
Serial.println(F(" >>>REPLY recieved...."));
Serial.println(reply);
}
delay(300);
}
void initialize_ethernet(void){
for(;;){ // keep trying until you succeed
//Reinitialize ethernet module
//pinMode(5, OUTPUT); // do notknow what this is for, i ve got something elso on pin5
//Serial.println("Reseting Ethernet...");
//digitalWrite(5, LOW);
//delay(1000);
//digitalWrite(5, HIGH);
//delay(500);
// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0){
Serial.println( "Failed to access Ethernet controller");
continue;
}
if (!ether.dhcpSetup()){
Serial.println("DHCP failed");
continue;
}
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
//reset init value
res = 180;
break;
}
}
Si se preguntan porque los comentarios estan en ingles es porque estoy usando un ejemplo de la libreria el cual yo modifique para hacer el protecto y no estoy intentando violar las normas del foro. Si esta mal los comentarios me dicen y los tradusco y envio nueva mente el codigo con los comentarios en español. Gracias.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.