Skip to main content

Smart Home using Tamra IoT

· 10 min read
Ahmed Farouk
Nadeen Muhammed Elhadad

In this demo, we'll show you the steps to build your very own smart home using the Tamra IoT platform. This smart home has 3 basic systems and you can configure it to your liking. None of these systems depend on each other.

These systems are:

1. Lighting System: The lighting feature enables you to control the light in your smart home on the Tamra application.

2. Security System: With the security system feature, you get to activate and deactivate the system from your Tamra app.

3. Air Conditioning System: The air conditioning system allows you to monitor the room temperature, control the fan in your smart home as well as open and close your window.

Smart Home Smart Home

Components

  • Breadboard 630-Tie Point "BB-01"
  • Male-Male Jumper Connecting Wire
  • Female-Female Jumper Connecting Wire
  • Male-Female Jumper Connecting Wire
  • Wall Adapter Fixed 12V 2A DC
  • DC 2.1mm Female Plug 25cm
  • 5v Dual Channel Relay Module with Optocoupler
  • LED Strip 12V
  • 2x Transistors 2N2222 "NPN"
  • PIR Motion Sensor Module
  • Small Buzzer 5V
  • Servo Motor Micro (180) 1.6 kg.cm Plastic Gears "SG90"
  • 12V DC Fan Size 5x5 cm2
  • LM35 Temperature Sensor
  • Insulating tape
  • Screwdriver

BreadBoard Male-male Jumpers Female-female Jumpers Male-female Jumpers Adapter DC 2.1mm Female Plug 25cm Relay LED Strip 2N222A PIR Module Buzzer Servo DC Fan LM35 Insulating tape Screwdriver

Step 1: powering up your system

The first and most vital step is to connect the power sources to your breadboard. This can be achieved by following the next steps closely.

  1. You'll want to connect the 12V adapter to the female plug as shown in the picture.
  2. We'll strip two jumpers with male ends from the other end. This male end will be inserted in the breadboard as shown in the picture, with the red VCC wire in the +ve line and the black GND wire in the -ve line. The other stripped side will be attached to the female plug as shown in the picture. Make sure to secure the connection by twisting the bare wires together and applying tape to the stripped parts.
  3. The first thing we'll start to power up will be our Tamra board. We'll do this by using a male-male jumper to apply 12V from the VCC line we just powered up to the Vin pin of our board. We'll use another male-male jumper to connect a GND pin to the GND line.
  4. Now that the board is powered up, we'll use its 5V output pin to supply the opposite line of the breadboard. Similarly, we'll connect a male-male jumper from the 5V pin on our board to the other +ve line on the breadboard, and a different male-male jumper from another GND pin to the -ve line on the breadboard.

Now that we have our power options ready, we can tackle a feature at a time!

note

You can use any 12V DC power supply available and follow the same steps of using jumpers to connect the VCC and GND wires to the +ve and -ve lines on your breadboard respectively.

Powering Up Powering Up Powering Up

Step 2: lighting up your smart home

This step is simple. What we want to achieve here is being able to turn the LED strip on and off from our Tamra application. The steps will be as follows:

  1. Power your relay module up by using female-male jumpers to connect the VCC and GND pins on the module to the 5V and GND lines on your breadboard.
  2. We'll strip two jumpers with male ends from the other end. The stripped sides will be attached to the two wires on one end of the LED strip as shown in the picture. This step is to make handling the LED strip easier than working with wires. Make sure to secure the connection by twisting the bare wires together and applying tape to the stripped parts.
  3. Now that we have male ends to the LED strip that are easier to work with. We'll connect the GND jumper of the LED strip to any GND line on our breadboard. After, we'll connect the male end of the VCC jumper of the LED strip to the relay's COM1 as shown in the picture.
  4. We'll connect the NO1 pin on the relay to the 12V line on our breadboard with a male-male jumper.
  5. Finally, for the IN1 pin, we'll connect it to any digital pin on our board using a female-male jumper. We chose pin 2 for this step.
note

If the relay you're using is Active Low, the operation of the ON and OFF slider in your application is reversed, i.e., when you press OFF the LED strip turns on and vice versa.

Lighting System Lighting System Lighting System

Step 3: securing your smart home

