is () at () active?

Description

The block reports the state of the sensor connected to the selected pin. The block returns true when it is HIGH (or 3.3V) or false when it is LOW (or 0V). The block is used for digital sensors like PIR Sensor, Flame Sensor, or the IR Sensor.

There are lots of pins to which the sensor can be connected:

  1. Digital Pin: D1, D2 or D3
  2. Analog Pins: A1 and A2

The pin can be selected from the dropdown.

Example

The project demonstrates how to make an IR sensor-activated coke dispenser.

The project demonstrates how to make an IR sensoractivated coke dispenser.

Circuit

We are using 2 devices in this project:

  1. IR Sensor: The IR sensor provides information if there is an obstacle in front or not. The IR sensor connections are as follows:
    1. GND Pin connected to GND of the Quarky Expansion Board.
    2. VCC Pin connected to VCC of the Quarky Expansion Board.
    3. Signal Pin connected to D3 of the Quarky Expansion Board.
  2. The Water Pump Connected to the Relay: The water pump is turned on and off by a relay connected to a smart switch in the IoT house. When the relay is turned ON, the smart switch also turns ON, activating the water pump. The relay has the following connections:
    1. GND Pin connected to GND of the Quarky Expansion Board.
    2. VCC Pin connected to VCC of the Quarky Expansion Board.
    3. Signal Pin connected to Servo 8 of the Quarky Expansion Board.

Script

The script is simple. The relay turns ON when the IR sensor is active, else OFF.

Output

Read More
The project uses face recognition to identify authorized people and opens the door accordingly.

The project uses face recognition to identify authorized people and opens the door accordingly.

Circuit

We are using 2 devices in this project:

  1. IR Sensor: The IR sensor provides information if there is an obstacle in front or not. The IR sensor connections are as follows:
    1. GND Pin connected to GND of the Quarky Expansion Board.
    2. VCC Pin connected to VCC of the Quarky Expansion Board.
    3. Signal Pin connected to D3 of the Quarky Expansion Board.
  2. Servo Motor: The servo motor controls the Door of the IoT house which is connected to the servo port of 5 of the Quarky Expansion Board.

Alert: Make sure you have the Door Servo Motor calibrated.

Face Recognition

We will be using Face Detection extension for making the face recognition application.

Working of an IR Sensor

An Infrared sensor is a type of sensor that senses if something is close to it or not. The IR stands for Infrared sensor. Infrared is the light out of our visible spectrum.

An IR sensor has a white LED (transmitter) and a photodiode (receiver). The transmitter emits IR light, and the receiver detects reflected light from objects within the sensor’s range, which can be adjusted with a potentiometer. The sensor is indicated by two LED indicators, a power LED which is always on, and a signal LED which is on when an object is detected and off when nothing is detected.

The signal LED has two states or situations:

  1. ON (Active) when it detects an object
  2. OFF (Inactive) when it doesn’t detect any object

Storing the Face Authorised for IoT House

This script allows us to add a new face to the system. First, the video feed from the camera is turned on. Then, the camera is analyzed for a face. If one face has been detected, the user is asked to select a slot (1 to 10) and enter a name for the new face which is then added to the system. Finally, the video feed from the camera is turned off.

Code

This code creates a program that can add a new face to the system, and then recognize and authenticate the user:

  1. The program sets the threshold for face detection to 0.5, turns off the video feed from the camera, and enables the box to be drawn around the detected face.
  2. It also moves a servo on the expansion board to position 5 and moves it to 100 degrees to close the door.
  3. It defines custom blocks called Run Authorization Check.
  4. The Run Authorization Check block turns on the video feed from the camera, recognizes the face in the camera, and speaks out the name of the recognized user if the face has been recognized. It then returns 1 to indicate the user has been authenticated.
  5. The program then keeps running the loop forever. 
  6. It also checks if the IR sensor is active and if yes, calls the Run Authorization Check function. If the user has been authenticated, it moves the servo to 0 degrees to open the door and then back to 100 degrees to close the door after some time.

Output

Read More
This example shows you how to use the flame sensor to detect heat or flame nearby, and then how to create an alarm system that is triggered by the flame sensor.

This example demonstrates how to set up the flame sensor with Quarky to detect heat or flame nearby. Later, we create an alarm system triggered with the flame sensor.

Flame Sensor Connection to Quarky

Flame sensors have 4 pins: GND, VCC, DO, and AO. You have to connect the following 3 pins to the Quarky Expansion Board:

  1. GND to Ground Pin of Quarky Expansion Board
  2. VCC to 3.3V or VCC Pin of Quarky Expansion Board
  3. DO to the D3 (Digital Pin) of the Quarky Expansion Board

Calibrating Flame Sensor

The sensor also has 2 LEDs – Power and Detection. The desired calibration is achieved when the sensor is inactive when there is no heat or flame nearby and active when the flame is nearby. It is visible on the detection LED.

To calibrate the flame sensor:

  1. Turn the power on for the sensor.
  2. Place the sensor close to the heat or flame. You should see the detection LED turn on.
  3. If the LED is Off, adjust the potentiometer until the detection LED turns on.
  4. Move the sensor away from the heat or flame. The detection LED should turn off.
  5. If the detection LED does not turn off, continue to adjust the potentiometer until it does.

Project: Flame-based Alarm System

In the project, when heat or flame is detected, the alarm system starts with

  1. The fan turned ON.
  2. Quakry beeping with lights.
  3. The door is open for urgent evacuation.

The alarm system will be on until the flame sensor stops detecting the fire.

Circuit

Connect the following modules to the Quarky Expansion Board:

  1. Flame Sensor
    1. GND to Ground Pin of Quarky Expansion Board
    2. VCC to 3.3V or VCC Pin of Quarky Expansion Board
    3. DO to the D3 (Digital Pin) of the Quarky Expansion Board
  2. Motor Fan: Connect the motor to the Motor Port 1 of the Quarky Expansion Board.
  3. Door Servo Motor: Connect the servo motor to the servo port 5 of the Quarky Expansion Board.

Code

Adding IoT in Fire Alarm System

As an advanced system, we can also send the fire detection alert to the users using IFTTT. For that, we will use IFTTT webhooks.

The following IFTTT sequence is to be created:

You can learn in detail how to create an IFTTT applet here: https://ai.thestempedia.com/extension/ifttt-webhooks/

Code

You can download the code from here: Flame-Based Alarm System – Stage Mode

IoT-based Fire Alarm in Upload Mode

You can also make the automatic lighting work independently of PictoBlox using the Upload Mode. For that switch to upload mode and replace the when green flag clicked block with when Quarky starts up the block.

Note: Make sure you know how to work on Upload Mode with Quarky in IoT. Follow the example to learn more: https://ai.thestempedia.com/example/automatic-light-control-with-ldr-sensor/

You can download the code from here: Flame-Based Alarm System – Upload Mode

Read More
All articles loaded
No more articles to load
Table of Contents