Project tutorial
Programmable Wireless Room Thermostat (Bluetooth Accessible)

Programmable Wireless Room Thermostat (Bluetooth Accessible) © GPL3+

Wireless room thermostat with LCD screen. Two Arduinos, Pro Mini is master, Uno is slave. Now with Bluetooth accessible.

  • 3,541 views
  • 0 comments
  • 8 respects

Components and supplies

Apps and online services

About this project

Hello my friends. Yes, thermostat again but it has real time clock and wireless communication with Ferroli Combi. It has two parts. One of (master one) measuring temperature, show the temp with LCD and send the temp info to Combi with Arduino Pro Mini. Sure, you can use Arduino Uno, as a matter of size. The other one (the slave), receives the temp info, processes it according to the code and time data.

But first things first, let's create the master one.

Step 1: Measure the temperature of the room.

It's easy with DHT11, you know that. DHT11 can measure the ambient temperature with 1 degree of precision. It is okay for me. Easily connect your DHT11 to Arduino Pro Mini. You can use LM35, etc.

Step 2: Show measured temperature, DHT11 status and Communication status with LCD.

So we know the temperature. Code is easy:

   lcd.clear();                                
   lcd.setCursor(0, 0);                        
   lcd.print("Hum%   : ");                      
   lcd.print((float)DHT11.humidity); 
   lcd.setCursor(0, 1);                        
   lcd.print("Temp: ");                     
   lcd.print((float)DHT11.temperature) 
   delay (3000);

I include the code for showing DHT11 working status to us. The library I use for DHT11 has a (chk) command for checking of the DHT11 measuring status. If the value of chk is "zero", its okay. Otherwise check your connections or DHT11 Sensor.

int chk = DHT11.read(DHT11PIN)   
lcd.print(chk) 

Finally, connect to nRF24 to your pro mini. This code for the writing the communicate status check result to LCD.

boolean gonderimDurumu = verici.send(FAST);    
 if (gonderimDurumu == true)                 
   lcd.print("Send..");                                  
 else 
 { 
   lcd.clear(); 
   lcd.setCursor(0, 0); 
   lcd.print("Cant Send..."); 
  } 

Step 3: Creating Slave one

Connect other nRF24, relay, Bluetooth module and DTS1302 Real time Clock module to Arduino Uno. Relay must connect to your Combi 's room thermostat bridge. It is usually bridged with a jumper wire.

There is a important tip for the setting up the clock module for the first time.

Important !: Use this line only once then deactive it. Otherwise it will always back to the your first clock setting time with every reset or energy interruption.

myRTC.setDS1302Time(00, 48, 23, 04, 26, 01, 2017);  // Seconds, minutes, hours, weekday, day, mounth, year (Monday is the first weekday)

Step 4: Setting Up The Weekly Programme

This is mine, you can create yourself:

You can easily force this program by Bluetooth (BT) commands with your smartphone etc. Do to this I use "Bluetooth Terminal" app. When you send "a" command by BT, combi will in "Forced Mode" and start heating promptly. If you think room temp is okay then send "b" command by BT to combi. It will in your schedule and wait for RF data to decision.

Code

Wireless Room Thermostat (Slave part code) RecieverArduino
This code for slave part (receiver)
//   WIRELESS ROOM THERMOSTAT v1.0 (RECEIVER)
//
//  Writer: Tamer Savaşcı
//  Date: 27.01.2017
//
//  email: tsavasci@yahoo.com


#include <SPI.h>
#include <nRF24L01p.h>
#include <virtuabotixRTC.h>
#include <SoftwareSerial.h>
SoftwareSerial bluetoothModule(A0, A1);
/* Arduino  ->  Bluetooth module
  A0 (Rx)   ->  Tx
  A1 (Tx)   ->  Rx
*/

nRF24L01p receiver(7, 8);            // CSN = 7, CE = 8
virtuabotixRTC myRTC(5, 4, 3);    // SCLK = 5, I/O(DAT) = 4, CE = 3

int relay = 2;
float set_temp;
float room_temp;
char BT_readChar;
int relay_status = 0;
int BT_Force = 0;

void BT ()
{
  BT_readChar = bluetoothModule.read();
  switch (BT_readChar)
  {
    case 'a':
      BT_Force = 1;
      digitalWrite(relay, HIGH);
      relay_status = 1;
      Serial.println("Forced mode: on");
      bluetoothModule.println("Forced mode: on");
      break;

    case 'b':
      BT_Force = 0;
      Serial.println("Combi is waiting RF command by Bluetooth command");
      bluetoothModule.println("Combi is waiting RF command by Bluetooth command");
      break;
  }
}

