Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member683242
Participant
689

Introduction


Welcome to the second part of the Home Automation Workshop 1.

In PART 1, we discussed automatic lighting control using PIR sensor.

In this blog post we will get to see how automatic temperature control works using Arduino Board and Temperature Sensor.

Scenario:


Turn on the fan based on the room temperature 

Components Involved:



  • Arduino UNO Board 

  • Temperature Sensor 

  • Breadboard 

  • Jumper Wires 

  • DC Motor 

  • H-bridge Motor Driver - L293D 


Steps:



  1. We have the basic circuit ready with us from the first scenario. Now, search for temperature sensor and drag and drop it over the circuit area. We will connect the power of the temperature sensor with the positive terminal of the breadboard and GRND terminal to the negative terminal of the breadboard.

  2. Next, connect the Voltage output of the temperature sensor to the analog input of the Arduino board as shown in the diagram below.

  3. Connect the power cable to the Motor driver. Similarly, connect the two ground cables on the Ground pin and enable pin (shown as blue wires).

  4. Connect the output from the Arduino board to the Motor driver. Take the 12th pin and connect it to the input1 of the Motor driver. 

  5. If you want to run the motor in both directions, you can connect the pin 13th of the Arduino board to input2 of the Motor driver.

  6. Next, connect the output1 of the H-bridge Motor driver to one terminal of the motor. Similarly, connect the output2 to the other terminal. 

  7. Now let us add the code.
    void setup() 
    {
    pinMode(12,OUTPUT);
    pinMode(13,OUTPUT);
    pinMode(A0,INPUT);
    }
    void loop()
    {
    //temp with fan
    float value=analogRead(A0);
    float temperature=value*0.48;
    if(temperature > 20)
    {
    digitalWrite(12,HIGH);
    digitalWrite(13,LOW);
    }
    else
    {
    digitalWrite(12,LOW);
    digitalWrite(13,LOW);
    }
    }


  8. This completes our circuit for this scenario.


 

Hope you liked the blog post. Stay tuned for more such blog posts where we will focus on breaking down the working of a smart home to see how these things run.

Cheers !!