Can't send data using ESP8266

I am trying to connect a NodeMCU Esp 8266 device sending just one variable to a Tago Device I have created.

I have used the Custom HTTP POST for this device.

It seems everything is working correctly, after the settings in Tago.

Now I get this info on my Serial monitor (Arduino):

Conectado na!
Post via HTTP POST: POST /data HTTP/1.1
Device-Token: 6d0f9b65-1470-4937-8b7c-816e0d2c65b4
_ssl: false
Content-Type: application/json
Content-Length: 33

POST /data HTTP/1.1
Device-Token: 6d0f9b65-1470-4937-8b7c-816e0d2c65b4
_ssl: false
Content-Type: application/json
Content-Length: 33


Timeout !

Timeout ! is sent by the Arduino sketch.

Question: how do I make sure my content is sent to the correct variable in the device bucket?
I cannot see any variable with the name my sketch program is sending. And I don´t find any place where I can create a new variable in the Bucket area. Or any other part of Tago.

Help please.

We have had a Tago subscription for some months now. We would like to use it for our tests and for our future clients.

But I don´t seem to get past the basics! Sorry for that but help will be appreciated.

Itajai - SC - Brazil

Hi @joe.vitor.silva,

The variables is creating automatically, when you send a post it should be create.

If you send a multiples values, it should be inside an array, like [{"variable": "count", "value": 33}, {"variable": "anothecount", "value": 34}].

Usually problems with bad request or timeout on arduino, it’s because content-length wrong or missing \r\n, otherwise your request looks good.

You can get a tutorial of arduino on this page,

Thank you for your answer.

You said Arduino (I know NodeMCU ESP8266 is Arduino based). So one first question:

1- Should I use Arduino connection in Tago Device creation? (I have used HTTP). What should be the correct one, please?

For the moment, I am trying to send just one variable to make sure I can do it.
If I can do it, later I will do other tests using more than one variable.

Is there any other way I can get a faster support? Like by phone or by Skype?
It seems to be a minor thing. But I can´t solve it without a first help from you.

Thanks again.
Phone(WhatsApp) — 47 98899-2929

Hi Felipe

Just to make sure, I deleted that Device and its bucket, as instructed.

Now, I have created another Device BUT USING Arduino connection and followed instructions for creation.

My line of code to create the payload to be sent is the one below. Since you mentioned that one possible problem sometimes is related to missing \r\n…in the string to be sent to Tago.

String post_dados = String("“variable”:“contador”,“value”:")+String(contador)+String("}");

Actually, I have no \r\n anywhere in that line. Can that be the cause of not connecting to Tago?
If so, where should I put the \r\n???

Also, I don´t find these characters in the example for Arduino connection you mention.

Lost here!!!


for some reason, the String post_dados in the above post was not shown correctly. I don´t understand why.

Here it is again.

  String post_dados = String("{\"variable\":\"contador\",\"value\":")+String(contador)+String("}");


I see spaces between the data in the lines in your example.
My line doesn´t have spaces?

Are spaces mandatory?

[{“variable”: “count”, “value”: 33}, {“variable”: “anothecount”, “value”: 34}]

String post_dados = String("{“variable”:“contador”,“value”:")+String(contador)+String("}");


Again, no sending data, using Arduino connection.

There may be a problem with variable name. When I try to create the dashboard for the new Device, it shows that there is no variable to choose.

And connection to Tago continues the same as previous deleted device when I used HTTP connection.

Conectado na!
Post via HTTP POST: POST /data HTTP/1.1
Device-Token: a49da826-2aa2-4e23-8472-a72a47c94d67
_ssl: false
Content-Type: application/json
Content-Length: 33

POST /data HTTP/1.1
Device-Token: a49da826-2aa2-4e23-8472-a72a47c94d67
_ssl: false
Content-Type: application/json
Content-Length: 33


Timeout !

Please, help.

hi @joe.vitor.silva, the json can have or not spaces, it’s doesn’t matter, the \r\n is a pattern to send http request on ESP. the \r\n should be between headers and body. On your last posts you send multiples requests, with multiples body and multiples headers, I don’t got it.

Can you share a snippet of your code? then I can check how you are creating those requests.

NOTE: Also, about the support for phone it’s possible if you’re on Scale plan (we are working on a premium support plans on future btw), all you need to do this, if you are a scale client, you can create a ticket and ask for a support by phone, the support team will schedule a meeting.


Here is my code for sending only one variable with the name contador and a value which is incremented by reading a Infra red sensor. very simple.

The program part which supposedly should connect and send the data to Tago is below.

