LUA Amica V2 module with ESP8266 12F

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

13 comments

Andreas Wolter

Andreas Wolter

@wominator: sind es identische D1 Mini?
Haben Sie den Exception Decoder probiert, wie es in der Fehlermeldung steht?

wominator

wominator

Ich habe heute stundenlang versucht, diesen Sketch ans Laufen zu bekommen. D1 Mini und einem LDC 16×2. Im März 2021 habe ich diesen Sketch, gleiches Board und LCD 20×4 zum Laufen gebracht und läuft bis heute. Wenn ich den Sketch kompiliere und hochlade, passiert folgendes:

18:31:02.094 > ets Jan 8 2013,rst cause:2, boot mode:(3,6)
18:31:02.094 →
18:31:02.094 → load 0×4010f000, len 3460, room 16
18:31:02.094 → tail 4
18:31:02.094 → chksum 0xcc
18:31:02.094 → load 0×3fff20b8, len 40, room 4
18:31:02.094 → tail 4
18:31:02.094 → chksum 0xc9
18:31:02.094 → csum 0xc9
18:31:02.094 → v000627d0
18:31:02.094 → ~ld
18:31:03.441 → 7
18:31:03.942 → 7
18:31:04.443 → 7
18:31:04.922 → 7
18:31:05.407 → 7
18:31:05.946 → 7
18:31:07.163 → 7
18:31:07.696 → Mit Server verbinden
18:31:08.748 → OK
18:31:08.748 → Requesting data…
18:31:10.004 → 0 G20-Gipfel: Draghi spricht von großem Erfolg
18:31:10.651 → 1 Kommentar: G20-Beschlüsse sind nur der Anfang eines Weges
18:31:11.352 → 2 Klimagipfel beginnt in Glasgow: "Hört den Schrei der Erde"
18:31:12.107 → 3 Klimaneutralität bis 2060: China – Verschmutzer und Vorreiter
18:31:12.808 → 4 UN-Konferenz in Glasgow: Die wichtigsten Fragen rund ums Klima
18:31:13.456 → 5 UN-Report: Die sieben vergangenen Jahre waren die wärmsten
18:31:14.141 → 6 Spahn will Gipfel zu "Booster-Impfungen"
18:31:14.810 → 7 Liveblog: + Merkel dringt auf rasche Maßnahmen +
18:31:15.495 → 8 Coronavirus-Lage in Deutschland – aktuelle Zahlen
18:31:16.190 → 9 Coronavirus weltweit: Aktuelle Fallzahlen zu Covid-19
18:31:16.813 → 10 Aktueller Stand der Corona-Impfungen in Deutschland
18:31:17.515 → 11 Covid-19: Wie ist die Lage auf den Intensivstationen?
18:31:18.181 → 12 Atemwegserkrankung: RS-Virus – viele Kinderkliniken voll
18:31:18.836 → 13 Kohlegegner demonstrieren in Lützerath gegen Tagebau
18:31:19.569 → 14 Steuerentlastungen: Lindner kritisiert Ampel-Partner
18:31:20.325 → 15 Mützenich: Bei Ministeramt sollte Esken SPD-Parteivorsitz abgeben
18:31:20.973 → 16 Livestream: Die Nachrichten auf tagesschau24
18:31:21.559 → 17 Wahlen in Japan: Regierungskoalition bleibt an der Macht
18:31:22.276 → 18 Türkischer Frachter: Migranten dürfen in Griechenland von Bord
18:31:22.992 → 19 Taliban-Chef Achundsada offenbar aufgetreten
18:31:23.679 → 20 90 Jahre Airstream: Der amerikanische Traum vom Reisen
18:31:24.363 → 20 US-Hummerfischer kritisieren Regeln zum Schutz der Wale
18:31:25.081 → 20 Uhren auf Normalzeit zurückgestellt: Die geschenkte Stunde
18:31:25.780 → 20 Bundesliga: Augsburg schlägt Stuttgart 4:1
18:31:26.434 → 20 CDU-Vorsitz: Funktionäre proben Basisdemokratie
18:31:27.198 → 20 Wegen starker Sonneneruption: Polarlichter über Deutschland?
18:31:27.883 → 20 Greenpeace: Weniger Tiere für besseres Klima
18:31:28.597 → 20 Welche Rolle spielt Deutschland beim Klima-Gipfel?
18:31:29.298 → 20 US-Schauspieler Baldwin äußert sich zu tödlichem Schuss
18:31:29.999 → 20 Wiederaufbau von Gaza kommt nur mühsam voran
18:31:30.701 → 20 Friedlicher Protest gegen G20-Gipfel in Rom
18:31:31.418 → 20 Hunderte Klimaaktivisten demonstrieren in Glasgow
18:31:32.103 → 20 EU und USA legen Handelsstreit über Sonderzölle bei
18:31:32.858 → 20 Was sich durch die globale Mindeststeuer verändert
18:31:33.559 → 20 Immobilienentwickler Evergrande wendet Pleite ab
18:31:34.308 → 20 Marktbericht: US-Börsen bleiben auf Rekordkurs
18:31:35.043 → 20 Warum Deutschland wohl bald Impfstoff vernichten muss
18:31:35.810 → 20 Extremismus-Verdacht: BND erteilt Professor Hausverbot
18:31:36.464 → 20 Abschiebepolitik: Vom Allgäu nach Afghanistan
18:31:37.182 → 20 Bundesliga: Frankfurt rettet bei 1:1 Punkt gegen Leipzig
18:31:37.868 → 20 Bundesliga: Bayern München schlägt Union Berlin 5:2
18:31:38.569 → 20 Zukunftspodcast: Nur nachhaltiger Fischfang? Was dann?
18:31:39.270 → 20 faktenfinder-Podcast: Aufklären über "Fake News"
18:31:39.871 →
18:31:39.871 → -——————- CUT HERE FOR EXCEPTION DECODER -——————
18:31:39.871 >
18:31:39.871 → Exception (0):
18:31:39.871 → epc1=0×402012fe epc2=0×00000000 epc3=0×00000000 excvaddr=0×00000000 depc=0×00000000
18:31:39.871 →
18:31:39.871 → >>>stack>>>
18:31:39.871 →
18:31:39.871 → ctx: cont
18:31:39.871 → sp: 3ffffd70 end: 3fffffc0 offset: 0190
18:31:39.871 → 3fffff00: 00000000 3ffeec7c 3ffefe38 402012e5
18:31:39.871 → 3fffff10: 3ffeffc8 3ffeec7a 3ffefe60 4020488c
18:31:39.918 → 3fffff20: 00000000 00000040 00000014 3ffeec7b
18:31:39.918 → 3fffff30: 3ffeed70 3ffeec7a 3ffefe60 402013aa
18:31:39.918 → 3fffff40: 312e3133 30322e30 31203132 31333a38
18:31:39.918 → 3fffff50: 40105c00 001a5a42 3fff0178 00000000
18:31:39.918 → 3fffff60: 4025237e 00000007 3ffefe70 00000001
18:31:39.918 → 3fffff70: 617ed2de 00000000 000001f4 40205744
18:31:39.918 → 3fffff80: 3fff0a9c 40201a38 3fff0068 3fff0068
18:31:39.918 → 3fffff90: 3fffdad0 00000000 3fff0054 402015b5
18:31:39.918 → 3fffffa0: 3fffdad0 00000000 3fff0054 40205864
18:31:39.918 → 3fffffb0: feefeffe feefeffe 3ffe8694 40100df9
18:31:39.971 → <<<stack<<<
18:31:39.971 →
18:31:39.971 → -——————- CUT HERE FOR EXCEPTION DECODER -——————

