Display Live Inspirational Quotes on M5Stack Core

In this Visual Programming Visuino tutorial, we'll use the M5Stack Core2 to retrieve inspirational quotes from a free online API and display them on the screen. Although this example uses the M5Stack Core2, you can use any ESP32 or similar Wi-Fi-enabled board.

When the device starts, it automatically connects to your Wi-Fi network and requests a random quote from api.quotable.io. The quote is displayed immediately on the screen.

Every 20 seconds, the ESP32 automatically requests and displays a new random quote. You can easily change this interval in Visuino to any timing you prefer.

If you're using the M5Stack Core2, you can also press the button at any time to instantly fetch and display another random quote without waiting for the timer.

The quote data is received in JSON format and processed directly in Visuino. The visual programming environment extracts the quote text and author from the response, making it easy to display them on the screen.

Using Visuino's drag-and-drop interface, you can quickly configure the Wi-Fi connection, send HTTP requests, parse JSON responses, and create an internet-connected application without writing complex code.

This project demonstrates how to build a real-time IoT application that retrieves live data from a web API and presents it in an attractive way.

You can easily expand the project by saving favorite quotes, adding text-to-speech, displaying quotes on external displays, using different fonts and animations, or connecting to other online APIs.

For more information about the API used in this tutorial, visit:

https://api.quotable.io

STEP 1
What You Will Need
  1. ESP32 Basic Core IoT Development Kit or any other Core Kit
  2. Visuino program: Download Visuino

What You Will Need

What You Will Need photo 2

STEP 2
Start Visuino, and Select the M5 Stack Core Board Type

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "M5 Stack Core" as shown on Picture 2

Start Visuino, and Select the M5 Stack Core Board Type

Start Visuino, and Select the M5 Stack Core Board Type photo 2

STEP 3
WiFi Setup

Select M5 Stack Core board and in the editor Modules>WiFi>Access Points, click on [...] button, so that "Access points " window will open.In this editor drag the WiFi access point to the left side.

  1. In the properties window Under "SSID" put the name of your WiFi Network
  2. Under "Password" put the access password for your WiFi network
  3. Close the "Access points" window
  4. On the left in editor select Modules>Wifi>Sockets, click on [...] button, so that "Sockets" window will open Drag the TCP/IP Client from right to the left side, then Under Properties window set port: 37 and host: api.quotable.io
  5. Close the "Sockets" window

WiFi Setup

WiFi Setup photo 2

WiFi Setup photo 3

WiFi Setup photo 4

WiFi Setup photo 5

WiFi Setup photo 6

STEP 4
In Visuino Set Display

Select M5 Stack Core board and in the properties window expand "Modules>TFT Display>Elements" Click on the Elements 3 Dots

  1. In the Elements window Drag "Text Field" to the left and in the properties window set size to 2,, Wrap to True
  2. In the Elements window Drag "Text Field" to the left and in the properties window set size to 2, Wrap to True and Y to 80.
  3. Close the Elements Window

In Visuino Set Display

In Visuino Set Display photo 2

In Visuino Set Display photo 3

In Visuino Set Display photo 4

STEP 5
In Visuino Add Components
  1. Add "Debounce Button" component
  2. Add "HTTP Client" component
  3. Add 2X "Delay" component
  4. Add "Char To Text" component
  5. Add "Start" component
  6. Add "Split JSON Object" component

In Visuino Add Components

In Visuino Add Components photo 2

In Visuino Add Components photo 3

In Visuino Add Components photo 4

In Visuino Add Components photo 5

STEP 6
In Visuino Parsing JSON
  1. With the mouse right click on the "SplitJSONArray1" and in the menu click on the "Parse JSON Array.."

In the "JSON Array" window paste this sample code(avalible on api.quotable.io/random ) Or copy paste the following:

{"_id":"es6wl_dKJo","content":"The human spirit must prevail over technology.","author":"Albert Einstein","tags":["Technology"],"authorSlug":"albert-einstein","length":46,"dateAdded":"2021-03-26","dateModified":"2023-04-14"}

STEP 7
In Visuino Set Components


STEP 8
In Visuino Connect Components
  1. Connect "M5Stack Core" >Buttons> [A] pin [Out] to "Button1" pin [In]
  2. Connect "Delay1" pin [Out] to "CharToText1" pin [Clock]
  3. Connect "Delay1" pin [Out] to "Arduino.Modules.WiFi.Sockets.TCP Client1 [api.quotable.io:80]" pin [Disconnect]
  4. Connect "Button1" pin [Out] to "HTTPClient1.Requests.GET1" pin [Clock]
  5. Connect "Start1" pin [Out] to "Delay2" pin [Start]
  6. Connect "Delay2" pin [Out] to "HTTPClient1.Requests.GET1" pin [Clock]
  7. Connect "Delay2" pin [Out] to "Delay2" pin [Start]
  8. Connect "HTTPClient1.Requests.GET1.Response" pin [Content] to "CharToText1" pin [In]
  9. Connect "HTTPClient1" pin [Out] to "Arduino.Modules.WiFi.Sockets.TCP Client1 [api.quotable.io:80]" pin [In]
  10. Connect "CharToText1" pin [Out] to "SplitJSON1" pin [In]
  11. Connect "SplitJSON1.Elements.content" pin [Out] to "Arduino.Modules.Display.Elements.Text Field1" pin [In]
  12. Connect "SplitJSON1.Elements.author" pin [Out] to "Arduino.Modules.Display.Elements.Text Field2" pin [In]

In Visuino Connect Components

In Visuino Connect Components photo 2

In Visuino Connect Components photo 3

STEP 9
Generate, Compile, and Upload the Code

In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

Generate, Compile, and Upload the Code

STEP 10
Play

If you power the M5 Stack Core, the display should start showing the Quote and if you press the button the display should show a new quote, it will also show a new quote every 20s (you can change the interval in the delay component).

Congratulations! You have completed your Internet Time project with Visuino. Also attached is the Visuino project, that I created for this Tutorial. You can download and open it in Visuino: https://www.visuino.com

icon M5STACK-Core-api-quotes.zip 24KB Download(0)
License
All Rights
Reserved
licensBg
0