Hi, I am trying to to collect temperature/humidity with sensor DHT11 and visualize data via Bluetooth (module HC-05).
I am using Bluetooth Terminal HC-05. Correctly paired the module. I can see "Connected" to HC-05 but no data displayed. I can visualize data from Serial Monitor in IDE but data do not seem to be sent to the Module. The wiring looks good. What could be the cause of the issue? I can share my code/wiring if needed.
Thanks in advance for your help
They are obviously necessary because we are not fortune tellers. ![]()
This proves no more than that the power is applied. It does not prove that Bluetooth is properly connected to Arduino.
From what I can see, it isn't.
Check Rx to Tx and Tx to Rx. Declassifying your code might be helpful as well.
Not to me.
#include <SoftwareSerial.h>
#include <DHT.h>
#define bluetoothTx 1 // TX pin of HC-05 connected to pin 1 (Arduino RX)
#define bluetoothRx 0 // RX pin of HC-05 connected to pin 0 (Arduino TX)
#define DHTPIN 2 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // DHT 11 sensor type
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); // Create a SoftwareSerial object
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor
void setup() {
Serial.begin(9600); // Serial monitor for debugging
bluetooth.begin(9600); // Set up Bluetooth communication
dht.begin(); // Start DHT sensor
}
void loop() {
delay(2000); // Delay between sensor readings
// Read humidity value from the DHT11 sensor
float humidity = dht.readHumidity();
// Check if any reading failed and exit early if so
if (isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Send humidity data wirelessly via Bluetooth
bluetooth.print("Humidity: ");
bluetooth.print(humidity);
bluetooth.println("%");
// Print humidity value to the serial monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%");
}
Haha so funnt
I already connect the tx-hc 05 to rx arduino and rx-hc05 to tx arduino,the data still not display on the phone
You are using software serial on the hardware serial pins, a certain recipe for disaster. Either move the software serial to another pair of pins or simply leave Bluetooth where it is and use the serial commands you already have. The latter means you dispense with software serial altogether.
I am not understand can u provide me some sketch?
#include <DHT.h>
#define DHTPIN 2 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // DHT 11 sensor type
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor
void setup() {
Serial.begin(9600); // ***********
dht.begin(); // Start DHT sensor
}
void loop() {
delay(2000); // Delay between sensor readings
// Read humidity value from the DHT11 sensor
float humidity = dht.readHumidity();
// Check if any reading failed and exit early if so
if (isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Print humidity value to the serial monitor AND BLUETOOTH
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%");
}
NOTE THAT BLUETOOTH MUST BE DISCONNECTED WHILE UPLOADING THE ABOVE CODE.
I have never used software serial but I believe you have called it the wrong way round, and no amount of kosher wiring will fix that.
#include <SoftwareSerial.h>
#include <DHT.h>
#define DHTPIN 2 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // DHT 11 sensor type
SoftwareSerial bluetooth(3,4); // Create SoftwareSerial Rx Tx
The above implies that Bluetooth Tx is connected to pin 3.....
ALSO pls check the "how to use this forum" stickies, particularly about posting code.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.