Back to engineering work

Embedded sensing + wireless serial

Bluetooth temperature and humidity link

A DHT11 sensor supplies temperature and humidity readings to a Bluetooth serial link. The firmware checks the measurements before formatting them for an HC-05 receiver.

Bluetooth environmental sensor linkDevelopment work
Project wiring view showing the controller, DHT11 and Bluetooth serial module
Project wiring view. The complete data-send function is available below.

Engineering scope

  • DHT11 temperature and humidity acquisition
  • Invalid-reading handling
  • Formatting and transmission over Bluetooth serial

Firmware flow

How a temperature reading reaches Bluetooth

Complete temperature and humidity transmission routine.

ActionRead temperature and humidity
CheckBoth readings valid?Neither reading may be an unavailable numeric value.
Result · NoSend a sensor-read error and stop
Action · YesFormat the two readings
ResultSend over Bluetooth serialAlso print the packet to the local serial log.

Read temperature and humidity. If either reading is invalid, send a sensor-read error and stop. Otherwise format the values and send them through the HC-05 serial interface.

This establishes the packet-building logic, not wireless range, delivery confirmation or sensor accuracy.

Read the implementation

sendDHT11Data · selected source lines 187–206. Source inspection is not a hardware test.

void sendDHT11Data() {
  float humidity = dht.readHumidity();
  float temperatureC = dht.readTemperature();

  if (isnan(humidity) || isnan(temperatureC)) {
    Serial.println("DHT11 read failed.");
    hc05.println("ERROR,DHT11_READ_FAILED");
    return;
  }

  String dataPacket = "";

  dataPacket += "TEMP_C=";
  dataPacket += temperatureC;
  dataPacket += ",HUMIDITY=";
  dataPacket += humidity;

  Serial.println(dataPacket);
  hc05.println(dataPacket);
}
Open the exact source-level diagram

Invalid-reading handling

The send function reads temperature and humidity, then checks both values. If either read fails, it sends DHT11_READ_FAILED and returns without formatting a numeric result.

Serial message formatting

For valid measurements, the function builds a temperature-and-humidity message and writes it to the HC-05 serial connection. The complete function is included below.

Source implementation

The excerpt documents acquisition, validation, formatting and transmission. It does not establish sensor accuracy, hardware endurance or production validation.

All projectsArchive record

Project enquiries

Discuss your project.

Tell us what you’re developing and where you need engineering support.

Discuss your project