Das zwölfte Türchen

Today is again a Microcontroller behind the little door, with which you can not only read out various sensors and control actuators, but also establish a WiFi connection. It's another breakout board with the ESP8266. 

This breakout board has, in addition to the processor with 4MByte flash memory, a CP2102 USB to serial converter so that you can easily program the module. Most of the I / O pins are brought out. There is also a voltage regulator that supplies the 3.3 V supply voltage for the ESP8266 from the USB supply voltage or the voltage at the Vin connection. Here is an important note. Since the ESP8266 works with 3.3 V, no voltages higher than 3.3 V may be applied to its inputs! Another advantage of this board is that it is one pitch narrower and therefore fits on a simple breadboard.


As the cover picture shows, we want one of the controllers together with an LCD display as it was presented in the Advent calendar on December 4th, build an RSS feed reader that also shows the date and time. With the reader it is possible to display the latest news from a newsfeed as ticker. The date and time are obtained from an NTP time server.

An RSS feed is a news overview in XML format that various information servers on the Internet offer. The ARD (German TV program) server is used in the example program. Since the messages are received in XML format, it is easy to display only certain parts of the entire information. With 16 characters per line, the space is very small, which is why we only display the title of each message.
For example, here is the beginning of such a feed:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/resources/xsl/rdf_xsl.jsp" type="text/xsl"?>
<rss version="2.0">
<!--
* XML-format for teasering tagesschau.de-headlines. Version: 2.0
* Release-Date:2002/02/04, last updated 2006/06/28
*
* Die Nutzung dieser Inhalte ist ausschliesslich nic⸮ht-kommerziellen Internet-
* Angeboten erlaubt, die Nutzung kann jederzeit von tagesschau.de untersagt
* werden. tagesschau.de übernimmt keinen Support, zudem wird keine Verfügbarkeit
* dieser XML-Datei gewährleistet. Die Inhalte dürfen nicht archiviert werden.
//-->
<channel>
<title>tagesschau.de - Die Nachrichten der ARD</title>
<link>https://www.tagesschau.de</link>
<description>tagesschau.de</description>
<language>de</language>
<copyright>tagesschau.de, Norddeutscher Rundfunk</copyright>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<ttl>30</ttl>
<item>
<title>Corona-Katastrophenfall: Bayern will Maßnahmen verschärfen</title>
<link>https://www.tagesschau.de/inland/corona-bayern-119.html</link>
<description>Die Neuinfektionen mit dem Corona-Virus bleiben............</description>
<guid>https://www.tagesschau.de/inland/corona-bayern-119.html</guid>
<category>Inland</category>
</item>
<item>
<title>……………………………..


The root tag <rss> within this tag is the <channel> tag, which contains the individual messages with the <item> tag. We are interested in the title tag of the items, so the XML path must be /rss/channel/item/title.

We start with a little soldering. First, the microcontroller board has to be provided with pin headers. Then the I2C adapter should be soldered to the display. I recommend to mount the I2C adapter on the bottom side, because then it is not in the way when you plan to mount it in a case.


The wiring is quite simple: GND and Vcc of the display we connect to GND and Vin of the controller. The clock line SCL comes to D1 and the data line SDA to D2.

Now we start programming with the Arduino IDE. If the support for the boards with ESP8266 MCU is not yet installed, we have to do it now. In the Arduino IDE we go via the menu File to Preferences or simply type "Ctrl+;".

In the form we click at the point "Additional board manager URLs" on the symbol right beside the input field. Here we can enter the URL for the ESP8266 board manager:

http://arduino.esp8266.com/stable/package_esp8266com_index.json