void time_function()
{
  myRTC.updateTime();
  Serial.print("Date / Time : ");
  Serial.print(myRTC.dayofmonth);
  Serial.print("/");
  Serial.print(myRTC.month);
  Serial.print("/");
  Serial.print(myRTC.year);
  Serial.print(" ");
  Serial.print("(");
  Serial.print(myRTC.dayofweek);
  Serial.print(")");
  Serial.print(" ");
  Serial.print(myRTC.hours);
  Serial.print(":");
  Serial.print(myRTC.minutes);
  Serial.print(":");
  Serial.println(myRTC.seconds);
  delay(3000);
}

void RF()
{
  while (receiver.available())         // while receiver active
  {
    receiver.read();
    receiver.rxPL(room_temp);           // read receiver
    digitalRead(BT_Force);
    if (BT_Force == 0)
    {
      if (set_temp > room_temp)             // if "set_temp" value bigger than "room temp"
      {
        digitalWrite(relay, HIGH);      // trigger the relay
        relay_status = 1;
        Serial.println("Combi opened due to RF temp data"); // Combi is ON
        Serial.println();
        bluetoothModule.println("Combi opened due to RF temp data");
        bluetoothModule.println();
        digitalRead(BT_Force);
      }
      else                             // otherwise cut the power of relay
      {
        digitalWrite(relay, LOW);
        relay_status = 0;
        Serial.println("Combi closed due to RF temp data"); // combi is OFF
        Serial.println();
        bluetoothModule.println("Combi closed due to RF temp data");
        bluetoothModule.println();
        digitalRead(BT_Force);
      }
    }
    else
    {
      Serial.println("Combi is working in forced mode by Bluetooth command");
      bluetoothModule.println("Combi is working in forced mode by Bluetooth command");
    }
  }
}

void seri()
{
  Serial.print("set_temp: ");
  Serial.println(set_temp);
  Serial.print("Room temp: ");
  Serial.println(room_temp);
  Serial.print("BT Forced status: ");
  Serial.println(BT_Force);
  Serial.println ();
}

void BT_info()
{
  bluetoothModule.print("set_temp: ");
  bluetoothModule.println(set_temp);
  bluetoothModule.print("Room temp: ");
  bluetoothModule.println(room_temp);
  bluetoothModule.println();
  if (relay_status < 1)
  {
    bluetoothModule.println("Combi:On");
    bluetoothModule.println ();
  }
  else
  {
    bluetoothModule.println("Combi:Off");
    bluetoothModule.println ();
  }
}

void setup()
{
  bluetoothModule.begin(9600);
  Serial.begin(9600);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  receiver.channel(90);
  receiver.RXaddress("Tamer");
  receiver.init();
  pinMode (2, OUTPUT);
  //myRTC.set_tempDS1302Time(00, 19, 01, 04, 9, 03, 2017);  // This line is for the first upload to arduino than deactive it with (//)
}

void loop()
{
  time_function();
  while (myRTC.dayofweek < 6)
  {
    while (myRTC.hours < 6)
    {
      time_function();
      set_temp = 19;                        // set_temp combi to 19
      Serial.println("Weekdays");
      Serial.println("Gece Modu");
      seri();
      bluetoothModule.println("Weekdays");
      bluetoothModule.println("Gece Modu");
      BT_info();
      RF();
      BT();
    }
    while (myRTC.hours < 8)
    {
      time_function();
      set_temp = 22;
      Serial.println("Weekdays");
      Serial.println("Uyanis Modu");
      seri();
      bluetoothModule.println("Weekdays");
      bluetoothModule.println("Uyanis Modu");
      BT_info();
      RF();
      BT();
    }
    while (myRTC.hours < 17)
    {
      time_function();
      set_temp = 19;
      Serial.println("Weekdays");
      Serial.println("Home is empty");
      seri();
      bluetoothModule.println("Weekdays");
      bluetoothModule.println("Home is empty");
      BT_info();
      RF();
      BT();
    }
    while (myRTC.hours >= 17)
    {
      time_function();
      set_temp = 22;
      Serial.println("Weekdays");
      Serial.println("People in the house");
      seri();
      bluetoothModule.println("Weekdays");
      bluetoothModule.println("People in the house");
      BT_info();
      RF();
      BT();
    }
  }
  while (myRTC.dayofweek < 8)
  {
    while (myRTC.hours <= 7)
    {
      time_function();
      set_temp = 19;
      Serial.println("Weekend");
      Serial.println("Gece Modu");
      seri();
      bluetoothModule.println("Weekend");
      bluetoothModule.println("Gece Modu");
      BT_info();
      RF();
      BT();
    }
    while (myRTC.hours > 7)
    {
      time_function();
      set_temp = 22;
      Serial.println("Weekend");
      Serial.println("People in the house");
      seri();
      bluetoothModule.println("Weekend");
      bluetoothModule.println("People in the house");
      BT_info();
      RF();
      BT();
    }
  }
}
Wireless Room Thermostat (Master part code) Transmitter Arduino
This code for the transmitter.
//   WIRELESS ROOM THERMOSTAT v1.0 (TRANSMITTER)
//   
//  Writer: Tamer Savaşcı
//  Date: 27.01.2017
// 
//  
//  email: tsavasci@yahoo.com



