Skip to content

Instantly share code, notes, and snippets.

@valvoline
Created February 1, 2018 21:46
Show Gist options
  • Save valvoline/9ae55b197b20f64247ade5444111876b to your computer and use it in GitHub Desktop.
Save valvoline/9ae55b197b20f64247ade5444111876b to your computer and use it in GitHub Desktop.
int chk = DHT.read22(DHT22_PIN);
switch (chk)
{
case DHTLIB_OK:
client.print("{ \"temperature\":");
client.print(DHT.temperature-2);
client.print(", \"humidity\":");
client.print(DHT.humidity);
client.println("}");
break;
case DHTLIB_ERROR_CHECKSUM:
client.println("{ \"status\" : \"Checksum error\"");
break;
case DHTLIB_ERROR_TIMEOUT:
client.println("{ \"status\" : \"Timeout error\"");
break;
default:
client.println("{ \"status\" : \"Unknown error\"");
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment