|
비콘을 사용하려고 검색하다 보니까
https://hojunpark.wordpress.com/tag/beacon/
여기에 비콘 데이터 송신시 온도도 함께 보내는 것을 봤는데,
HM-10 에서 BLE 모듈에서도 가능한 것인가요?
어떻게 페어링 없이 센서의 데이터를 보낼 수 있는 방법이 있을까요?
MIDASCON에서도 온습도 센서의 값을 전달하는것 같은데 방법 문의드립니다.
먼저 제가 이것저것 조합해서 소스를 작성해보았습니다.
작성해본결과 해당소스 업로드 후 AT 명령어를 입력하면 비콘의 활성화 되면서 핸드폰에서 거리가 출력은 되지만 센서의 값은 출력이 안됩니다....
제가 구성하고 싶은거는 일정거리에 도달했을 경우 온도와 습도의 센서값을 핸드폰으로 전송 받고 싶은데 잘되질 않아 문의드립니다.
#include "Sensirion.h"
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(2, 3); // SoftwareSerial(RX, TX)
const uint8_t dataPin = 9; // SHT serial data
const uint8_t sclkPin = 8; // SHT serial clock
const uint32_t TRHSTEP = 500UL; // Sensor query period
Sensirion sht = Sensirion(dataPin, sclkPin);
uint16_t rawData;
float temperature;
float humidity;
//float dewpoint;
byte measActive = false;
byte measType = TEMP;
unsigned long trhMillis = 0; // Time interval tracking
unsigned long blinkMillis = 0;
void setup() {
Serial.begin(9600);
Serial.println("Hello!");
// 블루투스 포트 열어라
BTSerial.begin(9600);
sht.measTemp(&rawData); // SHT75 온도데이터
temperature = sht.calcTemp(rawData);
sht.measHumi(&rawData); // SHT75 습도데이터
humidity = sht.calcHumi(rawData, temperature);
//dewpoint = sht.calcDewpoint(humidity, temperature);
logData();
}
void loop() {
unsigned long curMillis = millis();
// Demonstrate non-blocking calls
if (curMillis - trhMillis >= TRHSTEP) {
measActive = true;
measType = TEMP;
sht.meas(TEMP, &rawData, NONBLOCK); // 온도 측정시작
trhMillis = curMillis;
}
if (measActive && sht.measRdy()) {
if (measType == TEMP) {
measType = HUMI;
temperature = sht.calcTemp(rawData);
sht.meas(HUMI, &rawData, NONBLOCK); // 습도측정시작
} else {
measActive = false;
humidity = sht.calcHumi(rawData, temperature); // Convert raw sensor data
// dewpoint = sht.calcDewpoint(humidity, temperature);
logData();
}
}
while (BTSerial.available()){ // 블루투스로 전송
byte data = BTSerial.read();
Serial.write(data); // 시리얼 모니터에 출력
}
while (Serial.available()){ // 시리얼 모니터 전송
byte data = Serial.read();
BTSerial.write(data); // 블루투스에 출력
}
}
void logData() {
BTSerial.print("Temperature = ");
BTSerial.print(temperature);
BTSerial.print("C");
BTSerial.print("Humidity = ");
BTSerial.print(humidity);
BTSerial.print("%");
delay(500);
}
|