#include <dht11.h>                              // dht11 library
#define DHT11PIN 2                              // DHT11PIN is digital 2
#include <SPI.h>                                // SPI library
#include <nRF24L01p.h>                          // nRF24 library
#include <LiquidCrystal.h>                      // LCD library
LiquidCrystal lcd(3, 4, 5, 6, 10, A0);          // LCD pins
nRF24L01p verici(7, 8);                         // CSN = 7, CE = 8 for nRF24
float sicaklik;                                 // creating sending messsage int
dht11 DHT11;                                    // DHT11 begin

void setup()
{
  Serial.begin(9600);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);                    // SPI begin
  verici.channel(90);
  verici.TXaddress("Tamer");                    // unique name for the com channel
  verici.init();                                // transmitter begin
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
}

void loop()
{
  int chk = DHT11.read(DHT11PIN);               // chk int. İf its 0 its ok
  Serial.println();
  Serial.print("Nem (%): ");
  Serial.println((float)DHT11.humidity, 2);     // humidity
  Serial.print("Sicaklik (Celcius): ");
  Serial.println((float)DHT11.temperature, 2);  // Temp 
  Serial.println(chk);                          // DHT11 check
  sicaklik = DHT11.temperature, 2;              // define the sending message
  verici.txPL(sicaklik);                        // message for the nRF24
  boolean gonderimDurumu = verici.send(FAST);   // Com. status check

  if (gonderimDurumu == true)                   // if com. fails it will false
  {
    Serial.println("mesaji gonderildi");        // Debugging 
    
    lcd.clear();                                // LCD clear
    lcd.setCursor(0, 0);                        // setting LCD cursor position
    lcd.print("Gonderildi..");                  // com status writing to LCD 
    lcd.setCursor(0, 1);                        
    lcd.print(chk);                             // DHT11 chk value for debugging 
    delay(3000);                                // wait 3 seconds 
    lcd.clear();                                
    lcd.setCursor(0, 0);                        
    lcd.print("Nem %   : ");                    
    lcd.print((float)DHT11.humidity);
    lcd.setCursor(0, 1);                        
    lcd.print("Sicaklik: ");                    
    lcd.print((float)DHT11.temperature);
  }
  else
  {
    Serial.println("mesaji gonderilemedi");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Gonderilemedi.");
    lcd.setCursor(0, 1);
    lcd.print(chk);
    delay(3000);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Nem %   : ");
    lcd.print((float)DHT11.humidity);
    lcd.setCursor(0, 1);
    lcd.print("Sicaklik: ");
    lcd.print((float)DHT11.temperature);
  }
  delay(180000);                              // wait for 3 min
}

Schematics

Wireless Room Thermostat (Master part code) Transmitter
it is for Transmitter
kablosuz_oda_termostati_(transmitter)_xo5d8borpa.fzz
Wireless Room Thermostat (Slave part code) Reciever
it is for receiver
receiver_with_bt_BzjSLMxIrr.fzz

Comments

Similar projects you might like

Bluetooth TFS Build LED strobe light

Project tutorial by Jimmy Ramkisoen

  • 3,339 views
  • 0 comments
  • 10 respects

Gesture Based Wireless Gaming Console

Project tutorial by Team Xolcano Technologies

  • 1,495 views
  • 0 comments
  • 1 respect

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,826 views
  • 17 comments
  • 75 respects

Wireless weather station (Arduino + ESP8266 + Thingspeak)

Project tutorial by Alin-Constantin Paun

  • 8,863 views
  • 2 comments
  • 11 respects

Protect Your Room with Fingerprints for Under $20

Project tutorial by Srivishnu Piratla

  • 6,524 views
  • 2 comments
  • 22 respects
Add projectSign up / Login