In this project, we will request, from the phone, that the Arduino send temperature or humidity information depending on the character sent. We will need to add the DHT-11 sensor to our circuit. The following diagram shows how to do this:
The DHT-11 temperature sensor is connected to the Arduino exactly as we did in Chapter 9, Environment Sensors. If you are unsure how to connect this sensor to the Arduino, please refer back to that chapter. Now we will need to write the code, so we can access the data from the sensor with Bluetooth LE service. We will start by setting up the SoftwareSerial library for the Bluetooth module and the DHT-11 temperature sensor. The following code will do this:
#include <DHT.h> #include <SoftwareSerial.h> #define DHT_PIN 3 #define DHT_TYPE DHT11 DHT dht(DHT_PIN, DHT_TYPE); SoftwareSerial HM10...