This is an experiment of RSS reader using Arduino core for the ESP 32 and OLED character display.
Using ESP-WROOM-32, it is very easy to connect to the Internet. I made an RSS reader, which displays information to an OLED character display.
To analyze an RSS document, I made a shoddy SAX-“like” XML parser, it’s shoddy…
Experiment
Analyzing RSS
I made a shoddy SAX-“like” XML parser. As it is shoddy, it is not a SAX.
The maximum length of tag name is 32, this can be configured. And if the XML document contains error, I am not sure how it works.
I prepared callback functions below. I am not an XML expert, terminology and/or meaning of them may be wrong.
Function
Description
Parameter
Remarks
foundXMLDecl()
Beginning of an XML document.
none
foudXMLEnd()
End of an XML document.
none
foundPI()
Found a Processing Instruction.
Name of Processing Instruction.
foundSTag()
Found a start tag.
Name of tag, number of attributes, attributes
foundETag()
Found an end tag.
Name of tag
foundEmptyElemTag()
Found an empty element tag.
Name of tag, number of attributes, attributes
foundSection()
Found “<!name”.
Name
not tested
beginCharacter()
Beginning of characters.
none
foundCharacter()
Found a character.
Character
A character outside of tag or inside of CDATA. This is called by each character.
endCharacter()
End of Characters.
none
As this parser reads one character at a time, we need to make a function to return a character. At the end of document, it needs to return EOF. The httpGetChar() function below implements it.
Calling a parser() method, it continues to read each one character until it reads EOF, before the parser() function returns.
Sketch
At the first row a fixed string is displayed and at the second row information is displayed. As few buffering is made(only 20 characters to display), sometimes a timeout may occusr while connecting to the web site.
Please edit lines 10 to 22 to fit your environment. The sketch below read CNN(title) and BBC(description)
The OLED character display I used is here(in Japanese).
You can download OLED library here and XML parser here.