void enviaDadosNuvem(void){

String token = “a49da826-2aa2-4e23-8472-a72a47c94d67”; // token do dispositivo no cadastro da
//String variaveis[2] = (“varialvel1”, “variavel2”); // vetor String para armazenar os NOMES das Variáveis ???
//float valores[2] = {variavel1, variavel2}; // vetor para armazenar os valores dos dados a ser enviados

//for (int i = 0; i < (sizeof(valores) / sizeof(int)); i++ ) {

if (client.connect(server, porta)) {
  Serial.print("Conectado na!\n");   // exibe mensagem de conexão com

  String tago = "";                          // variável com as instruções para remessa dos dados ao servidor

  // aqui começa a montagem do Post via protocolo HTTP e JSON --- payload na variável tago...

  String post_dados = String("{\"variable\":\"contador\",\"value\":")+String(contador)+String("}");
  tago = "POST /data HTTP/1.1\n";
  tago += "Host:\n";
  tago += "Device-Token: " + token + "\n";
  tago += "_ssl: false\n";
  tago += "Content-Type: application/json\n";
  tago += "Content-Length: " + String(post_dados.length()) + "\n";
  tago += "\n";
  tago += post_dados;

  Serial.print("Post via HTTP POST: "); // print Mensagem:  Post via HTTP POST:
  Serial.println(tago);                 // print dos valores enviados para a
  Serial.print(tago);                   // Envia informações para a
  Serial.println(post_dados);// teste

  tago = "";                            // limpa a string com os valores montados para o envio feito

      // verifica timeout
  unsigned long timeout = millis();     // armazena o valor de millis()
  while (client.available() == 0) {     // se o cliente não estiver disponivel
    if (millis() - timeout > 5000) {    // verifica se o servidor ficou 5 segundos sem responder
      Serial.println(">>> Timeout !");  // exibe a mensagem Timeout !
      client.stop();                    // finaliza a comunicação com o servidor da 
      return;                           // sai da função de conexão com a
  while (client.available()){                       // se o cliente estiver disponivel
    String resposta = client.readStringUntil('\r'); // le a string de resposta do servidor
    Serial.print("Resposta do Servidor da Tago: "); // print da mensagem "Resposta.....'
    Serial.print(resposta);                         // print da resosta do servidor
    Serial.print("\n\n");                           // pula duas linhas

client.stop();                                      // finaliza a comunicação com o servidor da 


@joe.vitor.silva, on your snippet I can’t see where you sending the variable tago, to the client.
All your functions call is Serial.print, not client.print, so it’s look like you never sent the string request to ESP. That’s explain why you are getting timeout, you open the connection but never do nothing with it.

if you go to our tutorial, you can see an example using the same interface. it’s should work.

Another thing on your code is about line break, I’m not sure, but ESP use \r\n as line break, and you’re using \n. If you use ESP on AT Mode \n doesn’t work, only \r\n, it can be a problem, but I’m not sure.

Check out the snippet of that code:

if (client.connect(server,80)) { // we will use non-secured connnection (HTTP) for tests
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("POST /data? HTTP/1.1");
    client.println("_ssl: false"); // for non-secured connection, use this option "_ssl: false"
    client.println("Content-Type: application/json");
    client.print("Content-Length: ");
    // note the time that the connection was made:
    lastConnectionTime = millis();
  else {
    // if you couldn't make a connection:
    Serial.println("connection failed");

Thanks Felipe,

Will give it a thorough cheking.
Tomorrow, I will let you know.

But that snippet is the part where I try to send data to Tago.

The other parts of the code just treats the sensor and sets the value on the variable contador.
As you can see, I put the variable name and value in the post_dados line.
It seems it is ok.

I did not understand your comment about which line is sending to Tago.

Serial.print(tago); // Envia informações para a

This line should be doing it, according to my understanding and according to an example I saw in the IOTools video which is on the Internet.

Do you think it is wrong? That may be the problem.

As to \r\n I confess it is a mistery to me. Never seem to understand when to use or when not to use. So I will give it different tries tomorrow to see if it improves on anything.

Don´t you have any example especifically for the ESP8266 NodeMCU or for ESP32, which you could send me to really clarify this part?

Thanks again


Thank you for the moment.

Now it is sending data to TAGO.

It was a mistake in the sketch.
It was not sending correctly because the line didn´t have]


Please,can you explain to us the paid support plans you have?

We may need more help until we can make it a product.


@joe.vitor.silva, great! I’m happy that worked!

I just forwarded that message about paid support to our Sales Team, somebody will contact you very soon.

Thank you.