Stephen Morss
Published © MIT

Blynk Home Automation System

Build a home automation system with a Blynk user interface, an alarm system, dimmable lights, timers, and remote controlled appliances.

IntermediateProtip4 hours3,139
Blynk Home Automation System

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
SparkFun Blynk Board - ESP8266
SparkFun Blynk Board - ESP8266
PowerSwitch Tail II
INSTEON 2413U PowerLinc USB Modem
INSTEON On/Off Module
INSTEON Motion Sensor
INSTEON Mini Remote Switch
Samsung SmartCam Plus 1080p

Software apps and online services

Virtual Wiring


Read more


Wires Page - Completed System

All wires


Blynk Home Automation System Script (Scripts/user/home_automation.script)

Here is the Script we created which builds our Blynk enabled home automation system. Some of the values (INSTEON addresses, email addresses and passwords, cell phone address, Blynk authorization tokens, timer longitude and latitude) will need customization to run on another system.

We've added spacing and comments (text strings that begin with a '#') to make the Script easier (for humans) to read. These will all be ignored by the Virtual Wiring system, so this can be your final, runnable script.
# add our INSTEON Devices
run_script("Scripts/Device/INSTEON/Modem2413", id:"modem", port_location:"/dev/ttyUSB0")
run_script("Scripts/Device/INSTEON/OnOffModule", address:"36.65.CC", id:"camera_power", port_location:nil)
run_script("Scripts/Device/INSTEON/LEDBulb", address:"20.27.EE", id:"timed_light", port_location:nil)
run_script("Scripts/Device/INSTEON/LEDBulb", address:"20.2A.EA", id:"remote_light", port_location:nil)
run_script("Scripts/Device/INSTEON/MotionSensor", address:"37.C3.67", id:"motion_sensor", port_location:nil)
run_script("Scripts/Device/INSTEON/MiniRemoteSwitch", address:"3E.BB.DB", id:"alarm_switch", port_location:nil)

# add our Blynk interface device (Hardware) and bridge to our Blynk Board
run_script("Scripts/Device/Blynk/Hardware", host_name:"", id:"blynk_app", port:nil, push_events:true, ssl:true, terminal_names:"D0, V0, D1, V1, V2, D2", token:"blynk interface token goes here")
run_script("Scripts/Device/Blynk/Bridge", channel:"V32", hardware_token:nil, id:"blynk_board", poll_interval:nil, terminal_names:"D5", token:"blynk board token goes here")

# add our messaging Device
run_script("Scripts/Device/EMail/TextMessagingPOP", email_address:"cell phone address goes here", gmail_polling:nil, host:"", id:"alarm_mailer", mail_subject:"Alarm Message", password:"your password", poll_interval:300, smtp_host:"", smtp_port:587, ssl_enable:true, user_name:"")

# set up our Alarm Device
run_script("Scripts/Device/Virtual/Alarm/Alarm", duration:60, id:"alarm", real_time:false)
run_script("Scripts/Device/Virtual/Alarm/InputTypes/Equal", alarm_id:"alarm", input_name:"motion", value:"on")
run_script("", text:"disable_alarm_messages()", on_device:"alarm")

# create a State Machine for filtering alarm messages
run_script("Scripts/Device/Virtual/StateMachine", file_name:"Scripts/user/alarm_filter.yaml", id:"alarm_filter", table_name:"")

# Mappers for changing on/offs to 0-255 values for Blynk LEDs
run_script("Scripts/Device/Virtual/Mapper", from:"on, off", function:nil, id:"alarm_enabled_mapper", to:"255, 0")
run_script("Scripts/Device/Virtual/Mapper", from:"on, off", function:nil, id:"timed_light_mapper", to:"255, 0")

# our timer
run_script("Scripts/Device/Virtual/TimerSunInterval", days:"", id:"timer", intervals:"sunset - 20 to 23:00", latitude:40.71, longitude:-74.00, weekdays:"")

# Inverter for changing the Blynk signal to the one the Blynk Board and PowerSwitch use
run_script("Scripts/Device/Virtual/Logic/Combinational/Inverter", id:"outlet_inverter", inputs:"1", outputs:"1S")

# Wires

# alarm system
wire("alarm_mailer:out", "alarm:command")
wire("alarm_switch:1S", "alarm:command")
wire("alarm:input_status", "alarm_filter:status")
wire("alarm:messages", "alarm_mailer:in")
wire("alarm:enabled", "alarm_enabled_mapper:in")
wire("alarm:enabled", "alarm_filter:enabled")
wire("alarm:enabled", "camera_power:1")
wire("alarm_filter:message", "alarm_mailer:in")
wire("motion_sensor:1S", "alarm:motion")

# wires to connect up the Blynk interface and Board
wire("alarm_enabled_mapper:out", "blynk_app:V0")
wire("blynk_app:D0", "alarm:command")
wire("blynk_app:D1", "timed_light:1")
wire("timed_light:1S", "timed_light_mapper:in")
wire("timed_light_mapper:out", "blynk_app:V1")
wire("blynk_app:D2", "outlet_inverter:1")
wire("outlet_inverter:1S", "blynk_board:D5")
wire("blynk_app:V2", "remote_light:1")

# connect the timer to the light bulb
wire("timer:out", "timed_light:1")


Stephen Morss

Stephen Morss

1 project • 0 followers


Add projectSign up / Login