Random Nerd Tutorials

Posting a Tweet with the ESP8266


In this project you’re going to post a Tweet with an ESP8266. The goal of this project is to show the endless possibilities that this $4 WiFi module offers when integrates with a free platform that I’m about to show you.

In order to accomplish this task you have to sign up for one free service called IFTTT which stands for “If This Then That”.

IFTTT is a platform that gives you creative control over dozens of products and apps.

You can make apps work together. For example when you send a request to IFTTT, it triggers a recipe that sends you an email alert.

Before continue reading this project, please complete the following tutorials:

If you like the ESP and you want to do more projects you can read my eBook Home Automation using ESP8266 hereLet’s get started!

Creating Your IFTTT Account

Creating an account on IFTTT is free!

Go the official site: https://ifttt.com/ and click the “Sign Up” button in the top of the page.

Complete the form with your personal information (see Figure below) and create your account.


After creating your account, follow their getting started tutorial.

Open the Applet

I’ve created an Applet that integrates perfectly in this project and you can also use it.

If you’re logged in at IFTTT and you open this URL below to use my Applet instantly:


Press the “Turn on” button:

Next, you need to grant access permissions to Maker Webhooks and Twitter. Let your IFTTT account connect to your Twitter account. A new page loads when you finish connecting your Twitter.

Complete the Applet

Fill the Applet with your own information. Follow these instructions:

  1. Type “post_tweet” in your event name
  2. Edit the text that you want to your ESP8266 to send out as a Tweet
  3. Press the “Save” button

Now, go to this URL: https://ifttt.com/maker_webhooks and open the “Settings” tab.

Copy you secret key to a safe place (you’ll need them later in this project). In my example my secret key is: b6eDdHYblEv2Sy32qLwe

Test Your Applet

Let’s test if your request is working properly. Replace YOUR_API_KEY from the following URL:


With your API KEY:


Open your URL with your API KEY in your browser.


You should see something similar to the preceding Figure. Then go to your Twitter and a new Tweet should be there!

If you like Twitter, you can follow me there @RuiSantosdotme for news related to electronics.


Parts List

Here’s the hardware that you need to complete this project:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Schematics (3.3V FTDI Programmer)

The schematics for this project are very straight forward. You only need to establish a serial communication between your FTDI programmer and your ESP8266 to upload some code.


Downloading ESPlorer

I recommend using the ESPlorer program created by 4refr0nt to create and save Lua files into your ESP8266.

Follow these instructions to download and install ESPlorer:

  1. Click here to download ESPlorer
  2. Unzip that folder
  3. Go to the main folder
  4. Run ESPlorer.jar. It’s a JAVA program, so you need JAVA installed on your computer
  5. Open the ESPlorer

esplorer start

Writing Your Lua Script

Don’t forget that first you need to flash your ESP with NodeMCU firmare. Copy and paste the code below into ESPlorer. Then edit line 5 with your network credentials and line 13 with your API KEY.

Uploading Your Lua Script

When you open the ESPlorer you should see a window similar to the preceding Figure, follow these instructions to send commands to your ESP8266: Connect your FTDI programmer to your computer

  1. Set bad raute as 9600
  2. Select your FTDI programmer port (COM3, for example)
  3. Press Open/Close
  4. Select NodeMCU+MicroPtyhon tab
  5. Copy the your Lua script into ESPlorer

Then you simply click the button Send to ESP. And you should see a a print saying “Posted Tweet” in the ESPlorer windowEverything that you need to worry about or change is highlighted in red box in the following Figure.


Limitations and Taking it Further

Twitter doesn’t allow you to post the same tweet over and over again. So you can use the following script (by changing line 5 with your network credentials and line 13 with your API KEY) to add parameters to your POST request.

In my example below I’m using the parameter “value1” and sending the value “True”. IFTTT supports three parameters called “value1”, “value2” and “value3” to customize your Tweets and make them unique.

In your POST request make sure you set the right “Content-Length” in my case it’s “17”, but if you change the “value1” or you add more parameters to your body request the “Content-Length” also changes. If you make a request with the wrong Content-Length it will fail.

With this concept in mind you can post data from your sensors (like temperature, humidity, etc) directly to Twitter using the ESP.

Here’s the end result:


Do you have any questions? Leave a comment down below!

Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

MicroPython Programming with ESP32/ESP8266 eBook

Learn how to program the ESP boards with MicroPython, including projects, tips, and tricks! The registrations are open for a limited time, so SIGN UP NOW »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our course even with no prior experience!

Leave a Comment:

Add Your Reply

⏰ Registrations are open for "MicroPython Programming with ESP32 and ESP8266" eBook