Top Logo Sp Logo
An easy start to Smart Home

An easy start to Smart Home

An easy start to Smart Home

 By: Timor Altinok

Today I will be showing you how I started my first Smart Home project.


In the beginning, I had some problems with materials. I started without mapping out a plan and tried to create my first prototype out of cardboard. Planning and thinking about possible workarounds for upcoming issues helped me organize and achieve my goals.

 

So I will show you a step-by-step guide about how I build my latest prototype, to remotely control my pleats.

PROJECT OVERVIEW


As mentioned before, I built a Smart Home by myself from scratch. I started with something I could use daily, and which could save me a lot of time. So I created my own device to control my blinds.


STEPS


What you’ll need:

  1. Wood (in my case chipboard)
  2. Stepper Motor
  3. ULN2003 Stepper Motor Driver Module
  4. Arduino Board (in my case MEGA 2560)
  5. Breadboard 
  6. Power Supply Module 
  7. Raspberry Pi (in my case 4)

Step 1


Your first step is to build a gear out of wood, to pull the cord of the pleats, moving them up and down. You should use wood or some other sturdy material because it will have to hold the pressure of the motor. Next you must glue one wooden circle from either side to the gear, so the cord will not slip out of the gear while pulling it down. After this you can build a wooden frame, with a hole in it, so the motor has a stabilized position. 


Step 2

In the second step you can put the Stepper Motor onto the wooden frame. Then you will have to find something hard enough, to combine the wheel with the motor, because it has a lot of power. I took a bottle cap, made a hole in it  and glued it onto the wheel. If you are done with that, you can put the bottle cap construction onto the motor. 

Step 3

For the third step you have to connect the driver module with the Stepper Motor. If this is done you have to connect the driver module to the Arduino Board. For that you connect the 1N1 with PIN 11, the 1N2 with PIN 10, the 1N3 with PIN 9 and the 1N4 with PIN 8. Then you can put the power supply module onto the breadboard. After that you are going to connect the GND PIN of the Arduino Board and the two other pins of the driver module with the breadboard as shown in the picture. 


Step 4


Step 4 is to build up a serial connection between your Arduino Board and the Raspberry Pi. 

For that, enable Serial and I2C in the Pi Configuration and after that you need to restart your Raspberry Pi.

Lastly, install the serial python library like this: 


sudo apt-get install python-serial

sudo pip install pyserial

Then start connecting and disconnecting the Arduino Board from the Raspberry Pi, to check the port:

ls /dev/tty*

Find a port called “/dev/tty/ACM0”. In some cases, you will find the port with other numbers than “0”, so you have to adjust the following code. If you need help in this step check here.


Step 5


In this step you must upload the code to your Arduino Board. To do that, you have to connect the Arduino to your computer and use the Arduino IDE for coding: 


#include <Stepper.h>


const int stepsPerRevolution = 2048;  

const int rolePerMinute = 10;        


Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);


void setup() {

myStepper.setSpeed(rolePerMinute);

Serial.begin(9600);

}


String RecentInput = "";


void loop() {

if (Serial.available() > 0) {

  String IncomingInput = Serial.readString();

  RecentInput = IncomingInput;

  }

if (RecentInput == "ROLL UP!"){

  Serial.println("clockwise");

  myStepper.step(stepsPerRevolution);

}

if (RecentInput == "ROLL DOWN!") {

  Serial.println("counterclockwise");

  myStepper.step(-stepsPerRevolution);

}


}


If it’s properly connected to your computer you can upload the code to your Arduino Board.

Step 6


Now you can create the python file on the Raspberry Pi. I created an interface with 3 buttons, so you can click on the buttons to roll it up or down:  


from graphics import *

import serial


ser=serial.Serial("/dev/ttyACM0",9600)

ser.baudrate=9600


win = GraphWin("Motor HUD", 500, 350)

sq1 = Rectangle(Point(50,50),Point(450,100))

sq2 = Rectangle(Point(50,150),Point(450,200))

sq3 = Rectangle(Point(50,250),Point(450,300))


def setContainers():


    sq1.setFill('Gray')

    

    sq1.draw(win)

    sq1Text = Text(Point(250,75),'Roll UP')

    sq1Text.draw(win)

    

    sq2.setFill('Gray')

    sq2.draw(win)

    

    sq2Text = Text(Point(250,175),'Roll Down')

    sq2Text.draw(win)

    

    sq3.setFill('Red')

    sq3.draw(win)

    

    sq3Text = Text(Point(250,275),'STOP')

    sq3Text.draw(win)



def resetColor(pressedButton):

    sq1.setFill('Gray')

    sq2.setFill('Gray')

    if (pressedButton == sq1):

        sq1.setFill('LightGreen')

    elif (pressedButton == sq2):

        sq2.setFill('LightGreen')


def checkContainerClick(PositionOfMouse):

    print(PositionOfMouse)

    if (50 <= PositionOfMouse.x <= 450 and 50 <= PositionOfMouse.y <= 100):

        resetColor(sq1)

        ser.write('ROLL UP!')

        print('ROLL UP!')

    elif (150 <= PositionOfMouse.x <= 450 and 50 <= PositionOfMouse.y <= 200):

        resetColor(sq2)

        ser.write('ROLL DOWN!')

        print('ROLL DOWN!')

    elif(250 <= PositionOfMouse.x <= 450 and 50 <= PositionOfMouse.y <= 300):

        resetColor(sq3)

        ser.write('STOPP ROLL!')

        print('STOPP ROLL!')

        

if __name__ == '__main__':

    setContainers()

    while True:

        mousePosition = win.getMouse()

        checkContainerClick(mousePosition)


As mentioned before, you may have to change the serial port number.


Step 7

 

At this point the first project is finished. You can now connect the Arduino to the Raspberry Pi and run the python program. In my case I also used a touchscreen monitor, so I can build a Smart Home interface as a future project soon.


CONCLUSION


As you saw in this guide, you can build a small Smart Home by yourself, without having much knowledge. 


This was my first project, and I will continue to work on it and optimize it, so let me know if you have any questions or suggestions.


If you want to follow my progress, I document everything I do on TikTok. You can find me there under timors_project_journey.

Comments

  • Very interesting and informative. I really liked the way you explained everything so easy, so that even someone like me without any knowledge can follow. Keep up the good work!

    Pan Baer on

Leave a comment

* Required fields

Please note: comments must be approved before they are published.