…………………………… ..</div> <p> </p> <p>The root tag (pronounced "tegg" = label, tag, identification) <rss> within this tag is the <channel> tag, which contains the individual messages with the <item> tag. We are interested in the item's title tag, so the XML path must be / rss / channel / item / title.</p> A little soldering work is required first. First, the microcontroller board has to be provided with pin headers. Then the I2C adapter should be soldered to the display. I recommend installing the I2C adapter on the underside, as it will not be in the way if you plan to install it in a housing.<br><br>The wiring is very simple GND and Vcc of the display we connect to GND and Vin of the controller. The clock line SCL comes to D1 and the data line SDA to D2. <table width="100%"> <tbody> <tr> <td><img src="https://cdn.shopify.com/s/files/1/1509/1638/files/Verdrahtung_7f27aa28-2076-40f7-8395-7eb8ea7c37cc_480x480_1_600x600.png?v=1607674627" alt="" style="display: block; margin-left: auto; margin-right: auto;"></td> </tr> </tbody> </table> <p><br>Now it's time to program with the Arduino IDE. If the support of the boards with ESP8266 MCU is not yet installed, we have to do it now. In the Arduino IDE we go to Preferences via the File menu or simply with "Ctrl +;".</p> <p>In the form we click on the symbol to the right of the input field under the item “Additional board administrator URLs”. Here we can now enter the URL for the ESP8266 board manager:</p> <p><em>http://arduino.esp8266.com/stable/package_esp8266com_index.json<br></em></p> <table width="100%"> <tbody> <tr> <td><img src="https://cdn.shopify.com/s/files/1/1509/1638/files/board_verwalter_480x480_480x480_f04cc826-b064-49b7-b405-7bc44ca75626_600x600.jpg?v=1607676661" alt="" style="display: block; margin-left: auto; margin-right: auto;"></td> </tr> </tbody> </table> <p><br>After the presets have been saved, we call the board manager via the menu Tools-> Board: -> Board manager. We enter “esp8266” as the search term. We get the following entry, which we install.</p> <table width="100%"> <tbody> <tr> <td><img src="https://cdn.shopify.com/s/files/1/1509/1638/files/boardverwalter_480x480_dde6e6de-80cd-4ccd-a1e0-8bc9fc15c853_480x480_1_600x600.jpg?v=1607676689" alt="" style="display: block; margin-left: auto; margin-right: auto;"></td> </tr> </tbody> </table> <p> <br>Now we can select a board in the Tools-> Board: -> ESP8266 Boards menu. We use NodeMCU 1.0….</p> <table width="100%"> <tbody> <tr> <td><img src="https://cdn.shopify.com/s/files/1/1509/1638/files/boardauswahl_480x480_480x480_4f372d09-6c70-4b39-b9b7-bd9e9653c473_600x600.jpg?v=1607677567" alt="" style="display: block; margin-left: auto; margin-right: auto;"></td> </tr> </tbody> </table> <p><br></p> <p>Everything is now ready to install the sketch for the news reader.</p> <p><span style="color: #5e6d03;" color="#5e6d03">#include</span> <span style="color: #434f54;" color="#434f54"><</span><span style="color: #d35400;" color="#d35400">ESP8266WiFi</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #000000;" color="#000000">H</span><span style="color: #434f54;" color="#434f54">></span>  <span style="color: #434f54;" color="#434f54">// WLAN support</span></p> <pre><span style="color: #5e6d03;" color="#5e6d03">#include</span> <span style="color: #434f54;" color="#434f54"><</span><span style="color: #000000;" color="#000000">TZ</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #000000;" color="#000000">H</span><span style="color: #434f54;" color="#434f54">></span>           <span style="color: #434f54;" color="#434f54">// time zone constants</span> <span style="color: #5e6d03;" color="#5e6d03">#include</span> <span style="color: #434f54;" color="#434f54"><</span><b><span style="color: #d35400;" color="#d35400">LiquidCrystal_I2C</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #000000;" color="#000000">H</span><span style="color: #434f54;" color="#434f54">></span> <span style="color: #434f54;" color="#434f54">// Library for the LCD display</span> <span style="color: #5e6d03;" color="#5e6d03">#include</span> <span style="color: #434f54;" color="#434f54"><</span><span style="color: #000000;" color="#000000">TinyXML</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #000000;" color="#000000">H</span><span style="color: #434f54;" color="#434f54">></span>         <span style="color: #434f54;" color="#434f54">// XML interpreter for reading the RSS feed</span> <span style="color: #434f54;" color="#434f54">// SSID and PSK from the local WLAN</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">STASSID</span> <span style="color: #005c5f;" color="#005c5f">"*********************"</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">STAPSK</span>  <span style="color: #005c5f;" color="#005c5f">"*********************"</span> <span style="color: #434f54;" color="#434f54">// Time zone with summer / winter time information</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">MYTZ</span> <span style="color: #000000;" color="#000000">TZ_Europe_Berlin</span> <span style="color: #434f54;" color="#434f54">// Timeout for reading the RSS feed in seconds</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">READ_TIMEOUT</span> <span style="color: #000000;" color="#000000">10</span> <span style="color: #434f54;" color="#434f54">// processing steps</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">ST_CLEAR</span> <span style="color: #000000;" color="#000000">0</span> <span style="color: #434f54;" color="#434f54">// get new data from the server</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">ST_START</span> <span style="color: #000000;" color="#000000">1</span> <span style="color: #434f54;" color="#434f54">//Show notification</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">ST_MOVE</span>  <span style="color: #000000;" color="#000000">2</span> <span style="color: #434f54;" color="#434f54">// Push the message through</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">ST_END</span>   <span style="color: #000000;" color="#000000">3</span> <span style="color: #434f54;" color="#434f54">// Show end of message</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">MAXNEWS</span> <span style="color: #000000;" color="#000000">10</span> <span style="color: #434f54;" color="#434f54">// Maximum number of messages</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">RSS_SERVER</span> <span style="color: #005c5f;" color="#005c5f">"www.tagesschau.de"</span> <span style="color: #434f54;" color="#434f54">// message server</span> <span style="color: #5e6d03;" color="#5e6d03">#define</span> <span style="color: #000000;" color="#000000">RSS_FEED</span> <span style="color: #005c5f;" color="#005c5f">"newsticker.rdf"</span>      <span style="color: #434f54;" color="#434f54">// name of the feed</span> <span style="color: #434f54;" color="#434f54">// LCD address = 0x27, number of characters 16, number of lines 2</span> <b><span style="color: #d35400;" color="#d35400">LiquidCrystal_I2C</span></b> <span style="color: #000000;" color="#000000">lcd</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">0x27</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">16</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">2</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// WLAN client instance</span> <span style="color: #d35400;" color="#d35400">WiFiClient</span> <span style="color: #d35400;" color="#d35400">client</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// XML interpreter instance</span> <span style="color: #000000;" color="#000000">TinyXML</span> <span style="color: #000000;" color="#000000">xml</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// German special characters</span> <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">font</span> <span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">8</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">9</span><span style="color: #000000;" color="#000000">]</span> <span style="color: #000000;" color="#000000">{</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x0c</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0c</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 0 °</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x04</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0a</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x1f</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 1 Ä</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0e</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0e</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 2 Ö</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0e</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 3 nights</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x0a</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x1e</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x01</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0f</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x13</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0d</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 4 a</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x0a</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0e</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x11</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0e</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 5 ö</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x0a</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x0f</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">// 6 ü</span>     <span style="color: #000000;" color="#000000">{</span><span style="color: #000000;" color="#000000">0x0c</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x14</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x12</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x14</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0x00</span><span style="color: #000000;" color="#000000">}</span>  <span style="color: #434f54;" color="#434f54">// 7 ß</span> <span style="color: #000000;" color="#000000">}</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #d35400;" color="#d35400">buffer</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">4000</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #434f54;" color="#434f54">// Buffer for XML interpreter</span> <span style="color: #00979c;" color="#00979c">uint16_t</span> <span style="color: #000000;" color="#000000">msglen</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>         <span style="color: #434f54;" color="#434f54">// length of the current message</span> <span style="color: #00979c;" color="#00979c">String</span> <span style="color: #000000;" color="#000000">msg</span><span style="color: #000000;" color="#000000">;</span>                  <span style="color: #434f54;" color="#434f54">// current message</span> <span style="color: #00979c;" color="#00979c">String</span> <span style="color: #000000;" color="#000000">news</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">MAXNEWS</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #434f54;" color="#434f54">// memory for messages </span> <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>         <span style="color: #434f54;" color="#434f54">// Number of current messages in memory</span> <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">curNews</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>         <span style="color: #434f54;" color="#434f54">// Index of the currently displayed message</span> <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #d35400;" color="#d35400">step</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>            <span style="color: #434f54;" color="#434f54">// Current processing step</span> <span style="color: #00979c;" color="#00979c">uint16_t</span> <span style="color: #000000;" color="#000000">pos</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>            <span style="color: #434f54;" color="#434f54">// Start position for pushing through</span> <span style="color: #434f54;" color="#434f54">// Coding German umlauts (UTF8) for the display</span> <span style="color: #00979c;" color="#00979c">String</span> <span style="color: #000000;" color="#000000">extraChar</span><span style="color: #000000;" color="#000000">(</span><span style="color: #00979c;" color="#00979c">String</span> <span style="color: #000000;" color="#000000">text</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">{</span>  <span style="color: #00979c;" color="#00979c">String</span> <span style="color: #000000;" color="#000000">res</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #005c5f;" color="#005c5f">""</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">i</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #00979c;" color="#00979c">char</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #5e6d03;" color="#5e6d03">while</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54"><</span><span style="color: #000000;" color="#000000">text</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">length</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>    <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">text</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">i</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">==</span><span style="color: #000000;" color="#000000">195</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span> <span style="color: #434f54;" color="#434f54">// UTF8 German umlauts</span>      <span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #5e6d03;" color="#5e6d03">switch</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">text</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">i</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">164</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">4</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Ä</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">182</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">5</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// ö</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">188</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">6</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// ü</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">159</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">7</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// ß</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">132</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">1</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Ä</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">150</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">2</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Ö</span>        <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">156</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">3</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Ü</span>        <span style="color: #5e6d03;" color="#5e6d03">default</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #000000;" color="#000000">}</span>    <span style="color: #000000;" color="#000000">}</span> <span style="color: #5e6d03;" color="#5e6d03">else</span> <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span> <span style="color: #434f54;" color="#434f54">==</span> <span style="color: #000000;" color="#000000">194</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span> <span style="color: #434f54;" color="#434f54">// UTF8 special characters</span>      <span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">text</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">i</span><span style="color: #000000;" color="#000000">]</span> <span style="color: #434f54;" color="#434f54">==</span> <span style="color: #000000;" color="#000000">176</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">0xdf</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #5e6d03;" color="#5e6d03">else</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #000000;" color="#000000">}</span> <span style="color: #5e6d03;" color="#5e6d03">else</span> <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span> <span style="color: #434f54;" color="#434f54">></span> <span style="color: #000000;" color="#000000">128</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span> <span style="color: #434f54;" color="#434f54">// normal characters unchanged</span>      <span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">255</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #000000;" color="#000000">}</span>    <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span><span style="color: #434f54;" color="#434f54">></span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">res</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">concat</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">}</span>  <span style="color: #5e6d03;" color="#5e6d03">return</span> <span style="color: #000000;" color="#000000">res</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #000000;" color="#000000">}</span> <span style="color: #434f54;" color="#434f54">// This function is called by the XML interpreter when an XML tag has been read</span> <span style="color: #434f54;" color="#434f54">// tagName contains the complete XML path of the tag, data the content of the tag</span> <span style="color: #00979c;" color="#00979c">void</span> <span style="color: #000000;" color="#000000">XML_callback</span><span style="color: #000000;" color="#000000">(</span><span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">status flags</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #00979c;" color="#00979c">char</span><span style="color: #434f54;" color="#434f54">*</span> <span style="color: #000000;" color="#000000">tagName</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #00979c;" color="#00979c">uint16_t</span> <span style="color: #000000;" color="#000000">tagNameLen</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #00979c;" color="#00979c">char</span><span style="color: #434f54;" color="#434f54">*</span> <span style="color: #000000;" color="#000000">data</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #00979c;" color="#00979c">uint16_t</span> <span style="color: #000000;" color="#000000">dataLen</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>  <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">status flags</span> <span style="color: #434f54;" color="#434f54">&</span> <span style="color: #000000;" color="#000000">STATUS_TAG_TEXT</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>    <span style="color: #434f54;" color="#434f54">//Serial.println(tagName);</span>    <span style="color: #434f54;" color="#434f54">// if we find a title tag and the maximum number of messages still</span>    <span style="color: #434f54;" color="#434f54">// is not reached, the message is saved and the counter is increased</span>    <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">strcasecmp</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">tagName</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #005c5f;" color="#005c5f">"/ rss / channel / item / title"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #434f54;" color="#434f54">==</span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>      <span style="color: #000000;" color="#000000">data</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">dataLen</span><span style="color: #000000;" color="#000000">]</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #00979c;" color="#00979c">'\0'</span><span style="color: #000000;" color="#000000">;</span>      <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">printf</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"% i% s \ n"</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">newsCnt</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">data</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54"><</span> <span style="color: #000000;" color="#000000">MAXNEWS</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>        <span style="color: #000000;" color="#000000">news</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">newsCnt</span><span style="color: #000000;" color="#000000">]</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">data</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">newsCnt</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #000000;" color="#000000">}</span>    <span style="color: #000000;" color="#000000">}</span>  <span style="color: #000000;" color="#000000">}</span> <span style="color: #000000;" color="#000000">}</span> <span style="color: #434f54;" color="#434f54">// Read new messages from the RSS feed</span> <span style="color: #00979c;" color="#00979c">boolean</span> <span style="color: #000000;" color="#000000">getNews</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>  <span style="color: #00979c;" color="#00979c">boolean</span> <span style="color: #000000;" color="#000000">res</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #00979c;" color="#00979c">false</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #00979c;" color="#00979c">boolean</span> <span style="color: #000000;" color="#000000">timedOut</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #00979c;" color="#00979c">false</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #00979c;" color="#00979c">char</span> <span style="color: #000000;" color="#000000">c</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// only if we have an internet connection</span>  <span style="color: #5e6d03;" color="#5e6d03">if</span><span style="color: #000000;" color="#000000">(</span><b><span style="color: #d35400;" color="#d35400">WiFi</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">status</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #434f54;" color="#434f54">==</span> <span style="color: #000000;" color="#000000">WL_CONNECTED</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">{</span>    <span style="color: #434f54;" color="#434f54">// connect to the HTTP server first</span>    <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">println</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"Connect to server"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #5e6d03;" color="#5e6d03">if</span><span style="color: #000000;" color="#000000">(</span><span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">connect</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">RSS_SERVER</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #000000;" color="#000000">80</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>      <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">println</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"OK \ r \ nRequesting data ..."</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #434f54;" color="#434f54">// Now we can get the XML page with the feed</span>      <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"GET /"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">RSS_FEED</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"HTTP / 1.1 \ r \ nHost:"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">RSS_SERVER</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"\ r \ nConnection: Close \ r \ n \ r \ n"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">flush</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #434f54;" color="#434f54">// prepare the XML interpreter</span>      <span style="color: #000000;" color="#000000">xml</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">reset</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #00979c;" color="#00979c">uint32_t</span> <span style="color: #000000;" color="#000000">t</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #d35400;" color="#d35400">millis</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// start time</span>      <span style="color: #5e6d03;" color="#5e6d03">while</span><span style="color: #000000;" color="#000000">(</span><span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">connected</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>        <span style="color: #5e6d03;" color="#5e6d03">if</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">read</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #434f54;" color="#434f54">>=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>          <span style="color: #434f54;" color="#434f54">// As long as we get characters from the web server, these will be</span>          <span style="color: #434f54;" color="#434f54">// passed on to the XML interpreter for interpretation</span>          <span style="color: #000000;" color="#000000">xml</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #000000;" color="#000000">processChar</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">c</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>          <span style="color: #d35400;" color="#d35400">delay</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">1</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Delay 1ms otherwise the XML interpreter will not follow</span>          <span style="color: #000000;" color="#000000">t</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #d35400;" color="#d35400">millis</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Reset timeout clock</span>        <span style="color: #000000;" color="#000000">}</span> <span style="color: #5e6d03;" color="#5e6d03">else</span> <span style="color: #5e6d03;" color="#5e6d03">if</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">(</span><span style="color: #d35400;" color="#d35400">millis</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #434f54;" color="#434f54">-</span> <span style="color: #000000;" color="#000000">t</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #434f54;" color="#434f54">>=</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">READ_TIMEOUT</span> <span style="color: #434f54;" color="#434f54">*</span> <span style="color: #000000;" color="#000000">1000</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>          <span style="color: #434f54;" color="#434f54">// In the event of a timeout, the interpretation is aborted</span>          <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">println</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"---Time-out---"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>          <span style="color: #000000;" color="#000000">timedOut</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #00979c;" color="#00979c">true</span><span style="color: #000000;" color="#000000">;</span>          <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">}</span>      <span style="color: #000000;" color="#000000">}</span>      <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">timedOut</span><span style="color: #000000;" color="#000000">)</span> <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">println</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"Time-out"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #5e6d03;" color="#5e6d03">if</span><span style="color: #000000;" color="#000000">(</span><span style="color: #434f54;" color="#434f54">!</span><span style="color: #000000;" color="#000000">timedOut</span> <span style="color: #434f54;" color="#434f54">&&</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54">></span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>        <span style="color: #434f54;" color="#434f54">// If messages have been received, the first message will be displayed</span>        <span style="color: #000000;" color="#000000">curNews</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>      <span style="color: #000000;" color="#000000">}</span>    <span style="color: #000000;" color="#000000">}</span>    <span style="color: #d35400;" color="#d35400">client</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">Stop</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">}</span> <span style="color: #5e6d03;" color="#5e6d03">else</span> <span style="color: #000000;" color="#000000">{</span>    <span style="color: #434f54;" color="#434f54">// there was no internet connection</span>    <span style="color: #434f54;" color="#434f54">// a new connection attempt is started</span>    <span style="color: #434f54;" color="#434f54">// and an error message is displayed</span>    <span style="color: #000000;" color="#000000">news</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">]</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #005c5f;" color="#005c5f">"No Internet connection!"</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">1</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #000000;" color="#000000">curNews</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">}</span> <span style="color: #000000;" color="#000000">}</span> <span style="color: #434f54;" color="#434f54">// update the display</span> <span style="color: #00979c;" color="#00979c">void</span> <span style="color: #d35400;" color="#d35400">updateDisplay</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>  <span style="color: #434f54;" color="#434f54">// first line time and date</span>  <b><span style="color: #d35400;" color="#d35400">time_t</span></b> <span style="color: #d35400;" color="#d35400">now</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">//current time </span>  <span style="color: #00979c;" color="#00979c">struct</span> <span style="color: #000000;" color="#000000">tm</span> <span style="color: #434f54;" color="#434f54">*</span> <span style="color: #000000;" color="#000000">s_time</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Time structure split into year, month, day, hours, minutes and seconds</span>  <span style="color: #00979c;" color="#00979c">char</span> <span style="color: #000000;" color="#000000">line_buffer</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">20</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Buffer for ad line</span>  <span style="color: #d35400;" color="#d35400">now</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #d35400;" color="#d35400">time</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">nullptr</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// read current time</span>  <span style="color: #000000;" color="#000000">s_time</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #d35400;" color="#d35400">localtime</span><span style="color: #000000;" color="#000000">(</span><span style="color: #434f54;" color="#434f54">&</span><span style="color: #d35400;" color="#d35400">now</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// convert to the time structure for the local time</span>  <span style="color: #434f54;" color="#434f54">// Fill line buffer with time and date</span>  <span style="color: #d35400;" color="#d35400">strftime</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">line_buffer</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">17</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #005c5f;" color="#005c5f">"%d.%m.%Y %H:%M"</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">s_time</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Output the time to the serial interface</span>  <span style="color: #434f54;" color="#434f54">//Serial.println(line_buffer);</span>  <span style="color: #434f54;" color="#434f54">// Show the time on the display in line 1</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">setCursor</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">0</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">line_buffer</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// second line of messages</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">setCursor</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">0</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">1</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #5e6d03;" color="#5e6d03">switch</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #d35400;" color="#d35400">step</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>    <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">ST_CLEAR</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #d35400;" color="#d35400">step</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">ST_START</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">//Next Step</span>        <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">curNews</span> <span style="color: #434f54;" color="#434f54">>=</span> <span style="color: #000000;" color="#000000">newsCnt</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>          <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"Update.."</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>          <span style="color: #000000;" color="#000000">getNews</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// get new messages</span>          <span style="color: #000000;" color="#000000">curNews</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">}</span> <span style="color: #5e6d03;" color="#5e6d03">else</span> <span style="color: #000000;" color="#000000">{</span>          <span style="color: #000000;" color="#000000">curNews</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// start next message</span>          <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"                "</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>          <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">curNews</span> <span style="color: #434f54;" color="#434f54">>=</span> <span style="color: #000000;" color="#000000">newsCnt</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #d35400;" color="#d35400">step</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">ST_END</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">}</span>        <span style="color: #000000;" color="#000000">msg</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">extraChar</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">news</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">curNews</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">msglen</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">msg</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">length</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">ST_START</span><span style="color: #434f54;" color="#434f54">:</span><span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">msg</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">substring</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">0</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">16</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">pos</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// take start position</span>        <span style="color: #d35400;" color="#d35400">step</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">ST_MOVE</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">ST_MOVE</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #000000;" color="#000000">pos</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">msg</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">substring</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">pos</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">pos</span><span style="color: #434f54;" color="#434f54">+</span><span style="color: #000000;" color="#000000">16</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #434f54;" color="#434f54">// when the message is ready, next message</span>        <span style="color: #5e6d03;" color="#5e6d03">if</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">pos</span> <span style="color: #434f54;" color="#434f54">></span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">msglen</span><span style="color: #434f54;" color="#434f54">-</span><span style="color: #000000;" color="#000000">17</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #d35400;" color="#d35400">step</span><span style="color: #434f54;" color="#434f54">=</span><span style="color: #000000;" color="#000000">ST_END</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #5e6d03;" color="#5e6d03">case</span> <span style="color: #000000;" color="#000000">ST_END</span><span style="color: #434f54;" color="#434f54">:</span> <span style="color: #d35400;" color="#d35400">step</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">ST_CLEAR</span><span style="color: #000000;" color="#000000">;</span>        <span style="color: #5e6d03;" color="#5e6d03">break</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">}</span> <span style="color: #000000;" color="#000000">}</span> <span style="color: #434f54;" color="#434f54">// setup function</span> <span style="color: #00979c;" color="#00979c">void</span> <span style="color: #5e6d03;" color="#5e6d03">set up</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>  <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">begin</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">115200</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #434f54;" color="#434f54">// Initialize the serial interface</span>  <span style="color: #434f54;" color="#434f54">// initialize the XML interpreter</span>  <span style="color: #000000;" color="#000000">xml</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">init</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">(</span><span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #434f54;" color="#434f54">*</span><span style="color: #000000;" color="#000000">)</span><span style="color: #d35400;" color="#d35400">buffer</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #00979c;" color="#00979c">sizeof</span><span style="color: #000000;" color="#000000">(</span><span style="color: #d35400;" color="#d35400">buffer</span><span style="color: #000000;" color="#000000">)</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #434f54;" color="#434f54">&</span><span style="color: #000000;" color="#000000">XML_callback</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Initialize the display and turn on the lighting</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">init</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">; // with older versions of the library, the call lcd.begin (); be called</span>  <br><span style="color: #000000;" color="#000000"> lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">backlight</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Generate German umlauts</span>  <span style="color: #5e6d03;" color="#5e6d03">for</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">i</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54"><</span><span style="color: #000000;" color="#000000">8</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">createChar</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">i</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #000000;" color="#000000">font</span><span style="color: #000000;" color="#000000">[</span><span style="color: #000000;" color="#000000">i</span><span style="color: #000000;" color="#000000">]</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Clear the display and show the start message</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">clear</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">setCursor</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">0</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"AZ Delivery"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">setCursor</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">0</span><span style="color: #434f54;" color="#434f54">,</span><span style="color: #000000;" color="#000000">1</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">lcd</span><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">print</span><span style="color: #000000;" color="#000000">(</span><span style="color: #005c5f;" color="#005c5f">"One moment...."</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Configure internal clock</span>  <span style="color: #000000;" color="#000000">configTime</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">MYTZ</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #005c5f;" color="#005c5f">"pool.ntp.org"</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Initialize WLAN and connect to the WLAN</span>  <b><span style="color: #d35400;" color="#d35400">WiFi</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">persistent</span><span style="color: #000000;" color="#000000">(</span><span style="color: #00979c;" color="#00979c">false</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <b><span style="color: #d35400;" color="#d35400">WiFi</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">Fashion</span><span style="color: #000000;" color="#000000">(</span><span style="color: #00979c;" color="#00979c">WIFI_STA</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <b><span style="color: #d35400;" color="#d35400">WiFi</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">begin</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">STASSID</span><span style="color: #434f54;" color="#434f54">,</span> <span style="color: #000000;" color="#000000">STAPSK</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #00979c;" color="#00979c">uint8_t</span> <span style="color: #000000;" color="#000000">cnt</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// wait until connection has been established</span>  <span style="color: #5e6d03;" color="#5e6d03">while</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">(</span><b><span style="color: #d35400;" color="#d35400">WiFi</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">status</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #434f54;" color="#434f54">!=</span> <span style="color: #000000;" color="#000000">WL_CONNECTED</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #434f54;" color="#434f54">&&</span> <span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">cnt</span><span style="color: #434f54;" color="#434f54"><</span><span style="color: #000000;" color="#000000">10</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>    <b><span style="color: #d35400;" color="#d35400">Serial</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">println</span><span style="color: #000000;" color="#000000">(</span><b><span style="color: #d35400;" color="#d35400">WiFi</span></b><span style="color: #434f54;" color="#434f54">.</span><span style="color: #d35400;" color="#d35400">status</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #000000;" color="#000000">cnt</span><span style="color: #434f54;" color="#434f54">++</span><span style="color: #000000;" color="#000000">;</span>    <span style="color: #d35400;" color="#d35400">delay</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">500</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #000000;" color="#000000">}</span>  <span style="color: #000000;" color="#000000">newsCnt</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">0</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #d35400;" color="#d35400">step</span> <span style="color: #434f54;" color="#434f54">=</span> <span style="color: #000000;" color="#000000">ST_CLEAR</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #000000;" color="#000000">}</span> <span style="color: #434f54;" color="#434f54">// main loop</span> <span style="color: #00979c;" color="#00979c">void</span> <span style="color: #5e6d03;" color="#5e6d03">loop</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span> <span style="color: #000000;" color="#000000">{</span>  <span style="color: #434f54;" color="#434f54">// show the time</span>  <span style="color: #d35400;" color="#d35400">updateDisplay</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span>  <span style="color: #434f54;" color="#434f54">// Delay for pushing through</span>  <span style="color: #d35400;" color="#d35400">delay</span><span style="color: #000000;" color="#000000">(</span><span style="color: #000000;" color="#000000">500</span><span style="color: #000000;" color="#000000">)</span><span style="color: #000000;" color="#000000">;</span> <span style="color: #000000;" color="#000000">}</span> </pre> <p> <a href="https://drive.google.com/file/d/1yBUrBvsCJ9nFtXCgpq9HA8tHBuQ68Fmk/view?usp=sharing" target="_blank" rel="noopener noreferrer"><strong>Download sketch</strong></a></p> Almost everything we need is included in the ESP8266 package. Only the libraries for the LCD display and for evaluating the XML data are missing. They can be installed via the library management in the Arduino IDE. <p>We enter “I2C LCD” as the search term and find the desired library a little further down the list.</p> <table width="100%"> <tbody> <tr> <td><img src="https://cdn.shopify.com/s/files/1/1509/1638/files/bibliothek_480x480_3445d739-d3ee-4647-9a79-59da3571300c_480x480_1_600x600.jpg?v=1607677600" alt="" style="display: block; margin-left: auto; margin-right: auto;"></td> </tr> </tbody> </table> <p><br>Then we enter “Tiny XML” as the search term and we get the desired library.</p> <table width="100%"> <tbody> <tr> <td><img src="https://cdn.shopify.com/s/files/1/1509/1638/files/TinyXML_480x480_2_600x600.jpg?v=1607677696" alt="" style="display: block; margin-left: auto; margin-right: auto;"></td> </tr> </tbody> </table> <p><br>Before we compile the sketch, we have to enter the access data for the WLAN in place of the asterisks.</p> <p>You may also want to select a different news server, a different feed on this server and / or a different number of messages. Then you have to change the corresponding #define entries. The number of messages should not be greater than 10.</p> <p>Don't be surprised if you get the following warning while compiling.</p> <p><span style="color: #bc3838;">WARNING: The LiquidCrystal_I2C library claims to run on avr architecture (s) and may be incompatible with your current board running on esp8266 architecture (s).</span></p> <p>This warning comes from the fact that an incorrect entry was made in the specifications for the library. The library works fine with ESP8266 MCUs.</p> <p>After all messages from the news server have been displayed, messages are fetched from the server again. The time is continuously updated. It switches automatically between summer time and winter time.</p> <p>Have fun with the replica.</p>
After saving the presettings, we call the board manager via the menu Tools->Board:->Board manager. As search term we enter "esp8266". We get the following entry, which we will then install.


