我写了一个程序,可以通过连接到Arduino Uno的DHT11传感器捕获水分。捕获的值将使用蓝牙HC-06模块发送到Android应用程序。一切正常,但后者(HC-06)不会发出捕获的水分。
有人可以帮助我,谢谢你 代码如下:
#include <SoftwareSerial.h>
/* to communicate with the Bluetooth module's TXD pin */
#define BT_SERIAL_TX 10
/* to communicate with the Bluetooth module's RXD pin */
#define BT_SERIAL_RX 11
/* Initialise the software serial port */
SoftwareSerial BluetoothSerial(BT_SERIAL_RX, BT_SERIAL_TX);
// DHT-11 Configuration
#include <DHT.h> // lightweight DHT sensor library
#define DHTTYPE DHT11 // DHT 11
#define TEMPTYPE 0 // Use 0 for Celsius, 1 for Fahrenheit
#define DHTPIN 2
DHT dht(DHTPIN, DHTTYPE); // Define Temp Sensor
void setup() {
BluetoothSerial.begin(115200); // Initialise BlueTooth
Serial.begin(9600);
//delay(1000);
dht.begin(); // Initialize DHT Teperature Sensor
BluetoothSerial.print("Starting ...");
}
void loop() {
// Take readings
float h = dht.readHumidity(); // Read humidity
BluetoothSerial.println(h);
delay(500);
}