Site updated at 2015-10-29 07:09:11 UTC

This commit is contained in:
Paulus Schoutsen 2015-10-29 00:09:11 -07:00
parent 7412a60701
commit b260f2881e
362 changed files with 42053 additions and 256343 deletions

View file

@ -4,7 +4,7 @@
<title><![CDATA[Category: esp8266 | Home Assistant]]></title>
<link href="https://home-assistant.io/blog/categories/esp8266/atom.xml" rel="self"/>
<link href="https://home-assistant.io/"/>
<updated>2015-10-27T12:45:27-07:00</updated>
<updated>2015-10-29T00:08:34-07:00</updated>
<id>https://home-assistant.io/</id>
<author>
<name><![CDATA[Paulus Schoutsen]]></name>
@ -18,250 +18,364 @@
<link href="https://home-assistant.io/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt/"/>
<updated>2015-10-11T12:10:00-07:00</updated>
<id>https://home-assistant.io/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt</id>
<content type="html"><![CDATA[<p>I recently learned about the ESP8266, a $5 chip that includes WiFi and is Arduino compatible. This means
that all your DIY projects can now be done for a fraction of the price.</p>
<content type="html"><![CDATA[
<p>I recently learned about the ESP8266, a $5 chip that includes WiFi and is Arduino compatible. This means that all your DIY projects can now be done for a fraction of the price.</p>
<p>For this tutorial, I&rsquo;ll walk through how to get going with ESP8266, get the temperature and humidity and
report it to MQTT where Home Asssistant can pick it up.</p>
<p>For this tutorial, Ill walk through how to get going with ESP8266, get the temperature and humidity and report it to MQTT where Home Asssistant can pick it up.</p>
<p class='img'>
<img src='https://home-assistant.io/images/blog/2015-10-esp8266-temp/setup.png' />
<p class="img">
<img src="https://home-assistant.io/images/blog/2015-10-esp8266-temp/setup.png" />
Picture of the final setup (+ 2 LED for decoration)
</p>
<p class='img'>
<img src='https://home-assistant.io/images/blog/2015-10-esp8266-temp/ha-sensor.png' />
<p class="img">
<img src="https://home-assistant.io/images/blog/2015-10-esp8266-temp/ha-sensor.png" />
Home Assistant will keep track of historical values and allow you to integrate it into automation.
</p>
<!--more-->
<h3>Components</h3>
<p>I&rsquo;ve been using Adafruit for my shopping:</p>
<p>Ive been using Adafruit for my shopping:</p>
<ul>
<li><a href="http://www.adafruit.com/product/2471">Adafruit HUZZAH ESP8266 Breakout</a> (<a href="https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/assembly">assembly instructions</a>)</li>
<li><a href="http://www.adafruit.com/product/2635">Adafruit HDC1008 Temperature &amp; Humidity Sensor Breakout Board</a> (<a href="https://learn.adafruit.com/adafruit-hdc1008-temperature-and-humidity-sensor-breakout/assembly">assembly instructions</a>)</li>
<li><a href="/components/mqtt.html#picking-a-broker">MQTT server</a></li>
<li><a href="http://www.adafruit.com/product/2471">Adafruit HUZZAH ESP8266 Breakout</a> (<a href="https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/assembly">assembly instructions</a>)</li>
<li><a href="http://www.adafruit.com/product/2635">Adafruit HDC1008 Temperature &amp; Humidity Sensor Breakout Board</a> (<a href="https://learn.adafruit.com/adafruit-hdc1008-temperature-and-humidity-sensor-breakout/assembly">assembly instructions</a>)</li>
<li><a href="/components/mqtt/#picking-a-broker">MQTT server</a></li>
</ul>
<p><em>Besides this, you will need the usual hardware prototype equipment: a breadboard, some wires,
soldering iron + wire, Serial USB cable.</em></p>
<p><em>Besides this, you will need the usual hardware prototype equipment: a breadboard, some wires, soldering iron + wire, Serial USB cable.</em></p>
<h3>Connections</h3>
<p>On your breadboard, make the following connections from your ESP8266 to the HDC1008:</p>
<table>
<thead>
<tr>
<th> ESP8266 </th>
<th> HDC1008 </th>
</tr>
</thead>
<tbody>
<tr>
<td> GND </td>
<td> GND</td>
</tr>
<tr>
<td> 3V </td>
<td> Vin</td>
</tr>
<tr>
<td> 14 </td>
<td> SCL</td>
</tr>
<tr>
<td> #2 </td>
<td> SDA</td>
</tr>
</tbody>
<thead>
<tr>
<th>ESP8266</th>
<th>HDC1008</th>
</tr>
</thead>
<tbody>
<tr>
<td>GND</td>
<td>GND</td>
</tr>
<tr>
<td>3V</td>
<td>Vin</td>
</tr>
<tr>
<td>14</td>
<td>SCL</td>
</tr>
<tr>
<td>#2</td>
<td>SDA</td>
</tr>
</tbody>
</table>
<p><em>I picked <code>#2</code> and <code>14</code> myself, you can configure them in the sketch.</em></p>
<h3>Preparing your IDE</h3>
<p>Follow <a href="https://github.com/esp8266/Arduino#installing-with-boards-manager">these instructions</a> on how
to install and prepare the Arduino IDE for ESP8266 development.</p>
<p>Follow <a href="https://github.com/esp8266/Arduino#installing-with-boards-manager">these instructions</a> on how to install and prepare the Arduino IDE for ESP8266 development.</p>
<p>After you&rsquo;re done installing, open the Arduino IDE, in the menu click on <code>sketch</code> -> <code>include library</code> ->
<code>manage libraries</code> and install the following libraries:</p>
<p>After youre done installing, open the Arduino IDE, in the menu click on <code>sketch</code> -&gt; <code>include library</code> -&gt; <code>manage libraries</code> and install the following libraries:</p>
<ul>
<li>PubSubClient by Nick &lsquo;O Leary</li>
<li>Adafruit HDC1000</li>
<li>PubSubClient by Nick O Leary</li>
<li>Adafruit HDC1000</li>
</ul>
<h3>Sketch</h3>
<p>If you have followed the previous steps, you&rsquo;re all set.</p>
<p>If you have followed the previous steps, youre all set.</p>
<ul>
<li>Open Arduino IDE and create a new sketch (<code>File</code> -> <code>New</code>)</li>
<li>Copy and paste the below sketch to the Arduino IDE</li>
<li>Adjust the values line 6 - 14 to match your setup</li>
<li>Optional: If you want to connect to an MQTT server without a username or password, adjust line 63.</li>
<li>To have the ESP8266 accept our new sketch, we have to put it in upload mode. On the ESP8266 device
keep the GPIO0 button pressed while pressing the reset button. The red led will glow half bright to
indicate it is in upload mode.</li>
<li>Press the upload button in Arduino IDE</li>
<li>Open the serial monitor (<code>Tools</code> -> <code>Serial Monitor</code>) to see the output from your device</li>
<li>Open Arduino IDE and create a new sketch (<code>File</code> -&gt; <code>New</code>)</li>
<li>Copy and paste the below sketch to the Arduino IDE</li>
<li>Adjust the values line 6 - 14 to match your setup</li>
<li>Optional: If you want to connect to an MQTT server without a username or password, adjust line 63.</li>
<li>To have the ESP8266 accept our new sketch, we have to put it in upload mode. On the ESP8266 device keep the GPIO0 button pressed while pressing the reset button. The red led will glow half bright to indicate it is in upload mode.</li>
<li>Press the upload button in Arduino IDE</li>
<li>Open the serial monitor (<code>Tools</code> -&gt; <code>Serial Monitor</code>) to see the output from your device</li>
</ul>
<p>This sketch will connect to your WiFi network and MQTT broker. It will read the temperature and humidity from the sensor every second. It will report it to the MQTT server if the difference is &gt; 1 since last reported value. Reports to the MQTT broker are sent with retain set to <code>True</code>. This means that anyone connecting to the MQTT topic will automatically be notified of the last reported value.</p>
<p>This sketch will connect to your WiFi network and MQTT broker. It will read the temperature and humidity
from the sensor every second. It will report it to the MQTT server if the difference is > 1 since last
reported value. Reports to the MQTT broker are sent with retain set to <code>True</code>. This means that anyone
connecting to the MQTT topic will automatically be notified of the last reported value.</p>
<div class="highlighter-coderay"><table class="CodeRay"><tr>
<td class="line-numbers"><pre><a href="#n1" name="n1">1</a>
<a href="#n2" name="n2">2</a>
<a href="#n3" name="n3">3</a>
<a href="#n4" name="n4">4</a>
<a href="#n5" name="n5">5</a>
<a href="#n6" name="n6">6</a>
<a href="#n7" name="n7">7</a>
<a href="#n8" name="n8">8</a>
<a href="#n9" name="n9">9</a>
<strong><a href="#n10" name="n10">10</a></strong>
<a href="#n11" name="n11">11</a>
<a href="#n12" name="n12">12</a>
<a href="#n13" name="n13">13</a>
<a href="#n14" name="n14">14</a>
<a href="#n15" name="n15">15</a>
<a href="#n16" name="n16">16</a>
<a href="#n17" name="n17">17</a>
<a href="#n18" name="n18">18</a>
<a href="#n19" name="n19">19</a>
<strong><a href="#n20" name="n20">20</a></strong>
<a href="#n21" name="n21">21</a>
<a href="#n22" name="n22">22</a>
<a href="#n23" name="n23">23</a>
<a href="#n24" name="n24">24</a>
<a href="#n25" name="n25">25</a>
<a href="#n26" name="n26">26</a>
<a href="#n27" name="n27">27</a>
<a href="#n28" name="n28">28</a>
<a href="#n29" name="n29">29</a>
<strong><a href="#n30" name="n30">30</a></strong>
<a href="#n31" name="n31">31</a>
<a href="#n32" name="n32">32</a>
<a href="#n33" name="n33">33</a>
<a href="#n34" name="n34">34</a>
<a href="#n35" name="n35">35</a>
<a href="#n36" name="n36">36</a>
<a href="#n37" name="n37">37</a>
<a href="#n38" name="n38">38</a>
<a href="#n39" name="n39">39</a>
<strong><a href="#n40" name="n40">40</a></strong>
<a href="#n41" name="n41">41</a>
<a href="#n42" name="n42">42</a>
<a href="#n43" name="n43">43</a>
<a href="#n44" name="n44">44</a>
<a href="#n45" name="n45">45</a>
<a href="#n46" name="n46">46</a>
<a href="#n47" name="n47">47</a>
<a href="#n48" name="n48">48</a>
<a href="#n49" name="n49">49</a>
<strong><a href="#n50" name="n50">50</a></strong>
<a href="#n51" name="n51">51</a>
<a href="#n52" name="n52">52</a>
<a href="#n53" name="n53">53</a>
<a href="#n54" name="n54">54</a>
<a href="#n55" name="n55">55</a>
<a href="#n56" name="n56">56</a>
<a href="#n57" name="n57">57</a>
<a href="#n58" name="n58">58</a>
<a href="#n59" name="n59">59</a>
<strong><a href="#n60" name="n60">60</a></strong>
<a href="#n61" name="n61">61</a>
<a href="#n62" name="n62">62</a>
<a href="#n63" name="n63">63</a>
<a href="#n64" name="n64">64</a>
<a href="#n65" name="n65">65</a>
<a href="#n66" name="n66">66</a>
<a href="#n67" name="n67">67</a>
<a href="#n68" name="n68">68</a>
<a href="#n69" name="n69">69</a>
<strong><a href="#n70" name="n70">70</a></strong>
<a href="#n71" name="n71">71</a>
<a href="#n72" name="n72">72</a>
<a href="#n73" name="n73">73</a>
<a href="#n74" name="n74">74</a>
<a href="#n75" name="n75">75</a>
<a href="#n76" name="n76">76</a>
<a href="#n77" name="n77">77</a>
<a href="#n78" name="n78">78</a>
<a href="#n79" name="n79">79</a>
<strong><a href="#n80" name="n80">80</a></strong>
<a href="#n81" name="n81">81</a>
<a href="#n82" name="n82">82</a>
<a href="#n83" name="n83">83</a>
<a href="#n84" name="n84">84</a>
<a href="#n85" name="n85">85</a>
<a href="#n86" name="n86">86</a>
<a href="#n87" name="n87">87</a>
<a href="#n88" name="n88">88</a>
<a href="#n89" name="n89">89</a>
<strong><a href="#n90" name="n90">90</a></strong>
<a href="#n91" name="n91">91</a>
<a href="#n92" name="n92">92</a>
<a href="#n93" name="n93">93</a>
<a href="#n94" name="n94">94</a>
<a href="#n95" name="n95">95</a>
<a href="#n96" name="n96">96</a>
<a href="#n97" name="n97">97</a>
<a href="#n98" name="n98">98</a>
<a href="#n99" name="n99">99</a>
<strong><a href="#n100" name="n100">100</a></strong>
<a href="#n101" name="n101">101</a>
<a href="#n102" name="n102">102</a>
<a href="#n103" name="n103">103</a>
<a href="#n104" name="n104">104</a>
<a href="#n105" name="n105">105</a>
<a href="#n106" name="n106">106</a>
<a href="#n107" name="n107">107</a>
<a href="#n108" name="n108">108</a>
<a href="#n109" name="n109">109</a>
</pre></td>
<td class="code"><pre><span class="preprocessor">#include</span> <span class="include">&lt;ESP8266WiFi.h&gt;</span>
<span class="preprocessor">#include</span> <span class="include">&lt;Wire.h&gt;</span>
<span class="preprocessor">#include</span> <span class="include">&lt;PubSubClient.h&gt;</span>
<span class="preprocessor">#include</span> <span class="include">&lt;Adafruit_HDC1000.h&gt;</span>
<pre><code class="cpp">#include &lt;ESP8266WiFi.h&gt;
#include &lt;Wire.h&gt;
#include &lt;PubSubClient.h&gt;
#include &lt;Adafruit_HDC1000.h&gt;
<span class="preprocessor">#define</span> wifi_ssid <span class="string"><span class="delimiter">&quot;</span><span class="content">YOUR WIFI SSID</span><span class="delimiter">&quot;</span></span>
<span class="preprocessor">#define</span> wifi_password <span class="string"><span class="delimiter">&quot;</span><span class="content">WIFI PASSWORD</span><span class="delimiter">&quot;</span></span>
#define wifi_ssid "YOUR WIFI SSID"
#define wifi_password "WIFI PASSWORD"
<span class="preprocessor">#define</span> mqtt_server <span class="string"><span class="delimiter">&quot;</span><span class="content">YOUR_MQTT_SERVER_HOST</span><span class="delimiter">&quot;</span></span>
<span class="preprocessor">#define</span> mqtt_user <span class="string"><span class="delimiter">&quot;</span><span class="content">your_username</span><span class="delimiter">&quot;</span></span>
<span class="preprocessor">#define</span> mqtt_password <span class="string"><span class="delimiter">&quot;</span><span class="content">your_password</span><span class="delimiter">&quot;</span></span>
#define mqtt_server "YOUR_MQTT_SERVER_HOST"
#define mqtt_user "your_username"
#define mqtt_password "your_password"
#define humidity_topic "sensor/humidity"
#define temperature_topic "sensor/temperature"
<span class="preprocessor">#define</span> humidity_topic <span class="string"><span class="delimiter">&quot;</span><span class="content">sensor/humidity</span><span class="delimiter">&quot;</span></span>
<span class="preprocessor">#define</span> temperature_topic <span class="string"><span class="delimiter">&quot;</span><span class="content">sensor/temperature</span><span class="delimiter">&quot;</span></span>
WiFiClient espClient;
PubSubClient client(espClient);
Adafruit_HDC1000 hdc = Adafruit_HDC1000();
void setup() {
Serial.begin(115200);
<span class="directive">void</span> setup() {
Serial.begin(<span class="integer">115200</span>);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setServer(mqtt_server, <span class="integer">1883</span>);
// Set SDA and SDL ports
Wire.begin(2, 14);
<span class="comment">// Set SDA and SDL ports</span>
Wire.begin(<span class="integer">2</span>, <span class="integer">14</span>);
// Start sensor
if (!hdc.begin()) {
Serial.println("Couldn't find sensor!");
while (1);
<span class="comment">// Start sensor</span>
<span class="keyword">if</span> (!hdc.begin()) {
Serial.println(<span class="string"><span class="delimiter">&quot;</span><span class="content">Couldn't find sensor!</span><span class="delimiter">&quot;</span></span>);
<span class="keyword">while</span> (<span class="integer">1</span>);
}}
void setup_wifi() {
delay(10);
// We start by connecting to a WiFi network
<span class="directive">void</span> setup_wifi() {
delay(<span class="integer">10</span>);
<span class="comment">// We start by connecting to a WiFi network</span>
Serial.println();
Serial.print("Connecting to ");
Serial.print(<span class="string"><span class="delimiter">&quot;</span><span class="content">Connecting to </span><span class="delimiter">&quot;</span></span>);
Serial.println(wifi_ssid);
WiFi.begin(wifi_ssid, wifi_password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
<span class="keyword">while</span> (WiFi.status() != WL_CONNECTED) {
delay(<span class="integer">500</span>);
Serial.print(<span class="string"><span class="delimiter">&quot;</span><span class="content">.</span><span class="delimiter">&quot;</span></span>);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(<span class="string"><span class="delimiter">&quot;</span><span class="delimiter">&quot;</span></span>);
Serial.println(<span class="string"><span class="delimiter">&quot;</span><span class="content">WiFi connected</span><span class="delimiter">&quot;</span></span>);
Serial.println(<span class="string"><span class="delimiter">&quot;</span><span class="content">IP address: </span><span class="delimiter">&quot;</span></span>);
Serial.println(WiFi.localIP());
}
void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
// If you do not want to use a username and password, change next line to
// if (client.connect("ESP8266Client")) {
if (client.connect("ESP8266Client", mqtt_user, mqtt_password)) {
Serial.println("connected");
} else {
Serial.print("failed, rc=");
<span class="directive">void</span> reconnect() {
<span class="comment">// Loop until we're reconnected</span>
<span class="keyword">while</span> (!client.connected()) {
Serial.print(<span class="string"><span class="delimiter">&quot;</span><span class="content">Attempting MQTT connection...</span><span class="delimiter">&quot;</span></span>);
<span class="comment">// Attempt to connect</span>
<span class="comment">// If you do not want to use a username and password, change next line to</span>
<span class="comment">// if (client.connect(&quot;ESP8266Client&quot;)) {</span>
<span class="keyword">if</span> (client.connect(<span class="string"><span class="delimiter">&quot;</span><span class="content">ESP8266Client</span><span class="delimiter">&quot;</span></span>, mqtt_user, mqtt_password)) {
Serial.println(<span class="string"><span class="delimiter">&quot;</span><span class="content">connected</span><span class="delimiter">&quot;</span></span>);
} <span class="keyword">else</span> {
Serial.print(<span class="string"><span class="delimiter">&quot;</span><span class="content">failed, rc=</span><span class="delimiter">&quot;</span></span>);
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
Serial.println(<span class="string"><span class="delimiter">&quot;</span><span class="content"> try again in 5 seconds</span><span class="delimiter">&quot;</span></span>);
<span class="comment">// Wait 5 seconds before retrying</span>
delay(<span class="integer">5000</span>);
}
}
}
bool checkBound(float newValue, float prevValue, float maxDiff) {
return newValue &lt; prevValue - maxDiff || newValue &gt; prevValue + maxDiff;
<span class="predefined-type">bool</span> checkBound(<span class="predefined-type">float</span> newValue, <span class="predefined-type">float</span> prevValue, <span class="predefined-type">float</span> maxDiff) {
<span class="keyword">return</span> newValue &lt; prevValue - maxDiff || newValue &gt; prevValue + maxDiff;
}
long lastMsg = 0;
float temp = 0.0;
float hum = 0.0;
float diff = 1.0;
<span class="predefined-type">long</span> lastMsg = <span class="integer">0</span>;
<span class="predefined-type">float</span> temp = <span class="float">0</span><span class="float">.0</span>;
<span class="predefined-type">float</span> hum = <span class="float">0</span><span class="float">.0</span>;
<span class="predefined-type">float</span> diff = <span class="float">1</span><span class="float">.0</span>;
void loop() {
if (!client.connected()) {
<span class="directive">void</span> loop() {
<span class="keyword">if</span> (!client.connected()) {
reconnect();
}
client.loop();
long now = millis();
if (now - lastMsg &gt; 1000) {
<span class="predefined-type">long</span> now = millis();
<span class="keyword">if</span> (now - lastMsg &gt; <span class="integer">1000</span>) {
lastMsg = now;
float newTemp = hdc.readTemperature();
float newHum = hdc.readHumidity();
<span class="predefined-type">float</span> newTemp = hdc.readTemperature();
<span class="predefined-type">float</span> newHum = hdc.readHumidity();
if (checkBound(newTemp, temp, diff)) {
<span class="keyword">if</span> (checkBound(newTemp, temp, diff)) {
temp = newTemp;
Serial.print("New temperature:");
Serial.print(<span class="string"><span class="delimiter">&quot;</span><span class="content">New temperature:</span><span class="delimiter">&quot;</span></span>);
Serial.println(String(temp).c_str());
client.publish(temperature_topic, String(temp).c_str(), true);
client.publish(temperature_topic, String(temp).c_str(), <span class="predefined-constant">true</span>);
}
if (checkBound(newHum, hum, diff)) {
<span class="keyword">if</span> (checkBound(newHum, hum, diff)) {
hum = newHum;
Serial.print("New humidity:");
Serial.print(<span class="string"><span class="delimiter">&quot;</span><span class="content">New humidity:</span><span class="delimiter">&quot;</span></span>);
Serial.println(String(hum).c_str());
client.publish(humidity_topic, String(hum).c_str(), true);
client.publish(humidity_topic, String(hum).c_str(), <span class="predefined-constant">true</span>);
}
}
}
</code></pre>
</pre></td>
</tr></table>
</div>
<h3>Configuring Home Assistant</h3>
<p>The last step is to integrate the sensor values into Home Assistant. This can be done by setting up
Home Assistant to connect to the MQTT broker and subscribe to the sensor topics.</p>
<p>The last step is to integrate the sensor values into Home Assistant. This can be done by setting up Home Assistant to connect to the MQTT broker and subscribe to the sensor topics.</p>
<pre><code class="yaml">mqtt:
broker: YOUR_MQTT_SERVER_HOST
username: your_username
password: your_password
<div class="highlighter-coderay"><table class="CodeRay"><tr>
<td class="line-numbers"><pre><a href="#n1" name="n1">1</a>
<a href="#n2" name="n2">2</a>
<a href="#n3" name="n3">3</a>
<a href="#n4" name="n4">4</a>
<a href="#n5" name="n5">5</a>
<a href="#n6" name="n6">6</a>
<a href="#n7" name="n7">7</a>
<a href="#n8" name="n8">8</a>
<a href="#n9" name="n9">9</a>
<strong><a href="#n10" name="n10">10</a></strong>
<a href="#n11" name="n11">11</a>
<a href="#n12" name="n12">12</a>
<a href="#n13" name="n13">13</a>
<a href="#n14" name="n14">14</a>
<a href="#n15" name="n15">15</a>
<a href="#n16" name="n16">16</a>
<a href="#n17" name="n17">17</a>
<a href="#n18" name="n18">18</a>
</pre></td>
<td class="code"><pre><span class="key">mqtt</span>:
<span class="key">broker</span>: <span class="string"><span class="content">YOUR_MQTT_SERVER_HOST</span></span>
<span class="key">username</span>: <span class="string"><span class="content">your_username</span></span>
<span class="key">password</span>: <span class="string"><span class="content">your_password</span></span>
sensor:
platform: mqtt
name: "Temperature"
state_topic: "sensor/temperature"
qos: 0
unit_of_measurement: "ºC"
<span class="key">sensor</span>:
<span class="key">platform</span>: <span class="string"><span class="content">mqtt</span></span>
<span class="key">name</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">Temperature</span><span class="delimiter">&quot;</span></span>
<span class="key">state_topic</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">sensor/temperature</span><span class="delimiter">&quot;</span></span>
<span class="key">qos</span>: <span class="string"><span class="content">0</span></span>
<span class="key">unit_of_measurement</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">ºC</span><span class="delimiter">&quot;</span></span>
sensor 2:
platform: mqtt
name: "Humidity"
state_topic: "sensor/humidity"
qos: 0
unit_of_measurement: "%"
</code></pre>
<span class="key">sensor 2</span>:
<span class="key">platform</span>: <span class="string"><span class="content">mqtt</span></span>
<span class="key">name</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">Humidity</span><span class="delimiter">&quot;</span></span>
<span class="key">state_topic</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">sensor/humidity</span><span class="delimiter">&quot;</span></span>
<span class="key">qos</span>: <span class="string"><span class="content">0</span></span>
<span class="key">unit_of_measurement</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">%</span><span class="delimiter">&quot;</span></span>
</pre></td>
</tr></table>
</div>
]]></content>
</entry>

View file

@ -5,8 +5,6 @@
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
@ -32,7 +30,6 @@
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
</head>
<body >
<header>
@ -54,10 +51,10 @@
<a href="/getting-started/">Getting started</a>
<ul>
<li><a href='/getting-started/'>Installing Home Assistant</a></li>
<li><a href='/getting-started/configuration.html'>Configuration basics</a></li>
<li><a href='/getting-started/devices.html'>Adding devices</a></li>
<li><a href='/getting-started/presence-detection.html'>Presence detection</a></li>
<li><a href='/getting-started/automation.html'>Automation</a></li>
<li><a href='/getting-started/configuration/'>Configuration basics</a></li>
<li><a href='/getting-started/devices/'>Adding devices</a></li>
<li><a href='/getting-started/presence-detection/'>Presence detection</a></li>
<li><a href='/getting-started/automation/'>Automation</a></li>
<li><a href='/cookbook'>Configuration cookbook</a></li>
</ul>
</li>
@ -65,26 +62,24 @@
<li>
<a href="/developers/">Developers</a>
<ul>
<li><a href="/developers/architecture.html">Architecture</a></li>
<li><a href="/developers/frontend.html">Frontend development</a></li>
<li><a href="/developers/creating_components.html">
<li><a href="/developers/architecture/">Architecture</a></li>
<li><a href="/developers/frontend/">Frontend development</a></li>
<li><a href="/developers/creating_components/">
Creating components
</a></li>
<li><a href="/developers/add_new_platform.html">
<li><a href="/developers/add_new_platform/">
Adding platform support
</a></li>
<li><a href="/developers/api.html">API</a></li>
<li><a href="/developers/credits.html">Credits</a></li>
<li><a href="/developers/api/">API</a></li>
<li><a href="/developers/credits/">Credits</a></li>
</ul>
</li>
<li><a href="/blog/">Blog</a></li>
<li><a href="/help/">Need help?</a></li>
</ul>
</nav>
</div>
</div>
</div>
</header>
@ -116,9 +111,7 @@
<h2>2015</h2>
<article>
<div class="grid">
<div class="grid">
<div class="grid__item one-fifth palm-one-whole">
<time datetime="2015-10-11T12:10:00-07:00" pubdate>
@ -129,9 +122,7 @@
<h1 class="gamma"><a href="/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt/">Report the temperature with ESP8266 to MQTT</a></h1>
<footer class="meta">
<span>
<span>
<i class="icon-tags"></i>
<ul class="tags unstyled">
@ -145,7 +136,6 @@
</ul>
</span>
</footer>
<hr class="divider">
@ -168,21 +158,20 @@
<section class="sharing aside-module grid__item one-whole lap-one-half">
<h1 class="title delta">Share this post</h1>
<a href="//twitter.com/share"
class="twitter-share-button"
data-url="https://home-assistant.io/blog/categories/esp8266/index.html"
data-counturl="https://home-assistant.io/blog/categories/esp8266/index.html" >Tweet</a>
data-url="https://home-assistant.io/blog/categories/esp8266/"
data-counturl="https://home-assistant.io/blog/categories/esp8266/" >Tweet</a>
<div class="g-plusone" data-size="standard"></div>
<div class="fb-share-button" style='top: -6px;'
data-href="https://home-assistant.io/blog/categories/esp8266/index.html"
data-href="https://home-assistant.io/blog/categories/esp8266/"
data-layout="button_count">
</div>
@ -250,7 +239,6 @@
</div>
</aside>
</div>
@ -261,30 +249,23 @@
<div class="grid">
<div class="grid__item">
<p class="copyright">
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a>, <a href='http://jekyllrb.com/'>Jekyll</a> and the <a href='https://github.com/coogie/oscailte'>Oscalite theme</a>. Hosted by <a href='https://pages.github.com/'>GitHub</a> and served by <a href='https://cloudflare.com'>CloudFlare</a>.</span>
<span class="credit">Powered by <a href='http://jekyllrb.com/'>Jekyll</a> and the <a href='https://github.com/coogie/oscailte'>Oscalite theme</a>. Hosted by <a href='https://pages.github.com/'>GitHub</a> and served by <a href='https://cloudflare.com'>CloudFlare</a>.</span>
</p>
</div>
</div>
</div>
</footer>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<script>
<script>
var _gaq=[['_setAccount','UA-57927901-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<script>
var disqus_shortname = 'home-assistant';
@ -298,13 +279,5 @@
}());
</script>
</body>
</html>