Skip to content

Instantly share code, notes, and snippets.

@arduinothai
Created May 18, 2018 12:59
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 arduinothai/188a94847cd7ce2d3a0015e5839832b7 to your computer and use it in GitHub Desktop.
Save arduinothai/188a94847cd7ce2d3a0015e5839832b7 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <AM2320.h>
AM2320 th;
void setup() {
Serial.begin(9600);
}
void loop() {
switch(th.Read()) {
case 2:
Serial.println("CRC failed");
break;
case 1:
Serial.println("Sensor offline");
break;
case 0:
Serial.print("humidity: ");
Serial.print(th.h);
Serial.print("%, temperature: ");
Serial.print(th.t);
Serial.println("*C");
break;
}
delay(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment