[temp(value), humd(value) /n] 이러한 형태의 문자열로 1초에 한 번씩 블루투스에게 값을 보내줍니다.
어? 만약 안드로이드 스튜디오에서 String으로 값을 받았네?
나는 숫자로 받아서 안드로이드 스튜디오에서 계산해서 값을 집어넣고 싶은데?
방법 : 안드로이드 스튜디오 : String에서 double형태로 바꾸기
double dTemp = Double.parseDouble(array[0]);
double dHumd = Double.parseDouble(array[1]);
간단하죠?
여러분들도 온습도 센서말고도 원하는 센서를 달아 보시면 상당히 재미있습니다.
저 같은 경우는
음속 = (331.5 + (0.6*celsius)) m/s 왕복거리 = 음속 * 시간
거리 = (음속 * 시간)/2
위
공식을 사용하여 온도에 따른 좀 더 정확한 초음파 센서를 만들어 보았습니다.
이것으로 블루투스 모듈에 관한 두 번째 글을 마치도록 하겠습니다.
Copyright (c) 2014 Akexorcist
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.