For this feature, we'll use the application to turn our security system on and off. If the system is turned on, the motion sensor is enabled and, when it detects motion, the buzzer is on. When the system is turned off, the motion sensor is disabled and any motion around the house will go undetected. To implement this system, we'll go through the following steps:

  1. At the beginning of this set of steps, we'll attach our two transistors, named transistor 1 and transistor 2, and our buzzer to our breadboard so we can start with our connections.
  2. If you inspect your PIR sensor, you'll find that it has 3 pins (legs): VCC, GND, and OUTPUT. We'll connect the pin named GND to any GND on our breadboard with a female-male jumper. For the VCC pin, we'll connect it to the emitter of transistor 1 with another female-male jumper. The emitter is the leg on the left if the flat side of the transistor is facing you, as can be seen in the picture. For the last pin, the output pin, we'll use a female-male jumper to connect it to the base of transistor 2. The base is the middle pin of a transistor.
  3. For transistor 1, we've established that its emitter is connected to the VCC pin of the PIR sensor with a female-male jumper. Now, we'll connect its base pin to any digital pin on our board using a male-male jumper. For this step, we chose pin 3, and it will be considered our Activation Pin since we'll send the signal of system activation from the application on it. For the collector pin of transistor 1, we'll simply use a male-male jumper to connect it to any pin on the 5V line on our breadboard.
  4. For the set of pins of transistor 2, we've already connected its base pin to the output pin of the PIR sensor. For its emitter pin, we'll use a male-male jumper to connect it to the GND pin of the buzzer. And for its collector pin, we'll use another male-male jumper to connect it to any GND pin on either of the GND lines.
  5. The last pin we need to connect for this step is the VCC pin of the buzzer which we'll use a male-male jumper to connect it to any point on the 5v line.

Security System Security System

Step 4: air conditioning your smart home

Here, we'll measure the room temperature and be able to read it from the application. We'll also implement two methods of air conditioning the smart home and control both methods from the Tamra application on our phones. The steps to implement this feature are as follows:

  1. We'll use two male-male jumpers, we'll connect each of the +ve and -ve wires of the DC fan to a jumper to make it easier to handle with the fan.
  2. For the connections, we'll connect the black GND jumper of the fan to any GND pin on the GND lines of the breadboard. And for its red VCC wire, we'll connect it to COM2 on our relay module.
  3. For the rest of the relay connections, we'll connect its NO2 to any pin on the 12V line using a male-male jumper. And we'll connect IN2 to any digital pin on our Tamra board where we'll send the signal to turn the fan on and off. For this step, we chose pin 4.
  4. For our window motion, we'll use the servo motor. It comes with 3 wires colored: red, orange, and brown. Its red wire is its VCC pin and we'll use a male-male jumper to connect it directly to a 5V pin on the line on the breadboard. Its brown wire indicates the GND pin and we'll use another male-male jumper to connect it directly to any GND pin on our breadboard. The orange wire is for the signal we'll send to the servo motor, so we'll connect it to any PWM pin on our Tamra board. We chose pin 5 for this step.
  5. The temperature sensor we're using is an LM35 and, like most sensors, it has 3 legs. When we're facing the flat side of the sensor, the left leg is the VCC leg and it works on the range between 3.5-5V, the right leg is the GND pin and the middle leg is the signal/output pin. After connecting our temperature sensor onto our breadboard, we'll use a male-male jumper to connect the VCC leg to the 5V line on the breadboard. And another male-male jumper to connect the GND pin to either GND line on the breadboard. Since we'll want to see the reading of the temperature on our application, we'll connect another male-male jumper between the sensor's signal leg and pin A0 on the Tamra board.
note

The sensor's reading is analogue which means we'll set our port mode to Analogue Input. The analogue value you can read on the application is not the actual room temperature. You can get the actual temperature by multiplying the value by the constant 0.48828125.

Air Conditioning System Smart Home

Step 5: testing our smart home

Now that all our connections are ready, it's time to power our smart home up and give it a try.

note

If you don't have a tamra account at this point, you should probably create an account to be able to keep going.

After inserting the adapter in your 220V outlet, you'll notice that Tamra's wifi appeared in your available wifi connections. On connecting to the Tamra IoT wifi, it should automatically open a window for you to enter your wifi credentials and the activation code necessary to activate your node. You can find this activation code when you open your Tamra application. Now, we'll now hop onto the application to try the project out.

The first thing we need to do is configure our node to our system by going through the following steps:

  1. We'll click on the burger menu at the upper left corner of the screen.
  2. Click on Connected Nodes.
  3. Press the Settings icon next to the New Node.
  4. Press on the Node Name box to change its name to the project name: Smart Home.
  5. Swipe the switches next to our used pins to activate their equivalent ports, change their names, and set their port modes according to the following list:
  • Port D2: LED Strip, Mode: Digital Output
  • Port D3: Security System, Mode: Digital Output
  • Port D4: Fan, Mode: Digital Output
  • Port D5: Window, Mode: Pulse Width Modulation Output
  • Port A0: Temperature Sensor, Mode: Analogue Input

Make sure to save your new settings from the Save Settings button at the end of the page.

note

If you're not sure which port mode to use, are confused about why we choose each mode, or don't know how to select the mode you want, you can find answers in Editing Port Settings.

App Smart Home