Previous                                    Tutorial                                  Tutorial

Authorized Online Retailers:

Purchase from US         Purchase from Japan

AMAZON                 

Introduction

In this lesson, we will show how to use the Osoyoo Yun IoT Kit to get the Flame sensor status remotely.

HARDWARE

SOFTWARE

Connection

Build the circuit as below:

Here we connect the Flame sensor Pin A0 to Arduino analog Pin A2.

Code Program

After above operations are completed, make sure that the Yun Shield is on the same network with the computer. Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch onto your Arduino.

#define BLYNK_PRINT Console
#include <Bridge.h>
#include <Console.h>
#include <BlynkSimpleYun.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
SimpleTimer timer;

//Widget LED
WidgetLED led4(V4); //register to virtual pin 4

//FLAME sensor
//connect to A2
int FlamePin = A2;  // This is for input pin
int Flame = 0;  // HIGH when FLAME Exposed

void FLAMESENSOR () {
  Console.println("FLAME SENSOR START!");
  Flame = analogRead(FlamePin);
  Console.print("flame_val = ");
  Console.println(Flame);   //The serial will print the smoke value
  if(Flame<=500)       // the point at which the state of LEDs change 
  {
    led4.on();
  }
  else
  {
    Console.println("No Fire!");
    led4.off();
  } 
    //delay(2000);
}

void setup()
{
  Blynk.begin(auth); 
  Bridge.begin();
  Console.begin();
  timer.setInterval(10000, FLAMESENSOR);
  while (!Console);{}
    
}

void loop() {
  // this is where the "polling" occurs
  timer.run();
  Blynk.run();

}

Add a Widget

Overhere we need to add an LED wiget. Follow the next operations:

Tap anywhere on the canvas to open the widget box. All the available widgets are located here. Now pick an LED.

Widget Box

Drag-n-Drop - Tap and hold the Widget to drag it to the new position.

Widget Settings - Each Widget has it’s own settings. Tap on the widget to get to them. The most important parameter to set is PIN. Connect the LED wiget to V4.

Running Result

After you finished all above operations, open the Blynk APP, press the PLAY button. This will switch you from EDIT mode to PLAY mode where you can interact with the hardware. While in PLAY mode, you won’t be able to drag or set up new widgets, press STOP and get back to EDIT mode.

Open the Serial Monitor, you will get below info:

At the same time, you can see the hardware side as below:

So, you can remote check the flame sensor status now.

Previous                                    Tutorial                                  Tutorial