<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.phidgets.com/docs/index.php?action=history&amp;feed=atom&amp;title=Home_Automation_With_Phidgets</id>
	<title>Home Automation With Phidgets - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.phidgets.com/docs/index.php?action=history&amp;feed=atom&amp;title=Home_Automation_With_Phidgets"/>
	<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs/index.php?title=Home_Automation_With_Phidgets&amp;action=history"/>
	<updated>2026-05-05T09:41:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.phidgets.com/docs/index.php?title=Home_Automation_With_Phidgets&amp;diff=34006&amp;oldid=prev</id>
		<title>Lmpacent: Created page with &quot;Category: Project {{#seo:|keywords=phidget SBC, light, sound}} {{#seo:|description=Get started with home automation and Phidgets!}} thumb ==Introduction== This project will provide a basic introduction to home automation with Phidgets. Ambient light and sound information will be monitored, and users will be able to control a single light source through a w...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.phidgets.com/docs/index.php?title=Home_Automation_With_Phidgets&amp;diff=34006&amp;oldid=prev"/>
		<updated>2023-08-09T18:16:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/docs/index.php?title=Category:Project&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Project (page does not exist)&quot;&gt;Category: Project&lt;/a&gt; {{#seo:|keywords=phidget SBC, light, sound}} {{#seo:|description=Get started with home automation and Phidgets!}} &lt;a href=&quot;/docs/File:Homeautomation_title.jpg&quot; title=&quot;File:Homeautomation title.jpg&quot;&gt;400px|link=https://www.phidgets.com/docs/images/e/e1/Homeautomation_title.jpg|thumb&lt;/a&gt; ==Introduction== This project will provide a basic introduction to home automation with Phidgets. Ambient light and sound information will be monitored, and users will be able to control a single light source through a w...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category: Project]]&lt;br /&gt;
{{#seo:|keywords=phidget SBC, light, sound}}&lt;br /&gt;
{{#seo:|description=Get started with home automation and Phidgets!}}&lt;br /&gt;
[[Image:Homeautomation_title.jpg|400px|link=https://www.phidgets.com/docs/images/e/e1/Homeautomation_title.jpg|thumb]]&lt;br /&gt;
==Introduction==&lt;br /&gt;
This project will provide a basic introduction to home automation with Phidgets. Ambient light and sound information will be monitored, and users will be able to control a single light source through a web interface. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
==Parts==&lt;br /&gt;
[[Image:Homeautomation_sbc.jpg|link=https://www.phidgets.com/docs/images/8/86/Homeautomation_sbc.jpg|thumb|&amp;lt;center&amp;gt;The PhidgetSBC4 is used to control this project.&amp;lt;/center&amp;gt;]]&lt;br /&gt;
This project utilizes the following hardware:&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://www.phidgets.com/?tier=3&amp;amp;catid=1&amp;amp;pcid=0&amp;amp;prodid=969 Phidget SBC4 - SBC3003_0]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://www.phidgets.com/?tier=3&amp;amp;catid=97&amp;amp;pcid=77&amp;amp;prodid=1167 WiFi USB Adapter (RT5370) or a network cable]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://www.phidgets.com/?tier=3&amp;amp;catid=8&amp;amp;pcid=6&amp;amp;prodid=707 Light Phidget - LUX1000_0]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://www.phidgets.com/?tier=3&amp;amp;catid=8&amp;amp;pcid=6&amp;amp;prodid=972 Sound Phidget - SND1000_0]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://www.phidgets.com/?tier=3&amp;amp;catid=61&amp;amp;pcid=54&amp;amp;prodid=1142 Power Plug Phidget - PSU1000_0]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;[https://www.phidgets.com/?tier=2&amp;amp;catid=30&amp;amp;pcid=26 Phidget Cables]&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Assembly==&lt;br /&gt;
[[Image:Homeautomation_parts.jpg|link=https://www.phidgets.com/docs/images/b/ba/Homeautomation_parts.jpg|thumb|&amp;lt;center&amp;gt;For long-term installation, consider a more robust assembly.&amp;lt;/center&amp;gt;]]&lt;br /&gt;
For this basic demonstration, the sensors were simply adhered to an aluminum plate using a hook-and-loop style fastener. For a long-term installation, you may consider a more durable method.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
==Lighting Control==&lt;br /&gt;
[[Image:Homeautomation_powerplug.jpg|link=https://www.phidgets.com/docs/images/6/64/Homeautomation_powerplug.jpg|thumb|&amp;lt;center&amp;gt;A Power Plug Phidget.&amp;lt;/center&amp;gt;]]&lt;br /&gt;
In order to control a light source through a web interface, a Power Plug Phidget is utilized. This device makes it easy and safe to control a 120VAC appliance, like a lamp. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Software==&lt;br /&gt;
For this project, we will create a simple webpage that is hosted by the Phidget SBC4. Using the [https://www.phidgets.com/docs/Phidget_Network_Server Phidget Network Server] and the [https://www.phidgets.com/docs/Language_-_JavaScript Phidget22 JavaScript libraries], we will send commands to the Power Plug Phidget to remotely control a light. The interface will also provide information about ambient light and sound values.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Homeautomation_webinterface.jpg|500px|link=https://www.phidgets.com/docs/images/c/c3/Homeautomation_webinterface.jpg|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;i&amp;gt;The webpage that is hosted by the Phidget SBC4. It includes two labels to display the sound and light values, as well as a button to control the light source.&amp;lt;/i&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
===Configuration===&lt;br /&gt;
We will be using the Phidget Network Server to communicate with the DC Motor Phidgets connected to the Phidget SBC4. The Phidget Network Server can be enabled by navigating to &amp;#039;&amp;#039;&amp;#039;Phidgets &amp;gt; phidget22 Network Server&amp;#039;&amp;#039;&amp;#039;.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Murvv_networkserver.png|500px|link=https://www.phidgets.com/docs/images/6/6e/Murvv_networkserver.png|center]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
===Webpage Code===&lt;br /&gt;
We will create an HTML file at &amp;lt;strong&amp;gt;/var/www/&amp;lt;/strong&amp;gt; titled &amp;lt;/strong&amp;gt; &amp;lt;strong&amp;gt;homeautomation.html&amp;lt;/strong&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
====HTML Layout====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=html&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
	table {&lt;br /&gt;
		margin:auto;&lt;br /&gt;
		width:500px;&lt;br /&gt;
	}&lt;br /&gt;
	th, td {&lt;br /&gt;
		border-color:black;&lt;br /&gt;
		border-style:ridge;&lt;br /&gt;
		border-width:1px;&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Home Automation Example&amp;lt;/title&amp;gt;		&lt;br /&gt;
&amp;lt;body&amp;gt;	&lt;br /&gt;
	&amp;lt;h2 style=&amp;quot;text-align:center&amp;quot;&amp;gt;Sensors&amp;lt;/h2&amp;gt;&lt;br /&gt;
	&amp;lt;table style=&amp;quot;width:25%&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;tr&amp;gt;&lt;br /&gt;
			&amp;lt;th style=&amp;quot;width:35%&amp;quot;&amp;gt;Light&amp;lt;/th&amp;gt;&lt;br /&gt;
			&amp;lt;th id=&amp;quot;lightLabel&amp;quot;&amp;gt;&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;/tr&amp;gt;&lt;br /&gt;
		&amp;lt;tr&amp;gt;&lt;br /&gt;
			&amp;lt;th&amp;gt;Sound&amp;lt;/th&amp;gt;&lt;br /&gt;
			&amp;lt;th id=&amp;quot;soundLabel&amp;quot; style=&amp;quot;text-align:center&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;/table&amp;gt;			&lt;br /&gt;
	&amp;lt;h2 style=&amp;quot;	text-align:center&amp;quot;&amp;gt;Light Control&amp;lt;/h2&amp;gt;		&lt;br /&gt;
	&amp;lt;center&amp;gt;&amp;lt;button type=&amp;quot;button&amp;quot; id=&amp;quot;lightButton&amp;quot;&amp;gt;Turn Light On&amp;lt;/button&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====JavaScript====&lt;br /&gt;
This section of the code creates four DC Motor objects. Each object is mapped to a specific motor controller (and therefore, a specific motor) using &amp;#039;&amp;#039;&amp;#039;setHubPort&amp;#039;&amp;#039;&amp;#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=javascript&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://unpkg.com/phidget22@^3.10/browser/phidget22.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;		&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
async function runExample() {&lt;br /&gt;
	const conn = new phidget22.NetworkConnection(8080, &amp;#039;phidgetsbc&amp;#039;);&lt;br /&gt;
	await conn.connect();&lt;br /&gt;
	&lt;br /&gt;
	const lightSensor = new phidget22.LightSensor();&lt;br /&gt;
	const soundSensor = new phidget22.SoundSensor();&lt;br /&gt;
	const lightRelay = new phidget22.DigitalOutput();&lt;br /&gt;
	&lt;br /&gt;
	lightSensor.onIlluminanceChange = (illuminance) =&amp;gt; {&lt;br /&gt;
		document.getElementById(&amp;quot;lightLabel&amp;quot;).innerHTML = illuminance.toString()+&amp;quot; lx&amp;quot;;&lt;br /&gt;
	};&lt;br /&gt;
	soundSensor.onSPLChange = (SPL) =&amp;gt; {&lt;br /&gt;
		document.getElementById(&amp;quot;soundLabel&amp;quot;).innerHTML = SPL.toString()+&amp;quot; dB&amp;quot;;&lt;br /&gt;
	};&lt;br /&gt;
	&lt;br /&gt;
	lightRelay.setHubPort(0);&lt;br /&gt;
	lightRelay.setIsHubPortDevice(true);&lt;br /&gt;
	&lt;br /&gt;
	await lightSensor.open(5000);&lt;br /&gt;
	await soundSensor.open(5000);&lt;br /&gt;
	await lightRelay.open(5000);&lt;br /&gt;
	&lt;br /&gt;
	document.getElementById(&amp;quot;lightButton&amp;quot;).onclick = function() {&lt;br /&gt;
		lightRelay.setState(!lightRelay.getState());&lt;br /&gt;
		var lightString = lightRelay.getState() ? &amp;quot;Turn Light On&amp;quot; : &amp;quot;Turn Light Off&amp;quot;&lt;br /&gt;
		document.getElementById(&amp;quot;lightButton&amp;quot;).innerHTML = lightString;&lt;br /&gt;
    }    	&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
runExample();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
We now have a simple webpage that displays sound and light values, and a button to control a light source.&lt;br /&gt;
&lt;br /&gt;
===Going Forward===&lt;br /&gt;
To improve on this project, consider the following:&lt;br /&gt;
* Create a script that runs on the Phidget SBC4 and logs sound and light values to a file. Use the web interface to display the values on a graph. &lt;br /&gt;
* Use a Phidget Dictionary in your script to make live sound and light values available for your webpage.&lt;/div&gt;</summary>
		<author><name>Lmpacent</name></author>
	</entry>
</feed>