Now we can select a board in the menu Tools->Board:->ESP8266 Boards. We use NodeMCU 1.0...


Now everything is ready to install the sketch for the news reader. Download here.

#include <ESP8266WiFi.h>  //WLAN Unterstützung

#include <TZ.h>           //Zeitzonen Konstanten

#include <LiquidCrystal_I2C.h> //Bibliothek für das LCD Display
#include <TinyXML.h>         //XML-Interpreter zum Lesen des RSS-Feed

//SSID und PSK vom lokalen WLAN
#define STASSID "*********************"
#define STAPSK  "*********************"

//Zeitzone mit Sommer/Winterzeit Information
#define MYTZ TZ_Europe_Berlin

// Timeout zum Lesen des RSS-Feed in Sekunden
#define READ_TIMEOUT 10

//Verarbeitungsschritte
#define ST_CLEAR 0 //neue Daten vom Server holen
#define ST_START 1 //Meldung anzeigen
#define ST_MOVE  2 //Meldung durchschieben
#define ST_END   3 //Meldungsende anzeigen

#define MAXNEWS 10 //Maximale Anzahl der Meldungen
#define RSS_SERVER "www.tagesschau.de" //Nachrichtenserver
#define RSS_FEED "newsticker.rdf"      //Name des Feeds


// LCD Adresse = 0x27, Anzahl Zeichen 16 Anzahl Zeilen 2
LiquidCrystal_I2C lcd(0x27,16,2); 

