Table of Contents

set relay at pin () to ()

Set relay

Description

Set relay at pin () to () block is a stack block available in the extension of the actuator for evive and all Arduino boards. The block set the relay connected to the specified digital pin to ON or OFF.

evive Notes Icon
Note: This block is available in both Upload mode and Stage mode.

Example

  1. In this example, we are controlling the relay connected to digital pin 13 using Dabble terminal module.
    Set relay example

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
A relay is an electromagnetic switch which is used to control high voltage appliances using microcontrollers.
Introduction

A relay is an electromagnetic switch that works on the principle of electromagnetic induction. A Realy is used to control the high voltage appliances using the microcontrollers.

5V Single-Channel Relay Module - Pin Diagram, Specifications, Applications, Working

a relay has a primary side which is need to be connected to the controller and the secondary side is need to be connected with the load, for example, motor, light bulb, fan, etc. primary side has 3 pins named as VCC, GND, and IN.  secondary also has connections named as Common(COM), Normally Open(NO), and Normally Closed (NC).

Circuit

connection

relay              Arduino

VCC                 5V

GND               GND

IN                  D7

COM             battery-

NO                1 leg of the bulb

Code

  1. From  event palette,  add when  flag clicked  into the scripting area
  2. From controls add a forever block
  3. Now go to actuator palette, and drag set relay at pin () to () into forever loop.
  4. Add a wait block from control palette.
  5. Repeat above 2 steps and change relay state from OFF to ON

 

Script

Output

Read More
The project demonstrates how to create a smart plug that can be controlled by an IoT device and that can retrieve information from the cloud. The smart plug can be used to turn lights ON and OFF.

The project demonstrates how to create a smart plug that can be controlled by an IoT device and that can retrieve information from the cloud. The smart plug can be used to turn lights ON and OFF.

Adafruit IO Settings

We will be using Adafruit IO for creating a switch on the cloud. Follow the instructions:

  1. Create a new Feed named Light.
  2. Create a new Dashboard named Light Control.
  3. Edit the Dashboard and add a Toggle Block.
  4. Connect the Light feed to the block and click on Next Step.
  5. Edit the Block Setting and click on Create Block.
  6. Block is added. You can try to toggle the switch.
  7. Go to the Light feed. You will observe the value of the feed changing as we click on the switch on the Dashboard.

Circuit

The bulb is connected to the smart plug which is controlled with a relay.

Note:  A relay is an electromechanical switch that is used to turn on or turn off a circuit by using a small amount of power to operate an electromagnet to open or close a switch.

If the relay is ON, the smart switch gets ON, turning on the light. 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 4 of the Quarky Expansion Board.

Code

The logic is the following – We’ll connect to the Adafruit IO account, fetch the switch state from the cloud, and use and if block to turn the relay on or off accordingly.

Output

IoT Enabled Smart Plug Upload Mode

You can also make the IoT Enabled Smart Plug 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.

You can download the code from here: IoT enabled Smart Plug – Upload Mode

Read More
This project demonstrates how to create a voice-controlled smart plug using natural language processing (NLP), speech recognition, and a relay.

This project demonstrates how to create a voicecontrolled smart plug using natural language processing (NLP), speech recognition, and a relay.

Text Classifier in PictoBlox

We will use the PictoBlox Machine Learning environment for creating the text classifier.

Follow the steps to create the model:

  1. Open PictoBlox and the Machine Learning Environment.
  2. Click on Open Project and add import the following project file: Alexa
  3. Find the Alexa project in the list and open it to get the workspace of the text classifier.
  4. There will be 2 classes Lights On and Lights Off. Each class has some phases added corresponding to the action. You can add a few phases yourself.
  5. Click on Train Model to train the model.
  6. Once trained, you can check the model in the Testing tab. Add a phase and check if it provides the right sentiment.
    Note: If the model is not giving the desired results, then add more phases until the model is good.
  7. Click on the Export Model to create the blocks for the project.
  8. Test the block with some input text.

Circuit

The bulb is connected to the smart plug which is controlled with a relay.

Note:  A relay is an electromechanical switch that is used to turn on or turn off a circuit by using a small amount of power to operate an electromagnet to open or close a switch.

If the relay is ON, the smart switch gets ON, turning on the light. 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 4 of the Quarky Expansion Board.

Code

The logic is the following – The Speech Recognition extension converts speech to text, which is then fed into the text classifier block. The text classifier block provides sentiment information, which is used to control the light via the relay.

Output

Read More
In this example, we will look into the basics of a Drip Irrigation System using the IoT House. With IoT House, you get 2 plant drip irrigation raw equipment.

