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

This project demonstrates how to connect the WiFi IoT module to the IFTTT platform. When Button A on the micro:bit is pressed, the current temperature and light intensity values are sent to IFTTT, which then triggers an email notification. This allows real-time sharing of environmental data with others.

Hardware Preparation

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

Wiring Diagram

1-18

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
  1. Enter IFTTT website, register an account if you don't have one. Then Sign in.

    1-1

  2. The following interface will appear when you signed in.

    1-2

  3. Click "Create" to enter the interface below.

    1-3

  4. Click "if this" and input "webhooks" in the search bar.

    1-4

    1-5

  5. The following interface when entering for the first time, click "Receive a web request".

    1-6

  6. Fill in the Event Name, then you have created this.(The event name can be defined by yourself).

    1-7

  7. The webpage will return back automatically. Click "that" and select "Email".

    1-8

  8. Click "Connect", fill in your emial address, and click "send PIN" to send a PIN code to your email box.

    1-9

  9. Check your email to find the PIN code, and fill it in the webpage, then click "Connect".

    1-10

  10. Click "Send me an Email" to set the email.

    1-11

  11. You can write the content to be sent to your email box in the interface below, here we select the default one. Click "Create action".

    1-12

  12. Enter the interface as follows.

    1-13

  13. Check Password: click your avatar, click "My services".

    1-14

  14. Click webhooks to enter the event created.

    1-15

  15. Enter webhooks, click "Documentation" then the password can be seen.

    1-16

    1-17

Sample Code

https://makecode.microbit.org/_6r9WkE7Lrfi9

Program Blocks

20

Result

Press the button A on the micro:bit, the current temperature and light values will be detected and uploaded to IFTTT, and then forward to the mailbox you set.

21

Was this article helpful?

TOP