//WLAN Client Instanz
WiFiClient client;

//XML Interpreter Instanz
TinyXML xml;

//Deutsche Sonderzeichen
uint8_t font [8][9] {
     {0x0c,0x12,0x12,0x0c,0x00,0x00,0x00,0x00}, // 0 °
     {0x11,0x04,0x0a,0x11,0x1f,0x11,0x11,0x00}, // 1 Ä
     {0x11,0x0e,0x11,0x11,0x11,0x11,0x0e,0x00}, // 2 Ö
     {0x11,0x00,0x11,0x11,0x11,0x11,0x0e,0x00}, // 3 Ü
     {0x0a,0x00,0x1e,0x01,0x0f,0x13,0x0d,0x00}, // 4 ä
     {0x0a,0x00,0x0e,0x11,0x11,0x11,0x0e,0x00}, // 5 ö
     {0x0a,0x00,0x12,0x12,0x12,0x12,0x0f,0x00}, // 6 ü
     {0x0c,0x12,0x12,0x14,0x12,0x12,0x14,0x00}  // 7 ß
};


uint8_t buffer[4000];        //Buffer für XML-Interpreter
uint16_t msglen = 0;         //Länge der aktuellen Nachricht
String msg;                  //aktuelle Nachricht
String news[MAXNEWS];        //Speicher für Nachrichten 
uint8_t newsCnt = 0;         //Anzahl der aktuellen Nachrichten im Speicher
uint8_t curNews = 0;         //Index der gerade angezeigten Nachricht
uint8_t step = 0;            //Aktueller Verarbeitungsschritt
uint16_t pos = 0;            //Startposition zum Durchschieben

