The M5Stack PaperS3 is an excellent choice for creating an information panel capable of displaying data from various types of sensors. But it can also visualize content pulled from multiple sources on the internet—such as weather information and forecasts, stock prices, news, and lots of other useful (and sometimes just fun) data.
To access this kind of content, many services offer what's known as an API—an interface that allows us to "talk" to a website in order to send or receive structured data.
In this article, I’ll explain what an API is, how to use one, and as a practical example, we’ll build a motivational quote viewer that automatically downloads inspirational quotes every 15 minutes and displays them on the PaperS3 screen.
If you're not familiar with the PaperS3 features, I recommend checking out this previous article where I do a full review and show a simple example.What is an API?
We, as users, access websites and their services using a browser and their interface. But an application running on a computer or microcontroller needs other mechanisms to exchange data. That’s where APIs (Application Programming Interfaces) come in: they define a set of rules that allow another application or service (not a human) to access a website and request data or perform functions.
RESTful APIAPIs can be implemented in many ways. In the case of a web API, the most common method is through the HTTP protocol using methods like GET or POST. These typically follow a methodology called REST (Representational State Transfer), which is why they are known as RESTful APIs (or simply REST APIs).
Key features of a REST API include:
- Uses the HTTP protocol: the same one used by web browsers.
- Follows the client–server model: a client makes requests and the server responds.
- Accesses resources via a URL: each resource has its own address, called an endpoint.
- Utilizes standard HTTP methods: GET, POST, PUT, DELETE.
- Treats each request independently: no context is stored between requests (this is called stateless).
- The server replies with a status code (e.g., 200 = OK) and optionally with data in a standard format like JSON.
As mentioned earlier, many websites are accessible through REST APIs. Some are paid, others are free but require registration to get an access token or key, and others are completely open. Examples include:
- OpenWeather: Weather data
- Todoist: Access to tasks and projects
- ZenQuotes: Inspirational quotes
- The Cat API: Random cat images
- Stock Data: Financial information
- ChuckNorris.io: Fun Chuck Norris facts ☺️
Next, I’ll show you how to create an application for the M5Stack PaperS3 that downloads motivational quotes throughout the day using the ZenQuotes API. The process is quite general, so you’ll be able to adapt it easily for other REST API-based websites as well.
ZenQuotesZenQuotes is a website that provides a free service to fetch motivational quotes from various authors and topics via its API.
The basic functionality is completely free and requires no registration or token. However, for advanced features or heavy usage, a paid account is needed.
To access its API, you make a GET request with the following format:
https://zenquotes.io/api/[mode]/[key]?option1=value&option2=value
Where mode
can be:
- random: Returns a single random quote
- quotes: Returns multiple quotes (ideal for caching and displaying locally)
- today: Returns the featured quote of the day
- author: Filters quotes by author (used with other modes; premium only)
- image: Returns an image (premium only)
Example endpoint that returns a random quote:
https://zenquotes.io/api/random
And to get quotes from a specific author:
https://zenquotes.io/api/quotes/author/[author-name]/[token]
Any request to the API returns data in JSON format with the following keys:
q
= Quote texta
= Author namei
= Author image (premium only)c
= Character count of the quoteh
= Quote in HTML format
The response is an array of elements in this format. When calling /quotes
, the response includes multiple items. In endpoints like /random
or /today
, it includes just one.
Example response from the /today
endpoint:
[{
"q": "Even in the grave, all is not lost.",
"a": "Edgar Allan Poe",
"h": "<blockquote>“Even in the grave, all is not lost.” — <footer>Edgar Allan Poe</footer></blockquote>"
}]
Requests and response handling can be easily coded in Arduino or MicroPython, but for this project, I’ll be using UIFlow 2, to make it more visual and beginner-friendly.
The ProgramThe structure of the program is straightforward and consists of the following tasks:
- Initialize the device
- Connect to the Wi‑Fi network
- Make the request to the ZenQuotes site
- Display the quote and its author on the screen
- Power off the device and reboot after 15 minutes
The most complex part is the function that displays text on the screen, because I designed it to preserve word separation and avoid splitting words mid‑line. I’ll explain how that works step by step.
InitializationDuring initialization (in addition to the default setup performed by UIFlow), the screen background is set using an image widget that covers the entire display.
The image (a file named FondoEPD16p.png
) is uploaded to the PaperS3’s flash memory using the Web Terminal and then made visible using the Set image0 Show
block in the code.
Next, the font size, text color, and background color are set. The cursor position is also defined for upcoming text prints at coordinates 20, 80.
The Wi‑Fi connection is established by calling the ConnectWifi
function, which is defined using the following blocks:
This function sets the Wi‑Fi to STA (station) mode and connects to your home network. Remember to replace the hidden SSID and password with your actual network details. The function returns the connection status, which allows you to verify whether the connection was successful.
Sending the Request to ZenQuotesIf the connection to the Wi‑Fi network fails, an error message is shown. If it succeeds, a request is sent to the ZenQuotes website.
The HTTP request uses the GET method and accesses the endpoint https://zenquotes.io/api/random/
. As mentioned earlier, this endpoint returns a list with a single element in JSON format, containing the quote, author, and additional information.
In this part of the program, the server response is processed. If there’s no error, the quote and author are displayed on the screen using the PrintLargeText
function.
As shown in the image above, the first step is to check whether the response code from the server is 200 (which means everything went OK). If it isn’t 200, an error message is shown. If it is, the received information is parsed.
First, the JSON data returned by the server is stored in the variable ResponseData
.
Next, using the get key
block, we look for the key q
, which corresponds to the quote, inside element 0 of ResponseData
(a list, even though it only contains one element). The value of that key is stored in the variable Text
and passed as a parameter to the PrintLargeText
function, which displays it on screen.
The same process is repeated to find the key a
, corresponding to the author’s name. The value is again stored in Text
and printed using PrintLargeText
.
Let’s now see what this function does:
The idea is to print the full words of the quote without breaking them at the edge of the screen.
To do this, the text to be printed is split into a list of words called Words
. Then, using a count
loop, these words are printed one by one while ensuring the total number of characters plus the spaces does not exceed 20—the maximum width I set. If the next word would exceed this limit, a new line is started further down, and the process is repeated until all words are printed.
To save battery, after displaying the text the program pauses for 2 seconds, then powers off the PaperS3 and schedules it to wake up in 15 minutes.
Everything above is done inside the Setup
block, and nothing is done in the Loop
block.
Here’s the complete program (click to enlarge)
The program is published in the Project Zone and can be found at this link.
And here’s what the PaperS3 looks like, showing inspirational quotes and stuck to my fridge with the built-in rear magnets ☺️
The M5Stack PaperS3 stands out not only for its low-power EPD screen but also for its ability to become a window into the digital world—displaying useful, interesting, or simply inspiring information.
In this project, we learned how to use a REST API to connect to a web service like ZenQuotes, retrieve content in JSON format, and display it clearly on screen. We did all of this using UIFlow 2, showing that you don’t need to write much code to create connected and visually engaging applications.
Beyond this example with motivational quotes, the same structure can be easily adapted to display:
- the daily weather,
- a to-do list,
- financial data,
- news headlines
- or any other data accessible through an API.
Combined with the UIFlow 2 programming environment, the PaperS3 becomes an excellent tool for entering the world of IoT and web-connected programming in a simple and visual way. Its ease of use makes it ideal for educational projects—where the goal is to learn about APIs, sensors, and automation—as well as for home maker projects, like information panels, daily planners, or digital boards that bring both functionality and style to your home.
If you have any questions or suggestions, feel free to leave them in the comment section below.
For more information and projects, you can check out my blog and social media.
See you next time! 🚀
Comments