Molemi IoT
  • Space farming using food computers for sustainable farming
  • Introduction to Arduino
    • Introduction to Electronics
    • The Breadboard
  • Controlling LEDs with an Arduino
    • The Code
    • Adding a button to control the LEDs
      • The Code
  • Introducing Sensors
    • The CO2 and air quality sensor
    • The Code
      • Explaining the Code
    • Light Intensity Sensor
  • Introducing the NodeMCU
    • Getting Started
      • A simple test for ESP8266
        • The Code
    • A light bulb switch using NodeMCU and the Blynk app
      • Setup Blynk on your Smartphone
      • The Code
    • Controlling a Centurion gate Motor with NodeMCU a 2-channel relay
      • Installing Blynk in Arduino IDE
    • Read and display the water flow sensor on Blynk
      • Setting up Blynk
      • The Code
        • Explaining the code
    • Read and Display temperature sensor readings with NodeMCU.
      • Installing libraries for DS18B20 temperature sensor.
      • Displaying the sensor readings on the serial port
        • Getting temperature readings from different DS18B20 sensors.
          • The Code
            • Display sensor readings on a web server
              • Build the web server
                • Designing and building the web page
                • The Code
    • Display the DHT11 sensor reading on a web server using NodeMCU.
      • Monitoring Room Temp & Humidity using Blynk
      • Installing DHT library on the ESP8266
        • Installing the Asynchronous Web Server library
          • The Code
          • Designing and building the web page
  • Data Science for Farming
    • Getting Started with Colaboratory
    • Introduction to Python for DS using Colab
  • Machine Learning for Farming
  • Molemi Personal Food Computer
    • Bill of Materials
  • Setting up WaziGate on a Raspberry Pi
  • Setting up DHT11 on Raspberry Pi
  • Using Telegram To Control Outputs
Powered by GitBook
On this page
  • Requirements:
  • What we will provide:

Was this helpful?

  1. Introducing the NodeMCU

Controlling a Centurion gate Motor with NodeMCU a 2-channel relay

These are the classes/lessons for the "Made in Workshop" training workshops. We will be controlling the Centurion gate motors with a 2-channel relay. This will close or open the gate.

For this activity we will be controlling the Centurion gate motor with a 2-channel relay. We will be using the Arduino-based nodeMCU and the Blynk mobile app to control the relay. The Blynk app will have two buttons. One will be to open and the other will be to close the gate.

This workshop will be 3 hours long and the following objectives need to be covered in this time period.

Requirements:

  • Bring your own laptop installed with Arduino IDE.

  • Basic knowledge of electric circuits.

  • Android/iOS smartphone installed with the Blynk app.

What we will provide:

  • Centurion Gate motor Box.

  • 12VDC battery.

  • 12 V power supply for the Arduino IOT 33 micro-controller board.

  • Relay switch module.

  • jumper cables.

  • Breadboard.

The Outcomes of this workshop/Tutorial

  • The main objective will be to open and close the Centurion motor gate using your smartphone.

  • Learn how to setup/configure your Blynk app to include buttons to open and close the gate.

  • Connect the gate motor to the relay module.

  • Setup the power supply to power the Arduino IoT 33 board.

  • Setup the 12V battery to power the Centurion Gate motor.

  • Setup the Blynk library on the Arduino IDE.

  • Write the code (on Arduino IDE) to allow communication between the Blynk app and the Arduino IoT 33 board so that you can toggle the relay module to open and close gate.

What will you need ?

  • NodeMCU dev kit/ Arduino IoT 33 board

  • 2-channel relay

  • An android smartphone with the Blynk app installed.

  • male-to-female jumper cables

  • a desktop computer/laptop with the Arduino IDE installed

  • A 12V DC motor

Introducing the components:

  • Arduino IoT 33 board - This will be used as our main controller. It will be used to communicate with the Blynk app. The code/program that will control the

  • Relay Switch module - used to open and close a circuit electro-mechanically or electrically.

Circuit setup is as follows:

  1. Connect one male-to-female jumper cable from the D0 pin on the NodeMCU to the "IN1" PIN on the relay board. Also connect the D1 PIN to the "IN2" PIN.

  2. Connect the GND pin of the relay module to the GND pin of the NodeMCU. Then connect the VCC pin of the of the relay module to the 5V pin (the relay needs a power supply of 5V. A nodeMCU only gives an output voltage of 3 - 3.3V so you will need to use an Arduino Uno or a 5V power supply.

  3. Connect the both of the wires of the motor into the COM of each of the relay modules.

  4. For the DC motor, connect the positive terminal of the power supply to both the Normally Open (NO) pin of the two relay modules. Then connect the negative terminal of the power supply to the two Normally Closed (NC) pins of both the relays.

If this is the first time working with the NodeMCU, you will need to install the ESP8266 board on the Arduino IDE as demonstrated here:

  1. The first thing you will need to do is install the Blynk app on your smartphone and create a New Project. Once you have created it, you will receive the authentication code via the e-mail address that you you signed up with.

Add two buttons for the two relays one labelled "Open Gate" the other "Close Gate":

After adding the buttons, click on the "OPEN GATE" one and then change the logic from 0-1 to 1-0 because the output of the NodeMCU is active LOW. Under the PIN tab, assign it the digital pin D0.

Do the same with the "CLOSE GATE" button and assign the digital pin D1 to it.

2. The second thing you will need to do is to add the is include the example code for blynk using the nodeMCU board.

click on File > Examples > Blynk > Boards_WiFi > NodeMCU

This will be the code that you get:

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example runs directly on NodeMCU.

  Note: This requires ESP8266 support package:
    https://github.com/esp8266/Arduino

  Please be sure to select the right NodeMCU module
  in the Tools -> Board menu!

  For advanced settings please follow ESP examples :
   - ESP8266_Standalone_Manual_IP.ino
   - ESP8266_Standalone_SmartConfig.ino
   - ESP8266_Standalone_SSL.ino

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
  Blynk.run();
}

PreviousThe CodeNextInstalling Blynk in Arduino IDE

Last updated 5 years ago

Was this helpful?

Credit:

https://www.youtube.com/watch?v=BQOji4i4PEc
Create a New Project
Authentication key generated
Configuring the OPEN GATE button
Configuring the "CLOSE GATE" button
The example code for Blynk NodeMCU