Johnny-Five를 이용하여 아두이노에 연결한 온도센서(DS18B20) 값 읽어오기Arduino Uno2015. 12. 2. 20:57
Table of Contents
반응형
Node.js를 설치하는 방법은 아래 글들을 참고하세요..
[웹/Node.js] - Ubuntu 14.04에 Node.js 설치 및 간단한 예제
[임베디드/Raspberry Pi] - Node.js를 이용하여 라즈베리파이2에 연결된 LED 제어하기
https://github.com/firmata/ConfigurableFirmata에서 라이브러리를 다운로드 받아서 C:\Users\webnautes\Documents\Arduino\libraries에 압축을 풀어 넣어줍니다..
아두이노를 피시에 연결하고 메뉴에서 파일-예제-ConfigurableFirmata-ConfigurableFirmata를 선택하여 불러온 후.. 아두이노에 업로드시킵니다..
피시에서 해도 되지만.. 저는 라즈베리파이에 아두이노를 연결하고 진행했습니다.
이제 디렉토리를 하나 만들고 필요한 johnny-five 패키지를 설치해줍니다.
$ mkdir johnny-five && cd johnny-five
$ npm install johnny-five
temp.js 라는 이름으로 아래 내용을 넣어 파일을 하나 만듭니다.
var five = require("johnny-five");
five.Board().on("ready", function() {
// This requires OneWire support using the ConfigurableFirmata
var temperature = new five.Thermometer({
controller: "DS18B20",
pin: 2
});
temperature.on("data", function() {
console.log(this.celsius + "°C", this.fahrenheit + "°F");
console.log("0x" + this.address.toString(16));
});
});
이제 아두이노에 DS18B20을 연결해줍니다.
실행시켜 보면.. 온도값이 올라오는 것을 확인할 수 있습니다.
sudo node temp.js
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.6875°C 83.6375°F
0x61796ff
28.625°C 83.525°F
0x61796ff
28.625°C 83.525°F
0x61796ff
28.625°C 83.525°F
0x61796ff
28.625°C 83.525°F
0x61796ff
반응형
'Arduino Uno' 카테고리의 다른 글
아두이노 부트로더 컴파일해서 업로드 시켜보기 (0) | 2015.12.10 |
---|---|
아두이노와 초음파 센서( HC-SR04)를 이용하여 거리 측정하기 (2) | 2015.12.08 |
Johnny-Five를 이용하여 아두이노에 연결한 LED 제어하기 (0) | 2015.12.01 |
Arduino에 연결한 Nokia 5110 LCD에 온도센서값(ds18b20) 출력해보기 (0) | 2015.11.25 |
Nokia 5110 LCD를 arduino uno에 연결하기 (0) | 2015.11.25 |