//Deutsche Umlaute (UTF8) fürs Display codieren
String extraChar(String text){
  String res = "";
  uint8_t i = 0;
  char c;
  while (i<text.length()) {
    c=text[i];
    if (c==195) { //UTF8 Deutsche Umlaute
      i++;
      switch (text[i]) {
        case 164: c=4; break; //ä
        case 182: c=5; break; //ö
        case 188: c=6; break; //ü
        case 159: c=7; break; //ß
        case 132: c=1; break; //Ä
        case 150: c=2; break; //Ö
        case 156: c=3; break; //Ü
        default: c=0;
      }
    } else if (c == 194) { //UTF8 Sonderzeichen
      i++;
      if (text[i] == 176) c=0xdf; else c=0;
    } else if (c > 128) { //normal characters unchanged
      c=255;
    }
    if (c>0) res.concat(c);
    i++;
  }
  return res;
}


//Diese Funktion wird vom XML-Interpreter aufgerufen, wenn ein XML-Tag gelesen wurde
//tagName enthält den vollständigen XML-Pfad des Tags, data den Inhalt des Tags
void XML_callback(uint8_t statusflags, char* tagName, uint16_t tagNameLen, char* data, uint16_t dataLen) {
  if (statusflags & STATUS_TAG_TEXT) {
    //Serial.println(tagName);
    //wenn wir einen Titel-Tag finden, und die maximale Anzahl der Meldungen noch
    //nicht erreicht ist, wird die Meldung gespeichert und der Zähler erhöht
    if (strcasecmp(tagName,"/rss/channel/item/title")==0) {
      data[dataLen] = '\0';
      Serial.printf("%i %s\n",newsCnt,data);
      if (newsCnt < MAXNEWS) { 
        news[newsCnt] = data;
        newsCnt++;
      }
    }
  }
}