In this example, we will look into the basics of a Drip Irrigation System using the IoT House. With IoT House, you get 2 plant drip irrigation raw equipment.

Drip Irrigation

The drip irrigation system is a type of micro-irrigation of soil that has the potential to save water and nutrients by allowing water to drip slowly to the roots of plants. This leads to the wise use of water and also makes water reach the roots of plants and minimize evaporation. Drip irrigation systems distribute water through a network of valves, pipes, tubing, and emitters. Its efficiency depends on how well the system is designed, installed, maintained, and operated. A simple drip irrigation system is shown below in the figure.

Drip Irrigation Kit

In this project, we will be using an IoT House Drip irrigation kit. This kit consists of various components out of which the following are required in our project

  1. A feeder line pipe is used to transfer water from the water tank source to the drip irrigation system. It is also used to connect the T-connectors to make different connections.
  2. A drip emitter is a small piece used to water the plant drop by drop. It is connected to the T connector with the help of a feeder line pipe of around(2.5 cm as per our requirement).
  3. A T connector is a T-shaped piece of plastic that connects one drip emitter to the adjacent drip emitter with the help of a feeder line pipe.
  4. Emitter stakes are stands with a curve at the top and pointed at another end. It will help to provide stability to the feeder line pipe drip emitter connections.
  5. A 12V,3W Water pump is connected at one end of the feeder pipeline. The male end of the water pump is connected female dc connector.

Circuit

The Water Pump Connected to the Relay: The water pump is controlled by the smart switch of the IoT house which has a relay controlling the state. If the relay is ON, the smart switch gets ON, turning on 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 4 of the Quarky Expansion Board.

Script

The pump will turn ON when the L button of the Quarky is pressed.

Output

Read More
This example demonstrates how to use the Soil Moisture sensor to detect the moisture in the soil and water the plant using the drip system. The system will water the plant when the moisture of the soil is low.

This example demonstrates how to use the Soil Moisture sensor to detect the moisture in the soil and water the plant using the drip system. The system will water the plant when the moisture of the soil is low.

Drip Irrigation Assembly Guide

The following tutorials cover how to make the Drip Irrigation System:

  1. For 1 Plant: https://ai.thestempedia.com/docs/iot-house-quarky-addon-kit-documentation/1-plant-drip-irrigation-assembly-iot-house/
  2. For 2 Plants: https://ai.thestempedia.com/docs/iot-house-quarky-addon-kit-documentation/2-plants-drip-irrigation-assembly-iot-house/

Circuit

We are using 2 devices in this project:

  1. Moisture Sensor: The moisture sensor provides real-time moisture reading from the soil. The moisture 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 A2 of the Quarky Expansion Board.
  2. The Water Pump Connected to the Relay: The water pump is controlled by the smart switch of the IoT house which has a relay controlling the state. If the relay is ON, the smart switch gets ON, turning on 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.

Note:  Once the connection is done, make sure you have the drip irrigation system placed with some water in the tank.

Script

The project has 3 scripts:

  1. Script to display the real-time moisture level on the display of the Quakry. Based on the moisture value, the number of LEDs will light up. The script is a custom block defined with the name – Display Soil Moisture Level.
  2. The second script is another LED display showing the animation of the watering. The script is a custom block defined with the name – Watering Animation.
  3. The final script is the main script which has the logic to detect the moisture value. If the value becomes less than 30%, the pump gets ON and the watering continues until the moisture level gets to 80%.

Output

Uploading Code

You can also make the script 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.

Read More
In this example, we will demonstrate how to use the Moisture sensor to detect how much the tank is filled and start the pump whenever the water level is low.

In this example, we will demonstrate how to use the Moisture sensor to detect how much the tank is filled and start the pump whenever the water level is low.

Circuit

We are using 2 devices in this project:

  1. Moisture Sensor: The moisture sensor provides real-time moisture reading from the tank to estimate the depth of water. The moisture 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 A2 of the Quarky Expansion Board.
  2. The Water Pump Connected to the Relay: The water pump is controlled by the smart switch of the IoT house which has a relay controlling the state. If the relay is ON, the smart switch gets ON, turning on 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 4 of the Quarky Expansion Board.

Script

The project has 2 scripts:

  1. Script to display the real-time moisture level on the display of the Quakry. Based on the moisture value, the number of LEDs will light up. The script is a custom block defined with the name – Water Level Indicator.
  2. The final script is the main script which has the logic to detect the moisture value. If the value becomes less than 20%, the pump gets ON and the watering continues until the moisture level gets to 90%.

Output

Uploading Code

You can also make the script 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.

Read More
All articles loaded
No more articles to load