<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>nightlight &#8211; Squix &#8211; TechBlog</title>
	<atom:link href="https://blog.squix.org/tag/nightlight/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.squix.org</link>
	<description></description>
	<lastBuildDate>Tue, 13 Dec 2016 20:28:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.8</generator>
<site xmlns="com-wordpress:feed-additions:1">121913304</site>	<item>
		<title>ESP8266: Internet connected baby nightlight for less than $10</title>
		<link>https://blog.squix.org/2014/12/esp8266-internet-connected-baby.html</link>
					<comments>https://blog.squix.org/2014/12/esp8266-internet-connected-baby.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sun, 28 Dec 2014 11:39:00 +0000</pubDate>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[esplorer]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[nightlight]]></category>
		<category><![CDATA[nodemcu]]></category>
		<category><![CDATA[time client]]></category>
		<guid isPermaLink="false">http://blog.squix.org/2014/12/28/esp8266-internet-connected-baby/</guid>

					<description><![CDATA[A while ago a wanted to build one of those nightlights for my daughter that tell her when to sleep and when to call for the parents: an orange light behind a sun depicts the day, a blue light behind a moon the night. My ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2014/12/esp8266-internet-connected-baby.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
<a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2014/12/IMG_4772-1024x768.jpg?ssl=1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img data-recalc-dims="1" fetchpriority="high" decoding="async" border="0" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2014/12/IMG_4772.jpg?resize=320%2C240&#038;ssl=1" height="240" width="320" /></a></div>
<p>
A while ago a wanted to build one of those nightlights for my daughter that tell her when to sleep and when to call for the parents: an orange light behind a sun depicts the day, a blue light behind a moon the night. My first attempt was based on a Spark Core which is a bit pricy (~$40) to just connect to the internet to synchronise the time.<br />
Playing with the ESP8266 I needed an actual project to use it and the nightlight came in handy. It uses both GPIO pins available on the ESP8266-ESP01 and calls google.com to synchronise the time every 30 minutes as soon as the device is connected to the access point. I currently still need an Arduino but just as power source and debugging tool. So the actual components are:</p>
<ul style="text-align: left;">
<li>plastic box (from food delivery)</li>
<li>black paper as mask</li>
<li>sun and moon downloaded and printed from the internet</li>
<li>cardboard from a cereal box to shield the LEDs</li>
<li>2 LEDs (orange and blue)</li>
<li>a mini bread board</li>
<li>an ESP8266</li>
<li>2 resistors</li>
<li>some jumper wires</li>
</ul>
<p><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2014/12/IMG_5207-1024x768.jpg?ssl=1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img data-recalc-dims="1" decoding="async" border="0" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2014/12/IMG_5207.jpg?resize=320%2C240&#038;ssl=1" height="240" width="320" /></a></p>
<h3 style="text-align: left;">
Prepare the ESP8266</h3>
<div>
First you need to put the LUA firmware from nodemcu on the ESP8266. I described <a href="https://blog.squix.org/2014/12/esp8266-flashing-lua-firmware-and.html">in this post</a>&nbsp;how it is done. Once this is done you can use the <a href="http://esp8266.ru/esplorer/">Esplorer</a>&nbsp;to transfer lua files to the ESP8266.</div>
<div>
</div>
<h3 style="text-align: left;">
Check out the code and adapt it</h3>
<div>
Checkout the two lua files from <a href="https://github.com/squix78/ESP8266-lua-nightlight">here</a>&nbsp;and adapt them to your needs. Especially your access point and credentials need to be set in the init.lua file. If you&#8217;re not living in the GMT+1 timezone you&#8217;ll also need to adapt your offset in the nightlight.lua script. In the current version the day/night phases can only be set within the code, but this might change in the future. There is a lightweight webserver available for the lua firmware which might allow setting the time through a web browser.</div>
<div>
</div>
<h3 style="text-align: left;">
Transfer the files to the ESP8266</h3>
<div>
The current version of the firmware crashes and restarts the unit if you try to call the dofile function for a non-existing file. Since the init.lua scripts calls the nightlight.lua script transfer them in the appropriate order (first nightlight, then init). Note: I had some cases where the module would connect to the AP and receive an IP but would further fail to call the google server to get the time. This only happened after clean updates of the firmware and disappeared after a short while.</div>
<div>
</div>
<h3 style="text-align: left;">
Sources</h3>
<div>
<ul style="text-align: left;">
<li><a href="https://github.com/nodemcu/nodemcu-firmware">Lua firmware</a></li>
<li><a href="http://esp8266.ru/esplorer/">Esplorer (ESP8266 IDE)</a></li>
<li><a href="http://www.esp8266.com/viewtopic.php?f=19&amp;t=809">ESP8266 example for google time client</a>&nbsp;(thanks to GeoNomad)</li>
</ul>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2014/12/esp8266-internet-connected-baby.html/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">73</post-id>	</item>
	</channel>
</rss>