//Neue Nachrichten vom RSS-Feed lesen
boolean getNews() {
  boolean res = false;
  boolean timedOut = false;
  char c;
  newsCnt = 0;
  //nur wenn wir eine Internetverbindung haben
  if(WiFi.status()== WL_CONNECTED){
    //zuerst mit dem HTTP-Server verbinden
    Serial.println("Mit Server verbinden");
    if(client.connect(RSS_SERVER, 80)) {
      Serial.println("OK\r\nRequesting data...");
      //Nun können wir die XML-Seite mit dem Feed holen
      client.print("GET /");
      client.print(RSS_FEED);
      client.print(" HTTP/1.1\r\nHost: ");
      client.print(RSS_SERVER);
      client.print("\r\nConnection: Close\r\n\r\n");
      client.flush();
      //den XML-Interpreter vorbereiten
      xml.reset();
      newsCnt = 0;
      uint32_t t = millis(); // Startzeit
      while(client.connected()) {
        if((c = client.read()) >= 0) {
          //Solange wir Zeichen vom Webserver erhalten, werden diese
          //zur Interpretation an den XML Interpreter weitergegeben
          xml.processChar(c);
          delay(1); //Verzögerung 1ms sonst kommt der XML Interpreter nicht nach
          t = millis(); // Reset timeout clock
        } else if((millis() - t) >= (READ_TIMEOUT * 1000)) {
          //Im Falle eines Timeouts wird die Interpretation abgebrochen
          Serial.println("---Timeout---");
          timedOut = true;
          break;
        }
      }
      if (timedOut) Serial.println("Timeout");
      if(!timedOut && (newsCnt > 0)) { 
        //Falls Nachrichten empfangen wurden, wird die erste Nachricht angezeigt
        curNews = 0;
      }
    }
    client.stop();
  } else {
    //war keine Internet Verbindung vorhanden
    //wird ein neuer Verbindungsversuch gestartet
    //und eine Fehlermeldung angezeigt
    news[0] = "Keine Internetverbindung!";
    newsCnt = 1;
    curNews = 0;
  }
}

