Skip to content

Instantly share code, notes, and snippets.

@penpencool
Created June 7, 2018 05:25
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 penpencool/7153f54192ae9e14c9b9e1403b0ae0ad to your computer and use it in GitHub Desktop.
Save penpencool/7153f54192ae9e14c9b9e1403b0ae0ad to your computer and use it in GitHub Desktop.
/*
การต่อสาย AM2320 กับ Arduino Uno
VCC - 3.3-5V
GND - GND
SCL - A5
SDA - A4
*/
#include <Wire.h>
#include <AM2320.h>
AM2320 th;
void setup() {
Serial.begin(9600);
// Example By ArduinoAll
}
void loop() {
switch (th.Read()) {
case 2:
Serial.println("CRC failed");
break;
case 1:
Serial.println("Sensor offline");
break;
case 0:
Serial.print("ArduinoALL 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