Example Code for MakeCode-Sending Twitter (Based on IFTTT)

This project demonstrates how to send a text message to twitter by pressing the button on micro:bit. You can extend this to other application scenarios according to this project, for instance, sending current water quality, air quality and other data to twitter.

Hardware Preparation

  • MBT0039 micro:bit board x 1
  • MBT0008 IO Extender for micro:bit x1
  • WiFi IoT module x1
  • Wires

Wiring Diagram

Software Preparation

This section mainly introduces how to use the WiFi IoT module and how to program it using MakeCode.

MakeCode Programming Platform:
https://makecode.microbit.org/

I2C Library:
MakeCode I2C Library – DFRobot WiFi IoT

Configure IoT platform

In the last project, we have logged in the account on the computer. Next, we use the IFTTT app on the iPad to create events.

Search IFTTT in your APP store and download it. Log in your IFTTT account.

1

Click "Create", then the following interface will appear, click "Start".

5-2

Click "This" to configure it.

5-3

Search "Webhooks" in the search bar and click the result.

5-4

Click "Receive a web request" to enter "create your own" setup, input your Event name, and click "Create trigger".

5-5

5-6

It will return to the following page after clicking "Create trigger". Click "That" to configure it.

5-7

Click that to enter the search page, search for twitter in the input box and click to enter the twitter settings. After entering, there are four options: post a tweet, post a tweet with image, update profile picture, and update bio. Here, we select post a tweet.

5-8

5-9

Click "Add" in the interface below, and then fill in your twitter account and password in the pop-up box to add twitter account.

5-10

Enter the interface below after the last step. Click "Create action", and then click "Finish".

5-11

5-12

Sample Code

Program Link

https://makecode.microbit.org/_8bpXa41DfTU7

Program Block

5-14

Result

Press the button A on the micro:bit, send a twitter "Hi DFRobot 2020".

5-15

Was this article helpful?

TOP