To achieve my goal, I needed to glean information from Twitter first of all. To avoid any authentification process pertaining to Twitter API, I chose to use https://cdn.syndication.twimg.com to get the number of followers of a Twitter account using its screen name. When I managed to get information from Twitter, I programmed a web application in PHP, named Twitter Notifier Station, to print a data packet containing the number of followers, the screen name, the previous follower status, and the current follower status. By subscribing to TheAmplituhedron, you can use Twitter Notifier Station with your unique notifier path provided by TheAmplituhedron API as explained below. Nevertheless, if you want to create your web application on your server for this particular project, I leave the source code of the application below.
For connecting the host and gathering the data packet produced by the aforementioned web application, I used an ESP-WROOM-32 Development Board with which I was able to make an HTTP Get Request to my SSL protected server using the root certificate. To display information after collating data packets transferred from the web application, I used a 20x4 LCD Screen with I2C LCD Display Module. And, when there is a change in the number of followers of my Twitter account, I programmed ESP32 to display an alert message and tone generated by a buzzer.
You can visit my website here and my Twitter page here.
First of all, download the required libraries for Arduino IDE below to continue the following steps.
Required Libraries:
For ESP32 Development Board, click here.
For I2C LCD Display Module, click here.
Creating a web application in PHP to transfer information from Twitter
Without engaging an authentification process, you can get information from Twitter using the cdn.syndication.twimg third party host service with a screen name as shown on the source of the application below.
To permanently register a screen name and accurately track the previous status and the current status of the registered screen name, we need to save information coming from Twitter to a MySQL database.
Then, we can check whether there is a change in the number of followers of the registered Twitter account comparing the previous status and the current.
I programmed a web application named Twitter Notifier Station which can perform tasks above through a user-friendly control panel in which you can change the registered screen name anytime. It generates a unique notifier path transferring data for each user. You can inspect Twitter Notifier Station here.
Nevertheless, I leave the source code of the notifier path, if you want to create your web application for this particular project on your server. Just do not forget to save a screen name to the database before executing the code to avoid any possible error.
Depending on the status of the number of followers of the registered Twitter account, the notifier path prints four variables to be interpreted: the current number of followers, the registered screen name, the previous status, and the current status - INC, DEC, STABLE.
INC - There is an increase in the number of followers.
DEC - There is a decrease in the number of followers.
STABLE - There is no change in the number of followers.
Accessing your notifier path, you can elicit a data packet containing followers, the screen name, the previous status, and the current status, in the exact order, as shown below.
Note: The percentage sign(%) is the delimiter to separate information from the transferred data packet.
Collating data via ESP32 on Arduino IDE
To collect information via ESP32 from the web, we have to make an HTTP Get or Post Request to a web page. I decided to use the WiFiClientSecure library to make HTTP requests due to its features for SSL protected servers.
To connect an SSL protected server using ESP32, we need to use the root certificate instead of the fingerprint as opposed to ESP8266....
Read more »
Please feel free to leave a comment here if you have any questions or concerns regarding the project.