//Anzeige aktualisieren
void updateDisplay() {
  //erste Zeile Zeit und Datum
  time_t now; //aktuelle Zeit 
  struct tm * s_time; //Zeitstruktur aufgesplittet in Jahr, Monat, Tag, Stunden, Minuten und Sekunden
  char line_buffer[20]; //Buffer für Anzeigenzeile
  now = time(nullptr); //aktuelle Zeit lesen
  s_time = localtime(&now); //für die lokale Zeit in die Zeitstruktur umwandeln
  //Zeilenbuffer mit Uhrzeit und Datum füllen
  strftime(line_buffer,17,"%d.%m.%Y %H:%M",s_time);
  //Uhrzeit auf die serielle Schnittstelle ausgeben
  //Serial.println(line_buffer);
  //Uhrzeit am Display in Zeile 1 anzeigen  
  lcd.setCursor(0,0);
  lcd.print(line_buffer);
  //zweite Zeile Nachrichten
  lcd.setCursor(0,1);
  switch (step) {
    case ST_CLEAR: step = ST_START; //Nächster Schritt
        if (curNews >= newsCnt) {
          lcd.print("Aktualisierung.."); 
          getNews(); //neue Nachrichten holen
          curNews = 0;
        } else {
          curNews++; //nächste Nachricht starten
          lcd.print("                "); 
          if (curNews >= newsCnt) step = ST_END;
        }
        msg = extraChar(news[curNews]);
        msglen = msg.length();
        break;
    case ST_START:lcd.print(msg.substring(0,16));
        pos = 0; //Startposition einnehmen
        step = ST_MOVE;
        break; 
    case ST_MOVE: pos++;
        lcd.print(msg.substring(pos,pos+16));
        //wenn die Nachricht fertig ist, nächste Nachricht
        if (pos > (msglen-17)) step=ST_END;
        break;
    case ST_END: step = ST_CLEAR;
        break;
  }
}

