<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>latitude &#8211; About Things | A Hans Scharler Blog</title>
	<atom:link href="https://nothans.com/tag/latitude/feed" rel="self" type="application/rss+xml" />
	<link>https://nothans.com</link>
	<description>Life, Comedy, Games, Tech, Marketing, and Community</description>
	<lastBuildDate>Thu, 25 Aug 2022 14:15:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/nothans.com/wp-content/uploads/2023/02/cropped-settings.png?fit=32%2C32&#038;ssl=1</url>
	<title>latitude &#8211; About Things | A Hans Scharler Blog</title>
	<link>https://nothans.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">114568856</site>	<item>
		<title>Automatic Thermostat Control Based on Location and Weather</title>
		<link>https://nothans.com/automatic-thermostat-control-based-on-location</link>
					<comments>https://nothans.com/automatic-thermostat-control-based-on-location#respond</comments>
		
		<dc:creator><![CDATA[Hans Scharler]]></dc:creator>
		<pubDate>Tue, 14 Sep 2010 09:56:00 +0000</pubDate>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[ThingSpeak]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[home automation]]></category>
		<category><![CDATA[internet of things]]></category>
		<category><![CDATA[ioBridge]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[projects]]></category>
		<guid isPermaLink="false">http://nothans.com/automatic-thermostat-control-based-on-location</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<p>The&nbsp;<a title="Pittsburgh Perl Workshop 2010" href="http://pghpw.org/ppw2010/" target="_blank" rel="noopener noreferrer">Pittsburgh Perl Workshop</a> will be held at the Carnegie Mellon University on October 9-10, 2010. The PPW is a gathering of <a title="Perl Wiki" href="http://en.wikipedia.org/wiki/Perl" target="_blank" rel="noopener noreferrer">Perl</a> programmers from around the world (and near Pittsburgh) to learn more and discuss the future of Perl.</p>