Wieso passiert das mit dem anderen D1Mini und dem LCD20x4 nicht? Dieser lädt die Feeds von 0 bis 19 (habe ich so eingestellt) und stellt sie dann korrekt dar.
Hier lädt dieser D1Mini bis 19 und dann noch 22 Feeds, bis er abstürzt. Die Hinweise von “Paul” habe ich eingebaut, sonst bekommt man ja gar keine Feeds mehr.

Der Sketch:
#include //WLAN Unterstützung
#include
#include //Zeitzonen Konstanten

#include //Bibliothek für das LCD Display
#include //XML-Interpreter zum Lesen des RSS-Feed

//SSID und PSK vom lokalen WLAN
#define STASSID “XXXXXX” //enter your SSID here
#define STAPSK “XXXXXX” //enter your password here

//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 20 //Maximale Anzahl der Meldungen
#define RSS_SERVER “www.tagesschau.de” //Nachrichtenserver
#define RSS_FEED “newsticker.rdf” //Name des Feeds

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

//WLAN Client Instanz
WiFiClientSecure client;

//XML Interpreter Instanz
TinyXML xml;

//Deutsche Sonderzeichen
uint8_t font 89 {
{0x0c,0×12,0×12,0×0c,0×00,0×00,0×00,0×00}, // 0 °
{0x11,0×04,0×0a,0×11,0×1f,0×11,0×11,0×00}, // 1 Ä
{0x11,0×0e,0×11,0×11,0×11,0×11,0×0e,0×00}, // 2 Ö
{0x11,0×00,0×11,0×11,0×11,0×11,0×0e,0×00}, // 3 Ü
{0x0a,0×00,0×1e,0×01,0×0f,0×13,0×0d,0×00}, // 4 ä
{0x0a,0×00,0×0e,0×11,0×11,0×11,0×0e,0×00}, // 5 ö
{0x0a,0×00,0×12,0×12,0×12,0×12,0×0f,0×00}, // 6 ü
{0x0c,0×12,0×12,0×14,0×12,0×12,0×14,0×00} // 7 ß
};