//Setup Funktion
void setup() {
  Serial.begin(115200); //Serielle Schnittstelle initialisieren
  //XML-Interpreter initialisieren
  xml.init((uint8_t *)buffer, sizeof(buffer), &XML_callback);
  //Display initialisieren und Beleuchtung ein
  lcd.init(); //bei älteren Versionen der Bibliothek muss der Aufruf lcd.begin(); heißen  
lcd.backlight();  //Deutsche Umlaute erzeugen  for (uint8_t i = 0; i<8; i++) lcd.createChar(i, font[i]);  //Display löschen und Startmeldung anzeigen  lcd.clear();  lcd.setCursor(0,0);  lcd.print("AZ-Delivery");  lcd.setCursor(0,1);  lcd.print("Einen Moment....");  //Interne Uhr konfigurieren  configTime(MYTZ, "pool.ntp.org");  //WLAN initialisieren und mit dem WLAN verbinden  WiFi.persistent(false);  WiFi.mode(WIFI_STA);  WiFi.begin(STASSID, STAPSK);  uint8_t cnt = 0;  //warten bis Verbindung hergestellt wurde  while ((WiFi.status() != WL_CONNECTED) && (cnt<10)) {    Serial.println(WiFi.status());    cnt++;    delay(500);  }  newsCnt = 0;  step = ST_CLEAR; } //Hauptschleife void loop() {  //Zeit anzeigen  updateDisplay();  //Verzögerung fürs Durchschieben  delay(500); }

 Download Sketch


Almost everything we need is included in the ESP8266 package. Only the libraries for the LCD display and for evaluating the XML data are missing. They can be installed via the library manager in the Arduino IDE.

We enter "I2C LCD" as search term and find, a little further down in the list, the desired library.


Then we enter "Tiny XML" as a search term and get the library we want.


Before we compile the sketch, we need to enter the credentials for the WLAN in place of the asterisks.

You may also want to select a different news server, a different feed on this server and/or a different number of messages. Then you have to change the corresponding #define entries. The number of messages should not be greater than 10.

Don't be surprised if the following warning is displayed during compilation.

WARNING: Library LiquidCrystal_I2C claims to run on avr architecture(s) and may be incompatible with your current board running on esp8266 architecture(s).

This warning is because of an incorrect entry was made in the specifications for the library. The library works fine with ESP8266 MCUs.

After all messages have been displayed by the news server, messages are fetched from the server again. The time is updated continuously. Switching between daylight saving time and standard time is done automatically.

Have fun with the rebuild.

DisplaysEsp-8266Specials

6 comments

Hans-Jürgen Pollmer

Hans-Jürgen Pollmer

Hallo,
mit den Änderungen von Paul läuft der Sketch problemlos.
Ich würde aber gern das liquidcrystal_i2c-Display durch Matrixmodule max7219 ersetzen.
Wie ist der Sketch zu ändern, oder gibt es schon fertige Projekte damit?
Vielen Dank für evtl. Lösungen.

Paul

Paul

Vielen Dank für diese Idee. So, wie ihr sie vorgestellt habt, funktioniert sie leider nicht, da tagesschau.de Daten nur über einen https-Request ausgibt. Aber mit einem kleinen Umbau des Sketches läßt sich der Server überreden, doch Daten zu senden.

1. Erweiterung der Einbindung von Bibliotheken um die SlientSecure-Bibliothek:
#include

2. Die WLAN-Client Instanz ändern auf
WiFiClientSecure client;

3. in der boolean-Routine getNews() den Server-Port für die Client-Verbindung zum Server ändern von 80 auf 443

4. Im Setup vor dem Befehl WiFi.begin folgende Zeile hinzufügen:

client.setInsecure();

Mit diesem kleinen Umbau funktioniert der Sketch und damit auch der RSS-Reader problemlos und zeigt die Titel auf dem LC-Display an.

Der Befehl “client.setInsecure()” ermöglicht das Abfragen von Daten vom HTTPS-Server, ohne den FIngerprint senden zu müssen, der sonst vorhanden sein müsste, sich aber in einem bestimmten Interval immer wieder ändert.

Harry

Harry

Der Tagesschau Feed kann nicht mehr geladen werden da die Server nur noch verschlüsselte Verbindungen beantworten.
Also entweder das Programm reparieren oder auf einen unverschlüsselten Feed ausweichen. z.B.
#define RSS_SERVER “newsfeed.zeit.de” //Nachrichtenserver
#define RSS_FEED “index” //Name des Feeds

Wominator

Wominator

Sehr geehrter Herr Lechner,
ich habe dieses Projekt nachgebaut, mit einem LCD 20×4 und einem D1Mini. Display, WiFi usw. funktioniert, aber der RSS-Feed wird nicht abgerufen. Auf dem Display erscheint das aktuelle Datum, die Uhrzeit und “Aktualisierung..” Dann passiert nichts mehr.
Im Seriellen Monitor wird angezeigt:
01:13:08.880 → Mit Server verbinden
01:13:08.880 → OK
01:13:08.880 → Requesting data…
01:13:11.088 → Mit Server verbinden
01:13:11.088 → OK
01:13:11.088 → Requesting data…
01:13:13.296 → Mit Server verbinden
01:13:13.343 → OK
01:13:13.343 → Requesting data…
01:13:15.535 → Mit Server verbinden
01:13:15.582 → OK
01:13:15.582 → Requesting data…
01:13:17.758 → Mit Server verbinden
01:13:17.812 → OK
Egal, ob ich den RSS-Feed von der tagesschau oder von Heise eingebe, immer das selbe Ergebnis. Haben Sie eine Idee, warum der Feed nicht geladen und angezeigt wird?
Danke im Voraus!
Womi

Bernd-Steffen Großmann

Bernd-Steffen Großmann

Hi Anthony, I have this problem (the first two letters are not readable) too, but only with iOS (Safari). It works properly with Chrome, Firefox, and other browsers on Windows or Android. Sincerely Bernd-Steffen

Anthony Goodhew

Anthony Goodhew

Formatting of this blog not working properly.

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN