Bom dia, to tentando ler um arquivo .json no arduino, mas ele não abre o arquivo .json, então criei um arquivo j.txt com a mesma estrutra do .json e consegui ler pelo arduino. Mas não consigo para a String dados para char json. Como posso fazer isso ?

String dados = "";
String string = "";
char caractere;

File myfile = SD.open("t.txt",FILE_READ);

if (myfile)
{
while (myfile.available())
{
caractere = myfile.read();
if (caractere != "\n"){
dados.concat(caractere);
}
delay(10);
}
myfile.close();

}

char json[69];
dados.toCharArray(json, 69);
Serial.println(json);

StaticJsonBuffer<200> jsonBuffer;

JsonObject& root = jsonBuffer.parseObject(json);

if (!root.success())
{
Serial.println("parseObject() failed");
return;
}

const char* sensor = root["sensor"];
long time = root["time"];
double latitude = root["data"][0];
double longitude = root["data"][1];

Serial.println(time);
Serial.println();
Serial.println();

Exibições: 212

Responder esta

Respostas a este tópico

Bom dia  SMSR .

Sugiro ler o tópico: http://labdegaragem.com/forum/topics/sugest-o-de-como-postar

RV

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço