RSS FEED OLED ESP8266
ESP8266 Based RSS Feed on color OLED
This is an example of RSS Feed implementation on ESP8266 using MQTT as transport protocol and SSD1331 based color OLED screen as display
What is RSS?
RSS is a standard for publishing feeds to the clients. It is mostly used to get feeds regarding, news, blogs. etc.. There are various clients that are available, but the aim of the project is to show how that can be achieved at Hardware level, using a simple yet powerful microcontroller namely ESP8266. It also helps understand how to use the well known MQTT protocol and Python to parser the feed data. The primary feed are obtained from BBC, as they are easily parsed by using the feedparser module. The next update will include a little bit advance parser that will be based on Beautiful Soup module. The main benefit of RSS is that the user do not need to go the website to get the news, the news are pushed to the user.
What is MQTT?
MQTT is a light weight protocol that is designed on top of well known TCP/IP stack. The main benefit of MQTT is the library that are already available on all major languages. For this project I have used Python, as it is an easy to learn language for beginners, and its well known philosophy batteries included helps newcomer stay away from setting up all the necessary bits. MQTT follows the Publish-Subscribe model for data transport among the clients. In this model, there is a central broker that manages all the data transport, among the connected clients. This makes MQTT one of the best choice for IOT application.
Benefits of MQTT
- It is extremely light weight (In terms of code)
- Easy to implement (Library for many language)
- Provides QoS (Helps ensure data delivery)
- Low Bandwidth requirement (Can run on 2G, or Dial UP ;-) )
- 250 MB Payload limit
- Less Maintenance
There are three QoS level for message Delivery
- QoS 0
- Data is sent only once
- Do not survive connection loss
- QoS 1 (At least once)
- Data might be sent several time
- Survives connection loss
- QoS 2
- Data is sent only once never again
- Data survives connection loss
In this project I have used Mosquitto as the broker, and used Ubuntu Server running on Digital Ocean, they provide extremely cheap and easy to use service, the base one for just 5$ per month. The reason behind using a cloud based server, is that the server exposes a public IP, that can be easily connected from any network and prevents the so called connection dilemma caused by the clients being behind a NAT.
NAT is short for Network Address Translation, and this is used by almost every Internet Service Provider, as it is a really great and robust security measure, that helps prevent attack, till some client that is behind the NAT initiates the connection. This ability or a loophole in the system helps establish a connection without worrying about any security issues. As the client is opening a connection, the connection is considered authentic and not blocked at all.
The paho python client is used for establishing a connection to the server. Mosquitto server keeps on running in the background, and there is a python feed parser that parses the RSS feed and publish on a given topic, and the ESP client also connects to the same server and subscribes to the same topic.
Data is mostly sent as Strings directly, so sending image directly is not possible. So in python the data is first converted to bytearray and then sent using MQTT, and on the receiving end the byte data is written to a file, and then saved as an image file, which is then displayed on the OLED screen. The feed file in the repository have been commented for proper understanding.
On the ESP8266 side, the text data is obtained as string, so no further processing is needed, but for the images, the data needs to be combined in a file. So for this, the total length of the data is compared to the current size of the payload, if the size is equal, it means that string have been obtained, but if it is not equal, than it means a bigger data is obtained, and that...
Read more »