14. IoT Case 11: Kitchen Safety Flame Monitoring Alert

Level: level auto_fit

14.1. Goal


Make a flame monitoring alert system by detecting the existence of strong fire nearby.

14.2. Background


Nowadays, fire accidents always happen when the homeowner is sleeping or outside the home. It is good to install an IOT system in the kitchen or living room to alert the user on his/her phone when he/she is sleeping or in the office so that he/she will wake up and rush out from the home to prevent a terrible accident happened.


Kitchen Safety Flame Monitoring Alert Principle

By installing a flame sensor in the area, the system will trigger an alarm and blink the red LED to alert the home owner inside the home when there is fire detected. At the same time, it will send a IFTTT notification to the house owner’s phone so that can alert user when he/she is sleeping or outside the home.

pic

14.3. Part List


pic_90

14.4. Assembly step


Step 1

In this case, build the “Big Style Model” as a home base.

pic_90

Step 2

To build a kitchen, put model E3 & E1 onto model A, align with holes at model A and B2 & B1.

pic_90

Step 3

Attached the flame sensor to the model B2 using M4*10mm screws and nuts. And the connecting wire should be bended to the hole nearby.

pic_90

Step 4

Attached multi-color LED to the model B2 using M4*10mm screws and nuts. And the connecting wire should be bended to the hole below.

pic_90

Step 5

To build a stove model. Put the model L2 to model L1 from the top to bottom.

pic_90

Step 6

Fold the model L1 into the model L2 according to the arrow.

pic_90

Step 7

Fold the another side of model L1 into the model L2 according to the arrow.

pic_90

Step 8

Stick the paper with a cooking stove pattern.

pic_90

Step 9

The cooking stove Completed!

pic_90

Step 10

Place the cooking stove model at the kitchen.

pic_90

Step 11

To build a fridge, attach light sensor onto model G1 using M4 * 10mm screws and nuts. And the connecting wire could be bended to the hole below it.

pic_90

Step 12

Fold and bend the Model G1 accordinglyand put Model G3 into the Model G1, align with the holes.

pic_90

Step 13

Put Model G2 onto the Model G1, align with the holes.

pic_90

Step 14

The fridge completed!

pic_90

Step 15

Place the fridge model at the coner of the kitchen.

pic_90

Step 16

The fridge Completed!

pic_90

14.5. Hardware connect


  1. Connect the flame sensor to P2

  2. Connect the Multi-Color LED to P1

  3. Pull down the buzzer switch to connect buzzer

pic_80

14.6. IoT (IFTTT)


Part 1: Setup IFTTT

  1. Create a IFTTT account and login

  2. Create a new Applet

  3. In the IF, search “Webhooks” and click the Webhooks application
    pic_80

  4. Choose the “Received a web request” and enter the event name “fire”
    pic_80

    pic_80

  5. In the THEN, search “Notifications” and click the notifications application

  6. Choose the “Send a notification from the IFTTT App”
    pic_80

  7. After the applet is finish setup, click the Webhooks icon -> documentation
    pic_80


    pic_80

  8. Copy the Key
    pic_80


Optional: Use email as notification method

In the THEN field, search for the “email” and use it to replace the “notifications” in previous step pic_70

pic_70

pic_70

Part 2: Install the IFTTT App on smartphone

  1. Go to play store or app store to search and download the IFTTT App auto_fit

  2. Login to your IFTTT account auto_fit

14.7. Programming (MakeCode)


Step 1. Initialize OLED, IoT:bit and connect to WiFi, create variable

  • Snap Initialize OLED with width:128, height: 64 to on start

  • Snap Initialize IoT:bit TX P16 RX P8 from IoT:bit to on start

  • Snap Set Wi-Fi to ssid pwd from IoT:bit

  • Enter your Wi-Fi name and password. Here we set smarthon as SSID and 12345678 as password

  • Snap Set strip to NeoPixel at pin P1 with 1 leds as RGB(GRB format) pic_60

Step 2. Show icon “tick” after WiFi connection

  • Snap show icon from basic to On WiFi connected and select icon tick pic_50

Step 3. Check the internet connection status

  • In the Forever, put a if statement with condition WiFi connected? to check the connection status pic_50

Step 4. Check the flame sensor result and action on OLED display

  • Put another if statement with condition Get flame detection at Pin P2 = true to recognize the flame

  • Play a warning sound when the flame was detected pic_70

Step 5. Action on Warning LED

  • The LED should be blinking to telling dangerous

  • Put strip show color red to turn on the LED in red color

  • Add a pause (ms) 100 to wait for 0.1 second

  • Put strip show color black to turn off the LED

  • Pause for 0.1 second again auto_fit

Step 6. Action on IFTTT

  • Put a Send IFTTT key* XXXXXXXXX event_name* XXXXX .... to send the event to IFTTT

  • Fill in the IFTTT key from your Webhooks and the Applet’s event_name pic_50

Step 7. Know the Upload result

  • To check the upload state, use the On IFTTT Uploaded to get the sending result

  • Inside the On IFTTT Uploaded, use OLED display to show the information

  • Clear the OLED display before each update by clear OLED display

  • Show upload state by show string join IFTTT: Status, the Status value is from the function’s placeholder

  • Show error_code by show string join Error: Error_code, the Error_code value is from the function’s placeholder pic_50

Full Solution

MakeCode: https://makecode.microbit.org/_959awf824d8P

You could also download the program from the following website:

14.8. Result


When the flame source is detected by the flame sensor, it will trigger to blink the LED, making alert sound, and send the warning notification to IFTTT

auto_fit

auto_fit

14.9. Think


  1. Other than warning, any task we can do when we detect the flame? (e.g add a fan or sprinkler to extinguish the fire, call the police?)