uint8_t buffer4000; //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©;
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, 443)) {
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©;
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
news0 = “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_buffer20; //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(“Kommt gleich..”);
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(); //on error – try lcd.begin();
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(" Lupus Transitus");
lcd.setCursor(0,1);
lcd.print(“Moment….”);
//Interne Uhr konfigurieren
configTime(MYTZ, “pool.ntp.org”);
//WLAN initialisieren und mit dem WLAN verbinden
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
client.setInsecure();
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);
}

Jos Wich

Jos Wich

Ufff, da muss ich erst einmal drauf kommen.
Auf einem Ubuntu Laptop habe ich mit einem relativ sauberen Arduino V1.8.15 mit dem Boardverwalter für ESP8266 experimentiert. Mit der Version 3.0.2 (die derzeit letzte Version) bricht die Kommunikation ab. in einer Github Diskussion wurde über einen Memory Leak gesprochen. Also habe ich die vorgeschlagene 2.3.0 getestet, da ist aber TZ.h nicht verfügbar.

Aber BRAVO !!! mit der Version 2.7.4 für das ESP8266 Board läuft jetzt die Anzeige. Ich melde mich wieder wenn ich weitere Infos habe.

Kinders, es bleibt ein Hobby, damit muss ich kein Geld verdienen, es darf auch mal holprich sein, so lange wir anschliessend eine Lösung finden. Der Weg ist das Ziel.

Viel Spaß noch, aber meine 2 × 4 Matrix Version läuft deutlich flüssiger und erlaubt deutlich einfachere Wechsel zu anderen RSS feeds.

Jos

Jos Wich

Jos Wich

dabei benutze ich derzeit die Arduino Version 1.8.13.
die Meldung beim compilieren:
esptool.py v3.0
Serial port COM3
Connecting….
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 8c:aa:b5:xxxxxxxxxxxx
Uploading stub…
Running stub…
Stub running…
Configuring flash size…
Auto-detected Flash size: 4MB
Erasing flash (this may take a while)…
Chip erase completed successfully in 1.3s
Compressed 403488 bytes to 297361…
Writing at 0×00000000... (5 %)

Ja, dann habe ich auch den Flash Speicher im Chip mal komplett gelöscht

Was mache ich falsch ?

Jos

Jos Wich

Jos Wich

Danke für die schnelle Antwort Gerald, nur frag’ ich mich ob der download link eine andere Version liefert. Ich habe heute ein neues AZ-Delivery ESP82266-12F Board ausgepackt. Dann den code in einer frischen Datei geladen, die “Paul” updates übernommen (Port 443, ClientSecure, etc), auch
while(client.connected() && (newsCnt < MAXNEWS)) ersetzt
dann mit der Anzahl MAXNEWS gespielt, 5, 8 oder 10 und immer bricht das Board zusammen wenn genau diese Menge an Nachrichten im Serial Monitor gezeigt wurden….
13:18:26.615 > 6 Aktueller Stand der Corona-Impfungen in Deutschland
13:18:27.261 → 7 Covid-19: Wie ist die Lage auf den Intensivstationen?
13:18:27.261 →
13:18:27.261 → -——————- CUT HERE FOR EXCEPTION DECODER -——————
13:18:27.261 →
13:18:27.261 → Exception (0):
13:18:27.261 → epc1=0×40201302 epc2=0×00000000 epc3=0×00000000 excvaddr=0×00000000 depc=0×00000000
13:18:27.309 →

ich mag die Idee, komme aber leider nicht voran. Die Matrix Version läuft problemlos.

Danke im Voraus für weitere Hilfe

Jos

Gerald Lechner

Gerald Lechner

Das weitere Einlesen kann abgebrochen werden indem in der Funktion getNews() die Zeile
while(client.connected())
durch
while(client.connected() && (newsCnt < MAXNEWS))
ersetzt wird.

Jos Wich

Jos Wich

eine sehr interessante Idee, da habe ich mich echt gefreut.

Mittlerweile habe ich aber erfolgreich die andere Version mit 2 x MAX7219 aktiv. Auch mit anderen RSS Feeds. Nur bei dieser Variante holt sich der Buffer sehr viele Nachrichten die alle bis zu
MAXNEWS hochzählen. Aber wenn z.B. MAXNEWS = 5, dann bekommen alle nachfolgenden Nachrichten diese gleiche newscnt Zahl, denn die wird nicht weiter erhöht.
if (newsCnt < MAXNEWS) {
news[newsCnt] = data;
newsCnt++;

Leider finde ich nicht die Verzweigung dass dann keine weiteren Infos abgeholt werden sollen, sondern auf dem 1602 angezeigt werden müssen. Zwangsläufig muss dann der Buffer überlaufen und startet der 8266 immer wieder neu.

Gerne höre ich wo ich diesen Fehler korrigieren kann. Meine einzige Änderung im Aufbau ist die I2C Verbindung zum 1602, aber da kann ich mir nicht vorstellen dass da das Problem liegt.

Hoffentlich bis bald !

viel Spaß beim basteln
Jos

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