Created
June 7, 2018 05:25
-
-
Save penpencool/7153f54192ae9e14c9b9e1403b0ae0ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
การต่อสาย 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