Example Code for micro:bit-MakeCode-Use an Android phone to Send Message (IFFTT)

We often forget to water out plants, sometime, you have to be on business for a long time, but you want someone to take care of your plants. We can use the IoT expansion board to make an application to solve this problem. When the soil moisture is less than 350, the system automatically sends a message to your friend to water the plants. If it is over 520, send a message that the moisture is suitable.

Hardware Preparation

  • micro:bit board: Quantity 1
  • Micro: IoT expansion board: Quantity 1
  • Soil moisture sensor (P1): Quantity 1
  • IFFTT platform access: Quantity 1
  • Android phone with IFFTT app: Quantity 1

Software Preparation

Wiring Diagram

  1. Connect the soil moisture sensor to P1 of the Micro: IoT expansion board.
  2. Plug the micro:bit board into the Micro: IoT expansion board.

Other Preparation Work

    1. Enter IFFTT website, register an account: https://ifttt.com
    1. Sign in and enter the My Applets page, click New Applets.
    1. Create an Applet: click This, input webhooks, fill the Event Name as "message".
    1. Click That, search "Android sms", select "send an sms", set the phone number to receive the message.
    1. Add the phone number: Enter->Home->webhooks->add the phone number.

Sample Code

Makecode Programs: Send messages to Android phone

Result

when moisture<350, send: the flowers need watering; When moisture>250, send: the moisture of the soil is sufficient.

Was this article helpful?

TOP