In this guide, we'll explore how using a scheduler in your DIY electronic projects can automate your gadgets and devices, like having a helpful assistant. It allows you to set specific times or conditions for your creations to do things automatically.
We'll be using the Arduino Nano ESP 32, a compact and powerful board with built-in wireless capabilities, making it easy to connect your projects to the internet. This enables remote control and monitoring from a smartphone or computer.
Arduino IoT Cloud is another tool we'll utilize, allowing easy internet connectivity for your gadgets. This means you can control and monitor your devices from anywhere with an internet connection.
Introduction to the SchedulerThe Arduino IoT Cloud now offers a scheduler feature, providing a helpful assistant for your DIY electronic projects. It allows you to plan when your devices should perform specific tasks automatically. For example, you can set it to turn on lights at a certain time or regularly measure the temperature and send you updates.
Building the CircuitTo demonstrate, we'll create a circuit where you can co"We are about to create a circuit that allows us to connect simple electronic devices, making use of a scheduler.Let's begin with the circuit! I used Altium Designer to create the circuit and design the PCB. In Altium Designer, I will utilize a pump that operates on 12 V, so I'll connect a 12 V DC adapter. The input power is linked to a 7805 regulator, a 5V regulator that converts an input voltage range of 7-32V into a steady 5V DC supply. For easy troubleshooting, there are indicator LEDs at various points.
Within this setup, we have two switches. One is a relay triggered by a BC547 transistor, with its base connected to Digital Pin 3. Additionally, there is a MOSFET connected to digital Pin 5 of the Arduino. Also, you'll notice a buzzer that is activated and deactivated by this specific transistor. This transistor is connected to digital pin 6 of the Arduino.
You have the option to connect either the lock to the MOSFET or the relay, enabling programmable activation and deactivation. In my design, I opted to connect the pump to the MOSFET so that I could attach another device like a bulb to the relay. The other switch can be used to connect additional devices like a lamp or a motor for activities like opening a door or illuminating a lamp using the scheduler.
Remember, this is my design. As mentioned earlier, I will provide the schematics in the description, allowing you to redesign, customize, and create your own version. Alternatively, you can use my version as is. Regardless of your choice, the first step is to test it on a breadboard. Once you achieve the desired output, you can either keep using it as is or create your PCB.
In my case, I chose to use a PCB. I've designed a PCB layout that facilitates easy mounting of your Arduino Nano ESP32, relays, MOSFETs, and other components. This setup avoids the need for messy wires and cables. Making your own PCB for the project is exciting, isn't it? The board is lightweight and can be powered using a 9V battery or a 9-12 V power adapter, depending on the Solenoid Lock voltage."nnect simple electronic devices for use with the scheduler. The circuit involves various components like switches, relays, and MOSFETs that can be controlled programmatically.
Designing and Making a PCBWe'll design a Printed Circuit Board (PCB) layout to neatly mount the components without messy wires and cables.
This makes your project more organized and allows for efficient use of space.
Ordering and Assembling the PCBI placed an order for a PCB from PCBWay, a specialized manufacturer known for PCB prototyping, low-volume production, and meticulous PCB assembly. If you're keen on creating your own PCBs for a project, click on the link below. By signing up through this link, you can avail a 5-dollar discount. Additionally, you can also enjoy another 5-dollar discount during checkout by using the coupon code PCBWayLab.
To proceed with your PCB order through PCBWay, visit their website and fill out the basic board details using the instant order form. Following that, you'll be guided to a more detailed form where you can provide comprehensive board specifications. Update your board information in the PCB specification screen. In the subsequent step, you'll have the option to upload your Gerber file and submit it for review. After the review process, simply add the items to your cart, make the payment, and await the arrival of your PCBs.
Once you have all the components and the PCB in hand, it's time to solder them together. Ensure that you solder all the components onto the board, and be meticulous in checking the polarity of each component. After completing the soldering process, the PCB will take on this appearance.
Setting Up Arduino IoT CloudWe'll log in to the Arduino IoT Cloud and configure the project.
This involves linking the project to the Arduino Nano ESP 32 board and configuring the scheduler variable.
Now, let's examine the code.
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/c2de411c-d043-429b-8a75-2c24941e8d11
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudSchedule scheduler;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
void setup() {
pinMode(13, OUTPUT);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
delay(1000);
ArduinoCloud.update();
if (scheduler.isActive()) {
digitalWrite(9, HIGH);
digitalWrite(5, HIGH);
digitalWrite(3, HIGH);
Serial.println("Scheduler_Activated");
}
else
{
digitalWrite(8, LOW);
digitalWrite(5, LOW);
digitalWrite(3, LOW);
Serial.println("Scheduler_Deactivated");
}
}
In the code, we can observe that the variable has been declared already, so there's no need to declare it again. In the setup function, we initialize the serial communication and set the pin mode of specific pins to output. These pins are connected to MOSFET, relay, and LED, with the MOSFET serving as a means to control the device.
After this setup, the Arduino board connects to the Wi-Fi network we configured earlier. In the loop function, we check for any changes in the scheduler variable we previously defined.
Within this if condition, we define the actions to take. For instance, if the scheduler is ON, we turn ON these pins. Conversely, if the scheduler is not activated, we turn off these pins.
All that's left is to compile and upload the code."We are about to create a circuit that allows us to connect simple electronic devices, making use of a scheduler.
Testing the ProjectAfter uploading the code, we'll test the project to ensure the devices are triggered at the right times as per the scheduler settings.
ConclusionThe scheduler feature allows for automation and control of your DIY projects. You can tailor it to various applications and unleash your creativity. If you have any questions or doubts, feel free to ask in the comments."
Comments
Please log in or sign up to comment.