Mi arduino MKR1000 deja de enviar datos a thingspeak

2 views (last 30 days)
Hola,
Tengo 2 arduinos MKR1000, el 1 y 2. El MKR1000 1 envía datos en un canal y 4 campos y me funciona bien. Entonces configuro el otro MKR1000 2 en el mismo canal pero en 4 campos diferentes y entonces éste último me deja de funcionar, sólo recibo 2 mensajes. Y cuando vuelvo a poner el MkR1000 1 ya sólo recibo también 2 mensajes.Thingspeak bloquea alguna MAC por algún motivo?
Muchas gracias.
Un saludo,
Sofía

Answers (2)

Christopher Stapels
Christopher Stapels on 17 Jan 2024
Moved: Christopher Stapels on 17 Jan 2024
We recommend using one channel for each device. There is a 15 second minimum between posting to a channel for the free license, so the devices are likely colliding and causing your data to be lost. Both devices can simultaneously post to separate channels.
If you want both devices to be visible in the same channel, you can create a derived channel with custom visualizations that scrape both channels and show the data. Or you could add a visualization for channel A that reads from channel B and displays the data there.

JOSE JAVIER Anaya Velayos
JOSE JAVIER Anaya Velayos on 18 Jan 2024
Thank you for your answer. I have also try to do this but I can not longer connect to thingspeak. I only receive 2 messages and then seems that my device is blocked. I have also try to delete the complete channel and to create a new one with only one device but I have the same problem, I receive only 2 messages. Do you know why is that? Thank you very much.
  2 Comments
Christopher Stapels
Christopher Stapels on 18 Jan 2024
Do you mean you can only post or write two messages or you can only receive two messages from ThingSpeak when you try to read data?
My guess is that you are posting two fast. Can you share a code snippet so we can have a look at how you are writing or reading?
JOSE JAVIER Anaya Velayos
JOSE JAVIER Anaya Velayos on 18 Jan 2024
I mean that I can only send to thingspeak 2 messages after that I get and error and I can not send it.
I am not posting to fast because I am sending a message every 1 minute. Here you can see the code:
#include <SPI.h>
#include <WiFi101.h>
//Termopares
#include "max6675.h"
#include <TemperatureZero.h>
TemperatureZero TempZero = TemperatureZero();
char ssid[] = "****************";
char pass[] = "***************";
int status = WL_IDLE_STATUS;
// Initialize the Wifi client library
WiFiClient client;
// ThingSpeak Settings
char server[] = "api.thingspeak.com";
String writeAPIKey = "*******";
unsigned long lastConnectionTime = 0; // track the last connection time
const unsigned long postingInterval = 60L * 1000L; // post data every 60 seconds
//Termopares
int ktcSO = 8;
int ktcCS1 = 9; // chip select primer MAX6675
int ktcCLK = 10;
int ktcCS2 = 7; // chip select segundo MAX6675
int ktcCS3 = 6; // chip select tercer MAX6675
int ktcCS4 = 5; // chip select tercer MAX6675
int ktcCS5 = 4; // chip select tercer MAX6675
int ktcCS6 = 3; // chip select tercer MAX6675
MAX6675 ktc1(ktcCLK, ktcCS1, ktcSO);
MAX6675 ktc2(ktcCLK, ktcCS2, ktcSO);
MAX6675 ktc3(ktcCLK, ktcCS3, ktcSO);
MAX6675 ktc4(ktcCLK, ktcCS4, ktcSO);
MAX6675 ktc5(ktcCLK, ktcCS5, ktcSO);
MAX6675 ktc6(ktcCLK, ktcCS6, ktcSO);
float temp1, temp2,temp3,temp4, temp5,temp6;
void setup() {
// attempt to connect to Wifi network
while ( status != WL_CONNECTED) {
// Connect to WPA/WPA2 Wi-Fi network
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection
delay(10000);
}
httpRequest();
TempZero.init();
}
void loop() {
// if interval time has passed since the last connection,
// then connect again and send data
status = WiFi.status();
while ( status != WL_CONNECTED) {
// Connect to WPA/WPA2 Wi-Fi network
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection
delay(10000);
}
if (millis() - lastConnectionTime > postingInterval) {
httpRequest();
}
}
void httpRequest() {
Serial.print("Deg C 1 = ");
double temp1 =ktc1.readCelsius();
Serial.print(temp1);
Serial.print("\n");
Serial.print("Deg C 2 = ");
double temp2 =ktc2.readCelsius();
Serial.print(temp2);
Serial.print("\n");
Serial.print("Deg C 3 = ");
double temp3 =ktc3.readCelsius();
Serial.print(temp3);
Serial.print("\n");
Serial.print("Deg C 4 = ");
double temp4 =ktc4.readCelsius();
Serial.print(temp4);
Serial.print("\n");
Serial.print("Deg C 5 = ");
double temp5 =ktc5.readCelsius();
Serial.print(temp5);
Serial.print("\n");
Serial.print("Deg C 6 = ");
double temp6 =ktc6.readCelsius();
Serial.print(temp6);
Serial.print("\n");
//Internal Temperature (Chip)
float temperature = TempZero.readInternalTemperature();
Serial.print("Internal Temperature is : ");
Serial.println(temperature);
// create data string to send to ThingSpeak
String data = String("field1=" + String(temp1) + "&field2=" + String(temp2)+ "&field3=" + String(temp3)+ "&field4=" + String(temp4) + "&field5="+ String(temp5) + "&field6="+ String(temp6) +"&field7="+ String(temperature));
// close any connection before sending a new request
client.stop();
// POST data to ThingSpeak
int aux=client.connect(server, 80);
Serial.println(aux);
if (aux) {
client.println("POST /update HTTP/1.1");
client.println("Host: api.thingspeak.com");
client.println("Connection: close");
client.println("User-Agent: ArduinoWiFi/1.1");
client.println("X-THINGSPEAKAPIKEY: "+writeAPIKey);
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.print(data.length());
client.print("\n\n");
client.print(data);
}
else{
Serial.print("No entra en ThingSpeak\n");
}
// note the last connection time
lastConnectionTime = millis();
}

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!