<p>At this year’s PPW, I will be giving a talk called, “<strong><em>Connecting the Internet of Things with Perl</em></strong>“ (visit <a title="Pittsburgh Perl Conference Schedule for Internet of Things talk by Hans Scharler" href="http://pghpw.org/ppw2010/talk/3043" target="_blank" rel="noopener noreferrer">pghpw.org</a> for&nbsp;schedule&nbsp;info). I will also explain how to create an Internet of Things application using off-the-shelf&nbsp;Perl modules and web control technology by <a title="ioBridge Technology" href="http://www.iobridge.com/technology" target="_blank" rel="noopener noreferrer">ioBridge</a>.</p>
<p>As you may or may not know, Perl is a really powerful programming language that enables everything from fast&nbsp;prototyping&nbsp;of web applications to large-scale software platforms. What makes the language unique is the library of modules&nbsp;available&nbsp;to you. If you get a great new idea for a web app, you can get started quickly and find modules that others have written. In some cases, it’s literally copy-and-paste.</p>
<p>A big movement for the past few years is this concept of The Internet of Things. More things will be on the Internet than people in the next few years, so my talk is to highlight why Perl is still relevant after 20 years and needs to be apart of this emerging technology. Internet of Things applications involve connecting sensors and controllers to the web. Perl is perfect for parsing lots of data, pushing data into databases, and connecting services together, known as “mashups”.</p>
<p>My Internet of&nbsp;Things&nbsp;project, written in Perl, allows your current location&nbsp;and home weather conditions to control your home heating and cooling system.</p>
<p><img data-recalc-dims="1" fetchpriority="high" decoding="async" data-attachment-id="253" data-permalink="https://nothans.com/automatic-thermostat-control-based-on-location/google-latitude-iobridge-mashup-3" data-orig-file="https://i0.wp.com/nothans.com/wp-content/uploads/2010/09/Google-Latitude-ioBridge-Mashup2.jpg?fit=550%2C433&amp;ssl=1" data-orig-size="550,433" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Location Aware Home Automation" data-image-description="" data-image-caption="&lt;p&gt;Location Aware Home Automation&lt;/p&gt;
" data-medium-file="https://i0.wp.com/nothans.com/wp-content/uploads/2010/09/Google-Latitude-ioBridge-Mashup2.jpg?fit=300%2C236&amp;ssl=1" data-large-file="https://i0.wp.com/nothans.com/wp-content/uploads/2010/09/Google-Latitude-ioBridge-Mashup2.jpg?fit=550%2C433&amp;ssl=1" class="aligncenter wp-image-253 size-full" src="https://i0.wp.com/nothans.com/wp-content/uploads/2010/09/Google-Latitude-ioBridge-Mashup2.jpg?resize=550%2C433" alt="Location Aware Home Automation using Google Latitude API and ioBridge API" width="550" height="433" srcset="https://i0.wp.com/nothans.com/wp-content/uploads/2010/09/Google-Latitude-ioBridge-Mashup2.jpg?w=550&amp;ssl=1 550w, https://i0.wp.com/nothans.com/wp-content/uploads/2010/09/Google-Latitude-ioBridge-Mashup2.jpg?resize=300%2C236&amp;ssl=1 300w" sizes="(max-width: 550px) 100vw, 550px" /></p>
<p>I call it, &nbsp;”Location Aware Home Automation”. You don’t have to do anything to control your HVAC/Thermostat, it all happens based on where you are. If you are home, the thermostat regulates the inside temperature as normal. When you leave, systems turn off or enter power saving modes. When you get near your home, the heating/cooling system kicks back on so you have a comfortable temperature by the time you get back home. In order to pull off all of this passive and automatic functionality, I have mashed up several APIs from Google&nbsp;Latitude, WeatherBug, and ioBridge.</p>
<p>Using the API for Google&nbsp;Latitude, I track the location of my Android mobile phone. When I get near my home, I check the weather using Google Weather API, WeatherBug API, and my home&nbsp;temperature&nbsp;(via ioBridge) to see if I need to to use the air conditioner, the heater, or neither. If I do need to control the HVAC, I send the control commands using the ioBridge API that routes the commands to the IO-204 controller that’s hooked up to my thermostat.</p>
<p>This application is really just a beginning. Right after I got everything working, I started having a flood of ideas. I can see some real power here.</p>
<h2>The &#8216;How To&#8217; Portion of the Show</h2>
<h3>Google Latitude</h3>
<p>You have to enable Google Latitude on your mobile phone and get your Badge ID. This ID represents your position in the world, your latitude and longitude. Visit the <a title="Google Latitude API and Badge ID" href="http://www.google.com/latitude/apps/badge" target="_blank" rel="noopener noreferrer">Google Latitude API</a> site for more information.</p>
<p>Install the latest <a title="Google Latitude Perl Module" href="http://search.cpan.org/~mrdvt/Geo-Google-Latitude-0.06/lib/Geo/Google/Latitude.pm" target="_blank" rel="noopener noreferrer">Geo::Google::Latitude</a> Perl module from CPAN.org &#8211; this module completely abstracts the access to the Google Latitude API for you. All you have to do us pass your ID and the module returns the date, time, last known latitude and longitude (the values are in decimal degrees).</p>
<p><code>use Geo::Google::Latitude;<br />
my $gl=Geo::Google::Latitude-&gt;new;<br />
my $id="7832225593622256926";<br />
my $badge=$gl-&gt;get($id);<br />
my ($lat2, $lon2) = $badge-&gt;point-&gt;latlon;</code></p>
<h3>Calculating how far you are away &nbsp;from home</h3>
<p>You have to figure out how far you are from home, you do this by doing some math. Oh wait, there’s a Perl module for that. Install <a title="Geo::Distance Perl Module on CPAN used to calculate distance between positions" href="http://search.cpan.org/~bluefeet/Geo-Distance-0.16/lib/Geo/Distance.pm" target="_blank" rel="noopener noreferrer">Geo::Distance</a> and all you have to do is tell it what latitude and longitude to compare and it spits out the distance.</p>
<p><code>use Geo::Distance;<br />
my $geo = new Geo::Distance;<br />
### Home Location<br />
my $lon1 = "-79.76408";<br />
my $lat1 = "39.980342";<br />
### Calculated Distance<br />
my $distance = $geo-&gt;distance( 'mile', $lon1, $lat1 =&gt;; $lon2, $lat2 ); # Use 'meter' to calculate distance in meters</code></p>
<h3>Getting the Weather</h3>
<p>You can use a number of weather APIs to get weather data for your home location. All you need to know is where you live. The easiest to implement is Google Weather (<a title="Google Weather API" href="http://search.cpan.org/~possum/Weather-Google-0.05/lib/Weather/Google.pm" target="_blank" rel="noopener noreferrer">Weather::Google</a>), but the WeatherBug API has a lot more information you can use for other Internet of Things things you may do.</p>
<p><code> use Weather::Google;<br />
my $gw = new Weather::Google(15401); # Zipcode<br />
my $current_outside = $gw-&gt;current-&gt;{temp_f}; #Use temp_c for Celsius</code></p>
<h3>Connect to ioBridge</h3>
<p>All you have to do to connect with ioBridge is to send command via the <a title="ioBridge Widget API" href="http://www.iobridge.net/wiki/api/static-widget-api" target="_blank" rel="noopener noreferrer">ioBridge Widget API</a>. First you create the control widgets for your heating and cooling system. For mine, I can use relays. Others may need serial strings, which you can send as well. Once you have the widgets created, locate there widget ID’s and send them to the API.<br />
<code><br />
use LWP::Simple;<br />
my $Air_Conditioner_widgetID = "Gb2Q1FUKPmzZ"; ### Replace with your widget ID's<br />
my $Heater_widgetID = "9c3WEGHKemnzJ";<br />
my $Inside_Temp_widgetID = "D32SDghy98iOu";<br />
my $ioBridgeAPI = "";<br />
$ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Inside_Temp_widgetID . "&amp;value=1&amp;format=text";<br />
my $current_inside = get($ioBridgeAPI);<br />
### Test if the heater or the air condition should be turned on<br />
if ($current_outside &gt;= 78 &amp;&amp; $current_inside &gt;= 72) {<br />
$ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Air_Conditioner_widgetID . "&amp;value=1&amp;format=text";<br />
get($ioBridgeAPI);<br />
}<br />
elsif ($current_outside $ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Heater_widgetID . "&amp;value=1&amp;format=text";<br />
get("$ioBridgeAPI");<br />
}</code></p>
<h3>Putting it all together</h3>
<p>Once you have the&nbsp;entire&nbsp;built all you have to do is call the app periodically using CRON Linux or Task Scheduler on Windows. Here is a <a href="http://iamshadowlord.com/LocationAwareAutomation.txt" target="_blank" rel="noopener noreferrer">TXT file</a> of the Perl application with all of the parts tied together, probably will be easier to read and understand.</p>
<p>The hardware side uses the <a title="ioBridge IO-204 Internet Monitor and Control Module" href="http://www.iobridge.com" target="_blank" rel="noopener noreferrer">ioBridge IO-204</a> connected to the control lines of a&nbsp;<a title="Remotely enabling and disabling a thermostat" href="http://www.thomaswlewis.com/?p=567" target="_blank" rel="noopener noreferrer">thermostat</a> or an HVAC control box. The lines switch at 12 volts, so I use relays trigger them. Other thermostats&nbsp;that I researched use serial lines which the IO-204 can tap into using RS-232.</p>
<p>It may seem like a lot of work, but just think about what is happening. Feeds from Google&nbsp;Latitude&nbsp;and WeatherBug are being processed and passed to your home network via the Internet. All of this is happening without your direct interaction &#8211; your things are working for you. I hope that you can see that is a start of some pretty amazing applications of technologies that will advance over time. A lot has changed in the past year, I can’t image what comes next.</p>
<p>If you get around to building a project like this, please drop me a line. I love this stuff.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nothans.com/automatic-thermostat-control-based-on-location/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">676</post-id>	</item>
	</channel>
</rss>
