Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active December 26, 2020 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/a1c9e2c8570125d9e8e659e8bb6d2f5a to your computer and use it in GitHub Desktop.
Save parzibyte/a1c9e2c8570125d9e8e659e8bb6d2f5a to your computer and use it in GitHub Desktop.
int tiempoTranscurrido = 5;
float temperatura = 14.20;
float humedad = 79.20;
// Búfer para escribir datos en JSON
char bufer[50];
// Crear la respuesta pasando las variables
// La salida será algo como:
// {"t":14.20,"h":79.20,"l":5.00}
sprintf(bufer, "{\"t\":%.2f,\"h\":%.2f,\"u\":%d}", temperatura, humedad, tiempoTranscurrido);
// Responder con ese JSON
servidor.send(200, "application/json", bufer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment