element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Project14
  • Challenges & Projects
  • More
Project14
Show and Tell! Smart gate opener
  • News
  • Member Updates
  • Competitions
  • Forum
  • Documents
  • Theme Suggestions
  • Polls
  • Members
  • More
  • Cancel
  • New
Join Project14 to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: emaker
  • Date Created: 29 Aug 2026 10:40 AM Date Created
  • Views 63 views
  • Likes 1 like
  • Comments 1 comment
  • AVR-IoT
  • mqtt
  • microchip
  • seeed
  • arduino
Related
Recommended

Smart gate opener

emaker
emaker
29 Aug 2026
Smart Gate Opener (made with AI)

Last week, while I was organizing my drawers, I found a Microchip AVR-IoT Cellular Mini developement board that I had used a couple of years ago to make the project of a control system to get alerts in case of fire or intrusions by burglars in my country house. When I had seen "Show and Tell" on Element14,I thought about making something using the AVR-IoT Cellular.

image Microchip AVR-IoT Cellular Mini

 

I thought about making something that my son has been asking me for a long time, a gate opener that avoids searching for keys in bags or backpacks and lets you open the house gate using your smartphone. The gate is far from the house, so using the home WiFi isn't a feasible solution. Cellular communication could be a good solution in this case.

I have used the MQTT protocol to make the board and my smartphone communicate.

image

For those who have never used an AVR-IoT Cellular Mini, a great guide is the user guide. It fully describes the most important features of the board and explains in detail how to use it in the Arduino environment. Once the DxCore library is installed in the Arduino IDE, there will be plenty of code examples to start using the board. The project I want to create basically needs to wait for an event (an MQTT message coming from the smartphone) and then open the gate using a simple relay connected in parallel with the gate opener button. 

I started my work by taking the example mqtt_custom_broker.ino as a model and modifying it so I could use it for my needs. 

I used an MQTT server "test.mosquitto.org" that offers a convenient free service to test web applications that use MQTT. However, setting up a local MQTT server is very simple, and if I had had more time, it would have been more fun to set it all up on the Raspberry I use to manage some IoT devices in my home.

I used a 3V relay from Seeed to control the electric gate opener that runs on 12V.

image Seeed Switch Development Kit, General Purpose MCU, MPU, DSP, DSC, Grove Starter Kit

image

The code I wrote uses the public MQTT server I mentioned above and doesn't use any authentication or communication encryption. Obviously, this is fine for a simple test, but it needs to be considered if you want to create a project to use in real life.

/**
 * This code is based on mqtt_custom_broker.ino example .
 */

#include <Arduino.h>
#include <ecc608.h>
#include <led_ctrl.h>
#include <log.h>
#include <lte.h>
#include <mqtt_client.h>

// define MQTT parameters
#define MQTT_SUB_TOPIC "cancello"
#define MQTT_PUB_TOPIC "cancello"
#define MQTT_THING_NAME "gestione_casa"
#define MQTT_BROKER     "test.mosquitto.org"
#define MQTT_PORT       1883
#define MQTT_USE_TLS    false
#define MQTT_USE_ECC    false
#define MQTT_KEEPALIVE  60

// define Rele
#define RELE_PIN PIN_PE1  //PIN_PE1 is Arduino's D6

void setup() {
    Log.begin(115200);
    LedCtrl.begin();
    LedCtrl.startupCycle();
    pinMode(RELE_PIN, OUTPUT);
    digitalWrite(RELE_PIN, LOW);   //rele off
    Log.info(F("Starting MQTT with custom broker"));
    // Establish LTE connection
    if (!Lte.begin()) {
        Log.error(F("Failed to connect to operator"));
        // Halt here
        while (1) {}
    }

    // Attempt to connect to the broker
    if (MqttClient.begin(MQTT_THING_NAME,
                         MQTT_BROKER,
                         MQTT_PORT,
                         MQTT_USE_TLS,
                         MQTT_KEEPALIVE,
                         MQTT_USE_ECC)) {
        MqttClient.subscribe(MQTT_SUB_TOPIC);
    } else {
        Log.rawf(F("\r\n"));
        Log.error(F("Failed to connect to broker"));
        // Halt here
        while (1) {}
    }
}
  
void loop() {
    String message = MqttClient.readMessage(MQTT_SUB_TOPIC);
    // Read message will return an empty string if there were no new
    // messages, so anything other than that means that there was a new
    // message
    if (message != "") {
        Log.infof(F("Got new message: %s\r\n"), message.c_str());
        message.trim();   // elimina spazi, \n, \r
            if (mess.equals("Apri")) {
                Log.infof(F("UNO\r\n"));
                digitalWrite(RELE_PIN, HIGH); //rele on for 0.5 seconds
                delay(500);
                Log.infof(F("DUE\r\n"));
                digitalWrite(RELE_PIN, LOW);  // rele off
                }
        }             
    delay(3000);
}

For managing the gate opening command from my smartphone, I used the MQTT Dashboard Client app. The setup is straightforward and everything worked on the first try. The interface is a bit bare, but I have to admit I didn't spend much time trying to fix this issue. It works perfectly and I didn't experience any malfunctions.

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Possible future improvements:

  • the board comes with a 2-pin connector that lets you connect a battery and the circuitry needed to charge the battery via the USB port. Due to time constraints, since the post deadline is very close, I decided to power the circuit with mains voltage and a simple USB-C power supply. It would be interesting to make an autonomous system using a solar panel, a charge controller an a battery.
  • you have to use a strong authentication to protect the communication.
  • Sign in to reply
  • DAB
    DAB 12 hours ago

    Nice post.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube