Create Web Server with ESP8266
Hello friends, I hope you all are doing great. Today, we will create a web server with ESP8266 microcontroller to control the activation of an LED. The goal is to understand how the ESP8266 connects to a WiFi network, how it sets up a web server, and how it is possible to exchange information between the browser and the esp8266.
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | ESP8266 | Amazon | Buy Now |
Components Required
- 1x Computer/notebook with Arduino
- 1x Mini-USB cable.
- 1x NodeMCU (ESP8266 Breakout Board)
- Internet Browser (Chrome, Firefox, IE…)
ESP8266 Libraries for Arduino IDE
For this project, we will use two libraries:
- ESP8266WiFi: This library carries all the functions necessary for the ESP8266 to connect to a wifi network.
- ESPAsyncWebServer: This library carries the functions needed to create and manage an EB server.
Creating the code
- We can divide the code into three main functionalities:
- Control the LED.
- Connect to Wifi
- Create the webserver.
And we'll treat this building in blocks.
Importing Libraries
- The Libraries must be included at the beginning of the sketch so that their functions are already available elsewhere in the code.
LED Control with ESP8266
- Our first step is to define the pin to be used. For our example, we will use the LED of the NodeMCU module.
- And set this pin as output in the setup function.
- We will also create a variable to monitor LED status. This variable is not used to control the LED, but it will be important for the webserver so, we will include it here.
- So, we'll create a function that, whenever triggered, will change the state of the LED (and the variable).
- The toggleLed() function makes a function nesting in its first line:
- The digitalWrite() function receives as a value for writing, the inverse of the reading of the pin itself. So each time the function is called, it reads the current value of the pin and toggles its value.
- The following conditional is only used to update the stateValue variable. To test the function, you can include it in the loop as follows:
- With these inclusions, we will have this code:
- With this code, the NodeMCU module LED, we expect to change state every 3 seconds. Remember to remove the data inside the loop function when you finish the test. We will not use them in the next steps.
Connect ESP8266 to WIFI
- Now let's connect the ESP8266 to your WIFI network. We'll start by creating a variable to store the network name and another one for the password.
- The connection could be executed directly in the setup function, but we will create a standalone function to make the code more organized and so that it can be reused if you want to create a reconnect function.
The wifiConnect() function will send a connection request and wait for it to be approved.
With Wifi.begin(), ESP8266 will search the network informed in the ssid variable and send a connection request, informing the password (just like what a cell phone would do).
The WiFi.status() function can return the following values:
- WL_CONNECTED: assigned when connected to a WiFi network;
- WL_NO_SHIELD: assigned when no WiFi shield is present;
- WL_IDLE_STATUS: it is a temporary status assigned when WiFi.begin() is called and remains active until the number of attempts expires (resulting in WL_CONNECT_FAILED) or a connection is established (resulting in WL_CONNECTED);
- WL_NO_SSID_AVAIL: assigned when no SSID are available;
- WL_SCAN_COMPLETED: assigned when the scan networks is completed;
- WL_CONNECT_FAILED: assigned when the connection fails for all the attempts;
- WL_CONNECTION_LOST: assigned when the connection is lost;
- WL_DISCONNECTED: assigned when disconnected from a network;
In this project, we are not handling connection failures, so we are only interested in the WL_CONNECTED return. The function will wait while this is not the connection status and, when identifying it, it will look for the IP address it received on the network.
Here is a point of attention. The WIFI network must allow the connection and provide an IP by DHCP. If any device can connect to your network just by offering the password, don't worry. This configuration must already exist.
We've added some information to be viewed on the Serial monitor, so the serial needs to be initialized before we call the wifiConnect() function.
- This should be our code so far:
- The expected result on the Serial Monitor is as follows:
- From this point on, the ESP8266 can be found by network tools like the Advanced IP Scanner or a simple PING at the command prompt.
Creating the Webserver with ESP8266
- Spoiler Alert: At the end of this step, you can view our webserver at the address
- HTTP://”IP address”, for our case http://192.168.18.76.
- We will start by creating an instance of AsyncWebServer operating on port 80.
- In short, a webserver operates as a file manager that delivers on-demand. Then the browser makes a request, the web server responds and continues to wait for new requests.
- All this happens following communication protocols (HTTP, FTTP, or both), rigorous error handling, and high-security logic.
- The library takes care of preparing the backstage of the webserver, which saves us a lot of time and lines of code. But we still need to configure what happens on each request.
We will handle two requests:
- When the page starts or refreshes
- When we press the LED state change
The first will occur when we send a GET request to the root “/”. What the browser does automatically when we go to http://192.168.18.76.
- The server will respond with status 200 (default success response), the information on the type of file sent ("text/html"), the HTML file (which we will create next and save in the variable index_html), and the return of the processor( ) (which we will also create now).
- The processor function simply returns the value of the updated stateValue variable.
- The HTML file the browser expects tends to be large for a variable, and even with the good SRAM memory space the ESP8266 has, it could cause problems.
- That's why we'll use the PROGMEM utility so that the variable is written to FLASH memory.
- Don't worry if you don't know HTML or javascript. We won't go into details, but we'll explain the most important ones for now.
- On line 23, the page displays the value returned by the processor() function.
- In line 24, the button calls the “toggleLED()” function when activated.
- The toggleLED() function makes a GET request at address “/state” passing the toggle valceue.
- After 1 second it refreshes the page to receive the updated value. We need to handle this request:
- When the server receives the request at the address “/state” it calls the toggleLed() function
- and just replies to the server that everything went fine. And last but not least: We started the server:
- This will be our final code:
Conclusion
In this project, we saw a very simple application of the power that the ESP8266 WiFi has. In the HTML file, page styling could also be included to make the page prettier.
And with that base, it's possible to expand into several cool projects. A temperature monitor via Wifi? Security systems? Home automation systems? These are just a few examples. The limit is up to your creativity.
ESP8266 based WiFi Modules for IoT Projects
The Internet of Things (IoT) and the Industry 4.0. Distinct technological revolutions but with a common goal: To integrate equipment (digital or analog) to a computer network.
And to be part of this revolution, the developer goes out of its way to include wired ethernet modules or WIFI modules in its circuits. Which increases complexity, circuit size and development cost.
What if I told you that already has a built-in WIFI microcontroller? And that it fits in the palm of your hand? For just 1 US dollar?
Today I’m going to introduce you to the ESP8266 microcontroller, from Espressif. And for those of you who already program in 8Bit microcontrollers like the Atmega328 (one of the most common on Arduino) and struggle to build your code in the modic SRAM’s 2KB and Flash memory’s 32KB… The ESP8266 offers 32KB to RAM and 512KB to Flash Memory … expandable up to 4MB.
Did I get your attention? So, let’s go to a summary of the specs, provided by the manufacturer itself:
- 32-bit RISC architecture;
- 80MHz processor (can be expanded up to 160MHz);
- Operating Voltage of 3V;
- 32KB of RAM memory for instructions;
- 96KB of RAM memory for data;
- 64KB of ROM memory to boot;
- Flash memory preview by SPI (512KB to 4MB);
- Wireless 11 b/g/n standard;
- Operating modes: STA/AP/STA+AP;
- WEP, WPA, TKIP, AES security;
- Built-in TCP/IP protocol;
- QFN encapsulation with 32 pins;
- Main Peripherals: UART, GPIO, I2C, I2S, SDIO, PWM, ADC and SPI;
- Architecture with prediction of operation in energy saving
At this point you may have noticed that I stated that the ESP8266 has a 512KB Flash memory, extendable up to 4MB, but then I said that the module only provides this memory per SPI. Before explaining this, I want to draw your attention to another important point: The ESP8266 has a WIFI module inside a QFN package. WIFI is radio frequency! And how does it work without an antenna? The answer is: It doesn’t work!
The ESP8266Ex chip (this is its full name) needs an antenna to be connected to your antenna’s specific pins as well as a FLASH memory IC.
Started to get complicated? Don’t worry. With the idea of making the chip more accessible, several modules were developed that already include an antenna and a memory chip.
Understanding the need to include an antenna for the WIFI, a memory IC in the SPI and making pins more accessible, several manufacturers started working on ore “friendly” ESP8266’s versions. Among the best known are the ESP-01, ESP-03, ESP-05, ESP-07, ESP-12E, ESP-12F and NodeMCU. All of them have the esp8266 microcontroller in common, but they vary in size, antenna availability, memory size and pin availability. There are others, but today we’ll talk a little about them.
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | ESP8266 | Amazon | Buy Now |
ESP-01
It is the most common module in the ESP8266 range. It is compact (24.8 x 14.3 mm), the WIFI antenna is built in the board itself and has two GPIO pins that can be controlled according to programming. There are two significant drawbacks to this card:
- The pins are not intended for connection to a breadboard. Although they fit well, they end up shorting So, they necessarily need wires to extend the pins.
- The two available GPIOs play an important role in the board So it is necessary to pay attention to the level (high/low) when the board is initialized, or the board may mistakenly enter in programming mode. So, pins are safer operating as Outputs than as Inputs.
ESP-03
This version comes with a ceramic antenna, 7 GPIOs (two are those of the ESP-01 that require attention), a pair for UART, in size 17.4 x 12.2 mm. Smaller than 01? Yes! But that comes at a price: The encapsulation is another.
ESP-05
- No GPIOs available, it actually doesn’t even have a built-in antenna.
- This version was thought to incorporate WIFI to some other microcontroller (with the smallest possible size: 14.2 x 14.2 mm), so it has an external connector and UART pins to be manipulated by AT commands.
ESP-07
- The ESP-07 has both a ceramic antenna and an external connector. Looks a lot like the ESP-03, but leaves the meager analog pin available.
- In addition to incorporating a metallic cover that protects the circuit against magnetic interference.
ESP-12E and ESP-12F
Built-in antenna, 11 GPIOs, UART available, SPI available (not exactly, it’s still being used by the flash memory CI, but now you get the option to disable the memory and associate a larger one), an ADC pin (pause here to explain because it’s not that useful, The board operates with 3.3V, but the ADC is 0 – 1V. Low resolution, plus the big risk of damaging everything.).
The ESP-12E would be icing on the cake for the ESP8266’s boards, but the ESP-12F version handled an improvement in the antenna design and a little more pin protection.
NodeMCU
The NodeMCU module is to the ESP-12s as the Arduino UNO is to ATMEGA328s. A board with a protoboard compatible pinbus, all ESP-12 pins available, a 3.3V regulator to power the module (the VIN pin can receive 5V) and a UART – USB interface that turn the nodeMCU into a plug an play module.
There are versions with the ESP-12E (increasingly rare) and with the ESP-12F.
Now that we know a little more about the hardware, let’s take a look at how to program it.
There are different ways to programming the ESP8266. Different methods, different languages, among the most common, we have the ESP-IDF (manufacturer’s official. C programming) and others recommended, also, by the manufacturer: NodeMCU (Lua Script), Arduino (C++), MicroPython (you get one candy if you guess the language). It is possible to work with it in PlatformIO as well.
ESP-IDF
The ESP-IDF is the official Espressif solution. The SDK has a number of precompiled libraries and works with the Xtensa GCC compiler.
For a long time, the company has released RTOS and NON-OS versions in parallel. But since 2020 no NON-OS versions have been released (except minor bug fixes). Other modules from Espressif were born exclusive to RTOS versions, probably this was already part of the decision to bury the NON-OS. IN 2019, the company released a note stating that it would keep the main version, but that it would only operate in the correction of critical bugs. It even released some new features after that, but it doesn’t compare in quantity to the RTOS version.
This is without any doubt the most specialized tool that allows for the greatest customization at a low level. Drivers and libraries are customized for company modules. And specialization directly reflects on performance.
But the ESP-IDF lacks in complexity and size of the active community. Which ends up making the solution’s development a little slower. How does this happen? The programming is done in C- ANSI, in some cases with the directly treatment of registers, creating a more verbose code. More verbose? More chances for bugs. Also, active community is something that needs to be looked at when using any technology. Whether for creating new libraries or for sharing issues and solutions. The ESP-IDF user community exists, but it is much smaller than the others that will be presented here.
NodeMCU
The NodeMCU is an ambiguous term, it can either be used to indicate the NodeMCU module (hardware) or the NodeMCU development environment (software), both can be used together. But not necessarily. Let’s go to the software one.
The NodeMCU is a Lua-based firmware specific to the ESP8266 and uses a SPIFF (SPI Flash File System) based file system. This firmware is installed directly in FLASH memory, which allows the code’s execution in real time, without the need for compilation.
It offers a library structure for native functionality and for sensor’s integration, such DS18B20 or BME280, which make programming more dynamic.
The NodeMCU has been popular for quite some time. But it has three serious problems that have started to reduce its use.
- The Firmware NodeMCU, installed in FLASH, takes up a lot of Especially if the full version is included.
- It was developed based on the NON-OS version, so, firmware bugs started to get more complex to
- The memory management is quite complex in some cases. Because it didn’t compile, some memory overflow issues could only be noticed at runtime. (This was the reason I stopped using this method).
Arduino
The Arduino platform, undoubtedly the best known in the world when it comes to microcontrollers, is also on the manufacturer’s list of nominees.
The Arduino was built as software-hardware relationship that makes microcontroller’s development more accessible to non-specialists. The hardware complexity was minimal (in some cases none) and the software started to be treated in a high-level language (C++), allowing even object orientation.
Because it is so accessible, some members of the software’s community have started to be collaborators in building libraries (Only to control LCD displays, I know four), some sensor’s manufacturers offer official versions as well. Constantly updated material. Etc. Etc.
The Arduino architecture started with the Arduino Uno board (which uses an ATMEGA328), expanded support to other boards and… for some time now, it has support for ESP8266 in different modalities. There is good compatibility with standard Arduino libraries and it has its own.
MicroPython
I Don’t know the MicroPython in practice (yet), but as the name advertises, it allows programming in Python. Like NodeMcu, it deploys a firmware to FLASH memory and has well- defined libraries for hardware usage.
The space occupied in Flash is well optimized (not even compared to NodeMCU chaos). It seams to have a very active community. As for programming complexity I don’t have much information. But if you program in Python, I think it’s worth the experience.
PlatformIO
The PlatformIO is not really a development platform, but it allows an integration with other platforms to simulate the board. If you don’t have an ESP8266 on dang yet, it might be a good choice for your first steps.
However, there is a natural limitation when simulating a module whose flagship is WIFI.
Don’t you know where to start?
Personally, I think that the Arduino environment is perfect for prototyping. It’s easy to get results pretty quickly to validate a proof of concept. But in some cases you can go beyond that. If your project doesn’t demand maximum performance from the ESP8266, even the production version can be built here.
For a project that requires a lot of hardware precision, I don’t recommend intermediaries. Nothing will perform better than IDF.
For educational purposes, our next articles will use the NodeMCU board programmed on the Arduino platform.
Latest Proteus Libraries for Engineering Students V2.0
Hi Friends! Hope you’re well today. Happy to see you around. In this post today, I’ll walk you through Latest Proteus Libraries for Engineering Students V2.0.
We have been designing proteus libraries for our blog readers for quite a while now. You might have visited our Arduino Libraries for Proteus V2.0 and Analog Sensors Libraries for Proteus V2.0. We keep working on those libraries and make sure the bugs are removed and you always get the updated version of those libraries.
We are going to share the most advanced and upgraded version of Proteus Libraries V2.0 we have designed for our readers. These libraries are more robust, fast, and efficient than previous versions. Moreover, we have converted some digital sensors to analog sensors, helping you pick from a wide range of libraries for your projects. If you think some sensors or modules are missing in the Proteus database that should be included, leave your valuable suggestion in the section below. We’ll try our best to design and simulate those in proteus.
Before further ado, let’s jump right in.
Latest Proteus Libraries for Engineering Students V2.0
We’ll be covering both Arduino Libraries for Proteus V2.0 and Analog Sensors Libraries for Proteus V2.0.
Arduino Libraries for Proteus V2.0
Arduino boards are open-source electronic development boards that you can use in your projects. Arduino Libraries for Proteus V2.0 contain the following Arduino boards.
1. Arduino UNO Library for Proteus V2.0
Arduino UNO is a microcontroller board based on the Atmega328 microcontroller. We have designed Arduino UNO Library for Proteus V2.0 which you can download from the link given below. We’ve previously designed the Proteus Library for the Arduino UNO V1.0 board and the below figure shows the comparison of both V1 and V2 Arduino boards. You can see the V2 board is more compact and small-sized compared to the V1 Arduino UNO board.
In this library, we’ve also interfaced LCD with the Arduino UNO. If you find any difficulty in interfacing the board with the LCD, you can approach me in the section below. I’d love to help you the best way I can.
Download the Arduino UNO Library for Proteus V2.0 by clicking the link below:
Download Arduino UNO Library for Proteus V2.0
2. Arduino Mega 1280 Library for Proteus V2.0
Arduino Mega is an electronic board that features an Atmega1280 microcontroller. You can use this board to develop stand-alone electronic projects or you can also incorporate it into embedded projects. Again, the following figure shows a comparison between Arduino Mega 1280 V1 and V2. The V2 board is compact and small-sized compared to the V1 board.
We have developed the Arduino Mega 1280 library for proteus V2.0 which you can download to simulate Arduino Mega 1280 in proteus.
Download the Arduino Mega 1280 Library for Proteus V2.0 by clicking the link below:
Download Arduino Mega 1280 Library for Proteus V2.0
3. Arduino Mega 2560 Library for Proteus V2.0
Arduino Mega 2560 is a sophisticated, application-type microcontroller board that features an Atmega2560 microcontroller. This board comes in handy when you require more input and output pins and more memory space to store the code for your electronic project. We have developed Arduino Mega 2560 Library for Proteus V2.0 to help you simulate this board in the proteus. Moreover, we’ve also interfaced LCD with this board so if you have any questions about it, you can ask me in the section below:
]TEPImg6]
Click the link below and download the Arduino Mega 2560 Library for Proteus V2.0.
Download Arduino Mega 2560 Library for Proteus V2.0
4. Arduino Mini Library for Proteus V2.0
Arduino Mini is a small-sized, powerful open-source microcontroller board based on the Atmega328 microcontroller. The board is 1/6th of the size of the Arduino UNO board and can easily rest on hard-to-reach places. We have designed Arduino Mini Library for Proteus V2.0 that you can download to simulate Arduino Mini in Proteus.
Click the link below and download the Arduino Mini Library for Proteus V2.0:
Download Arduino Mini Library for Proteus V2.0
5. Arduino Pro Mini Library for Proteus V2.0
Arduino Pro Mini is a small-sized microcontroller board that includes an Atmega328 microcontroller. The Proteus library V2.0 is designed for Arduino Pro Mini, moreover, we have also interfaced the board with the LCD 20x4.
Click the link below and download the Arduino Pro Mini Library for Proteus V2.0.
Download Arduino Pro Mini Library for Proteus V2.0
6. Arduino Nano Library for Proteus V2.0
Arduino Nano is a powerful and bread-board-friendly microcontroller board based on ATmega328p/Atmega168 microcontroller. We have developed the Arduino Nano Library for Proteus V2.0 which you can download to simulate Arduino Nano in the Proteus workspace.
Click the link below and download the Arduino Nano Library for Proteus V2.0:
Download Arduino Nano Library for Proteus V2.0
Analog Sensors Libraries for Proteus V2.0
Analog Sensors Libraries for Proteus V2.0 contain the following Analog Sensors.
Vibration Sensor Library for Proteus V2.0
An analog vibration sensor, also known as a piezoelectric, is mainly employed to detect the vibration of industrial machinery. The sensor gets activated if the vibration of the machines goes above the standard value. Vibration sensors are used to monitor the small changes in temperature, acceleration, pressure, and force.
We have done a little work and designed Analog Vibration Sensor Library for Proteus V2.0. Earlier we designed the proteus library for V1 version analog vibration sensors. The V2 version is more robust, compact, and advanced compared to the V1 version. Four vibration sensors are included in the proteus library and they have both digital and analog output pins which you can interface with Arduino boards or microcontrollers.
You can download the analog vibration sensor library for proteus V2.0 by clicking the link below:
Download Vibration Sensor Library for Proteus V2.0
Sound Detector Sensor Library for Proteus V2.0
A sound detector sensor is used to detect the sound in the environment. This sensor is only used for sound detection, not for sound recognition.
We have designed the Sound Detector Sensor Library for Proteus V2.0 that you can download to simulate this sensor in proteus. An LC filter is used on the analog output of the sensor since we need to convert the peak to peak voltage into Vrms. Know that you don’t require this LC filter in the real sensor circuit. We have simulated two sound detector sensors in proteus as they have different outputs because of different voltages on the test pin.
Click the link below and download the Sound Detector Sensor Library for Proteus V2.0:
Download Sound Detector Library for Proteus V2.0
Analog Flex Sensor Library for Proteus
An Analog flex sensor, also known as a bend sensor, is a special type of sensor used to detect the value of bend in the application. This sensor is mainly employed indoor sensors, robot whisker sensors, and stuffed animal toys.
We have developed an analog flex sensor library for proteus that you can download to simulate this sensor in Proteus. Know that Test Pin is included in the pinout of this sensor in proteus only, you won’t find this pin in the real sensor. This pin will determine the value of the bend. The HIGH value at this pin will give the value of bend and the LOW value at this pin will indicate there is no bend. We have also interfaced the Arduino board with the sensor where the analog input pin of the board is connected with the voltage appearing across the voltmeter.
Click the link below and download the Analog Flex Sensor Library for Proteus:
Download Flex Sensor Library for Proteus
Analog PIR Sensor Library for Proteus
PIR (Passive Infrared) sensor is a small, inexpensive, low-power sensor used to detect heat energy in the surrounding. The sensor monitors if the human body has come in or out of the sensor’s range.
We have designed Analog PIR Sensor Library for Proteus that you can download to simulate this sensor in Proteus. Moreover, we’ve also developed a simulation of this PIR sensor with an Arduino board. Know that, besides Arduino boards, you can also interface this sensor with PIC or Atmel microcontrollers. We’ve added four PIR sensors file in the proteus that are the same in terms of working but they come in a different color. Again, a test pin is added in the pinout of this sensor in proteus only, you won’t find this pin in real. This pin is added to sense the motion in the proteus workspace.
Click the link below and download the Analog PIR Sensor Library for Proteus:
Download PIR Sensor Library for Proteus
Water Sensor Library for Proteus
A water sensor is a sensor used to sense the presence of water. The water’s electrical conductivity is measured using this sensor to sense the presence of water. This sensor is widely used in applications where we need to monitor rainfall, water level, and water leakage.
We have designed the water sensor library for proteus which you can download to simulate this sensor in proteus. The Test pin is added to detect the water in the proteus simulation. We’ve also interfaced this sensor with the Arduino board where we have connected the analog input pin of the Arduino board with the output of the water sensor appearing across the voltmeter.
You can download the water sensor library for Proteus by clicking the link below:
Download Water Sensor Library for Proteus
Soil Moisture Sensor Library for Proteus
A soil moisture sensor is employed to analyze the water content in the soil. The sensor uses capacitance to monitor the dielectric permittivity of the soil which defines the function of the water content.
We have designed the Soil Moisture Sensor Library for Proteus where we have connected the test pin with the variable resistor. This resistor is used to define the soil moisture content in the proteus simulation. The maximum resistance on the test pin shows zero volts across the voltmeter, referring to the zero moisture value of the water content. The sensor is also interfaced with the Arduino board as shown below.
Click the link below and download the Soil Moisture Sensor Library for Proteus:
Download Soil Moisture Library for Proteus
IR Proximity Sensor Library for Proteus
The IR proximity sensor is used in robots to detect obstacles. This sensor is widely used for path navigation and obstacle avoidance in electronic projects.
We have designed the IR Proximity Sensor Library for Proteus which you can download to simulate this sensor in Proteus. The Test pin is used for hurdle detection. HIGH value on this pin means there is an obstacle in front and LOW value on this pin means there is no hurdle.
LC filter is included in the simulation which you don’t require in real. This filter is used to convert the Peak to Peak value we get on Proteus into the Vrms value.
[TEPImg16]
You can download the IR proximity sensor library for proteus by clicking the link below:
Download IR Proximity Sensor Library for Proteus
That’s all for today. Hope you find this article helpful. If you have any questions, you can approach me in the section below. I’d love to help you the best way I can. Thank you for reading this article.
Vibration Sensor Library for Proteus V2.0
Hello friends, I hope you all are doing great. In today's tutorial, I am going to share a new Vibration Sensor Library for Proteus V2.0. It's the second version of the Vibration Sensor Library for Proteus. In this library, we have four vibration sensors.
These vibrations sensors have both digital and analog output pins and can easily be connected with microcontrollers i.e. Arduino, PIC, Atmel etc. Before downloading the Proteus Library zip file, let's first have a look at the brief overview of Vibration Sensor:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | Arduino Uno | Amazon | Buy Now |
What is Vibration Sensor?
- A vibration sensor is a small embedded sensor, which is used to detect vibrations on any surface.
- These vibration sensors are used for various purposes i.e. fault detection on heavy machinery, placed on doors & windows for security etc.
- Real vibration sensors are shown in the below figure:
Vibration Sensor Library for Proteus V2.0
- First of all, download the zip file of Proteus Library for Vibration Sensor, by clicking the below button:
Download Proteus Library Files
- After downloading the zip file, extract its files and open the folder named "Proteus Library Files".
- In this folder, you will find 3 Proteus Library Files named:
- VibrationSensor2TEP.IDX
- VibrationSensor2TEP.LIB
- VibrationSensor2TEP.HEX
- We need to place these files in the Library folder of Proteus software.
Note:
- After adding these library files, open your Proteus software or restart it, if it's already running.
- In the components section, make a search for Vibration, and you will get results, as shown in the below figure:
- In the above search result, the first four modules are from V2.0, while the fifth one is of the first version.
- Let's place these first four modules in the Proteus workspace, as shown in the below figure:
Adding Hex File to the Sensor
- Next, we need to add the hex file of the sensor, so double click on the sensor to open its Properties Panel.
- In the Program File section, browse to the hex file, which we have downloaded above and placed it in the Library folder of Proteus software:
- After adding the hex file, click the Ok button to close the properties panel.
The vibration sensor is now ready to simulate in Proteus, so let's design a simple circuit to understand its working:
Vibration Sensor Proteus Simulation
- I have simulated two of these vibration sensors, as shown in the below figure:
- As you can see, I have placed an LC filter on the analog output of the vibration sensor, its because proteus gives us a peak to peak voltage value and we need t convert it to Vrms.
- This LC filter is not required in real hardware.
- Now, let's run the Proteus simulation and if everything's fine, you will get results as shown in the below figure:
- As the potentiometer value is different on both sensors, that's why we are getting different outputs.
So, that was all for today. I hope this sensor will help engineering students in their projects' simulations. Thanks for reading. Have a good day. Bye !!! :)
Sound Detector Library for Proteus V2.0
Hello friends, I hope you all are doing great. In today's tutorial, we are going to share a new Sound Detector Library for Proteus. It's actually the second version of our previous library
Sound Sensor Library for Proteus. We have changed the name as "Sound Detector" is written on these sensors. Moreover, this new sensor is quite small-sized, compact and also has an analog output pin.
We were receiving many complaints about the large size of the previous sound sensor, as it occupies more space and there's less space left for other components. So, this new one is quite small-sized and I am hopeful students will find it helpful. So, let's first have a look at What is Sound Detector Sensor and why is it used?
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | Arduino Uno | Amazon | Buy Now |
What is Sound Detector Sensor???
- Sound Detector sensor is an Embedded sensor, used for the detection of sound in the surroundings.
- It has both analog & digital outputs and thus gives us information about the intensity of sound as well i.e. how low or high the sound is?
- So these sensors are used for sound detection but they are not used for sound recognition.
Now let's download the Proteus Library of Sound Detector Sensor and simulate it:
Sound Detector Library for Proteus V2.0
- First of all, download the proteus library of Sound Detector Sensor by clicking the below button:
Download Proteus Library Files
- You will get a zip file of Proteus Library, extract these files and open the folder named "Proteus Library Files".
- In this folder, you will find three files, titled:
- SoundDetector2TEP.IDX
- SoundDetector2TEP.LIB
- SoundDetector2TEP.HEX
- We need to place these three library files in the Proteus Library folder.
Note:
- Once added the Library files, now open your Proteus software or restart it. (In order to index the library components, proteus has to restart)
- In the components section, make a search for sound detector and you will get 4 results, shown in the below figure:
- Now, let's place all these sensors in the Proteus workspace:
Adding Hex File to the Sensor
- In order to simulate this sensor in Proteus, we need to add a hex file to the sensor.
- So, double click on the sensor or right-click on it and then click on Edit Properties and it will open up the Properties Panel.
- In the Properties panel, we have a textbox titled Upload Hex File and here we need to add the hex file, which we have placed in the library folder of Proteus, as shown in the below figure:
Now our sensor is ready to simulate, so let's design a simple circuit to understand its working:
Sound Detector Simulation in Proteus
- As we have seen this sensor consists of 5 pins in total, which are:
- V: Vcc (Power).
- G: Ground.
- D0: Digital Output.
- A0: Analog Output.
- Test: For Testing Purposes. (It's not present in real sensor)
Why Test Pin is used?
- As we can't add a real mic in Proteus simulation, so in order to simulate this sensor, we have placed this Test Pin.
- So, when the voltage at Test Pin will increase, the sensor will consider it as sound intensity is increasing.
- We need to connect a potentiometer with this Test Pin.
Sound Detector Circuit Diagram
- Now, we need to design a simple circuit in Proteus, as shown in the below figure:
- As you can see in the above figure, I have placed an LC filter on the analog output, because we are getting peak to peak voltage and we need to convert it to Vrms.
- We don't need to place this LC filter with the real sensor.
- Now, let's run this simulation and if everything's good, you will get results as shown in the below figure:
- I have simulated two of these sound detector sensors and you can see they have different outputs because they have different voltage at their Test Pins.
So, that was all for today. If you have any problem in simulating the sound detector, ask in the below comments. We will soon share its simulation with Microcontrollers. Thanks for reading. Take care !!! :)
Infrared Tracker Sensor Library for Proteus
Hello friends, I hope you all are doing great. Today, I am going to share a new Infrared Tracker Sensor Library for Proteus. By using this library, you will be able to simulate IR based tracker sensor. This library contains 4 tracker sensors in it.
This Infrared Tracker Sensor is not present in Proteus software and we are sharing it for the first time. We have already shared 2 Proteus Libraries of Infrared sensors, you should check them as well.
Note:
- You should also have a look at:
First, let's have a look at what is tracker sensor and why is it used?
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | IR Tracker Sensor | Amazon | Buy Now |
2 | Arduino Uno | Amazon | Buy Now |
What is IR Tracker Sensor???
- IR Tracker Sensor uses Infrared technology and contains two IR LEDs on it.
- A signal is transmitted from one LED, which is reflected back after hitting some target and is received by the second LED.
- This sensor is normally used in Line Tracking Robotic Projects, where the black line is sensed by this IR Tracker sensor.
Infrared Tracker Sensor Library for Proteus
- First of all, download the zip file of Proteus Library by clicking the below button:
Download Proteus Library Files
- Once you downloaded the zip file, extract it and open the folder named "Proteus Library Files".
- You will find three files in it, named:
- InfraredTrackerSensorTEP.IDX
- InfraredTrackerSensorTEP.LIB
- InfraredTrackerSensorTEP.HEX
- Place these three files in the Library folder of your Proteus software.
Note:
- Now open your Proteus software or restart it, if it's already running.
- In the components section, we need to make a search for Infrared Tracker Sensor, and you will get results as shown in the below figure:
- As you can see in the above figure, now we have 4 infrared tracker sensors in our Proteus database.
- Let's place these sensors in the Proteus workspace, that's how they will look like:
Adding Hex File to the sensor
- Now we need to add the hex file to the sensor, so double click on the sensor to open its Properties Panel.
- In the properties panel, we have a textbox named "Program File".
- In this textbox, browse to the hex file of the sensor, which we have placed in the Library folder of Proteus software, as shown in the below figure:
- After adding the hex file, click the OK button to close the properties panel.
Our sensor is now ready to operate.
Infrared Tracker Sensor Pinout
- As you can see these sensors have five pins in total, which are:
- V: Power.
- G: Ground.
- D0: Digital Output.
- A0: Analog Output.
- Test: For Testing Purposes.
Why Test Pin is used?
- As it's a simulation, so we can't actually generate IR pulses, that's why I have placed this Test Pin.
- As the voltage at Test Pin will increase, the sensor will consider it as the obstacle is coming close.
- We will place a potentiometer at this Test Pin.
- This Test Pin is not present in a real IR Tracker sensor.
So, let's design a simple simulation of this Infrared Tracker sensor to have a look at its working:
Infrared Tracker Sensor Proteus Simulation
- Design a simulation in Proteus, as shown in the below figure:
- I have placed an LC circuit in front of the analog output because we have to convert the peak to peak voltage to Vrms.
- This LC filter is also not required in real hardware, but in simulation, we need to place it to get an analog value.
- Now, let's run our Proteus simulation of the IR sensor and if everything goes fine, you will get results as shown in the below figure:
- I have simulated two of these sensors, the rest will work the same and as you can see depending on the potentiometer, we got different values at the output.
So, that was all for today. I hope this library will help you guys in your engineering projects. If you have any questions/suggestions, please use the below comment form. Thanks for reading. Take care !!! :)
Magnetic Hall Effect Sensor(KY-024) Library for Proteus
Hello friends, I hope you all are doing fine. Today, I am going to share a new
Magnetic Hall Effect Sensor Library for Proteus. We are sharing this library for the first time and we hope it will help students in their final year & semester projects.
In this library, you will find 4 models of the KY-024 Magnetic Hall Effect Sensor. First, we will have a look at the brief overview of Magnetic Hall Effect Sensor, then will add its Library in proteus and will simulate it. So, let's get started:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | Arduino Uno | Amazon | Buy Now |
What is Magnetic Hall Effect Sensor?
- Magnetic Hall Effect Sensor is used to measure the density of magnetic field in the surroundings using Hall Effect Principle.
- KY-024 is the sensor's model used for measuring magnetic density.
- There are many different breakout boards available but they all are using the same sensor i.e. KY-024.
So, let's install its Proteus Library and simulate it:
Magnetic Hall Effect Sensor Library(Ky-024) for Proteus
- First of all, download the Proteus Library zip file for Magnetic Hall Effect Sensor, by clicking the below button:
Proteus Library Files
- In this zip file, we need to open the folder titled Proteus Library Files.
- In this folder, you will find three Proteus Library files, named:
- MagneticHallEffectSensorTEP.IDX
- MagneticHallEffectSensorTEP.LIB
- MagneticHallEffectSensorTEP.HEX
- We need to place these files in the Library folder of our Proteus software.
Note:
- Now, open Proteus ISIS and if you are already working on it, restart it.
- In the components search box, make a search for "Magnetic Hall" and you will get four results, as shown in the below figure:
- Let's place these four Hall Effect sensors' models in our Proteus workspace.
So, we have successfully added these sensors to our Proteus software. Let's design a simple simulation to have a look at its working:
KY-024 Proteus Simulation
- As we have seen this simulated model of KY-024 has five pins in total:
- A0: Analog output.
- G: Ground.
- V: Vcc (Power).
- D0: Digital output.
- Test: For testing purposes.
Why Test Pin is used?
- As it's stimulation, so we can't actually create a magnetic field around the sensor, that's why we have placed this Test Pin.
- As the voltage at Test Pin will increase, the sensor will consider it as magnetic density is increasing around.
- If Test Pin is at 0V, the sensor will feel no magnetic field.
- If Test Pin is 5V, the sensor will feel a maximum magnetic field.
- We will attach a potentiometer to the Test Pin, for variable voltage levels.
Adding Hex File to the sensor
- In order to operate the magnetic Hall Effect sensor, we need to add a hex file in its properties panel.(We have placed the hex file in the Library folder)
- So, double click on your sensor to open its properties panel.
- In the Upload Hex File section, browse to your sensor's hex file, as shown in below figure:
- After adding the hex file to the sensor, click on the Ok button to close the properties panel.
Now our sensor is fully operational, so let's design its simulation:
Proteus Simulation of Magnetic Hall Effect Sensor
- Now, let's design a simulation in Proteus software, as shown in the below figure:
- I have attached an LED with the digital output of the sensor and a voltmeter with analog output.
- I have also placed a simple LC filter at the analog output. This filter is not required in real hardware implementation.
- We are using it in Proteus simulation, as Proteus gives the peak to peak value and we have to convert that PP value into Vrms.
- If you are working on a real sensor then you don’t need to add this LC circuit.
- Now, let's run our simulation and if everything's configured correctly, you will get results as shown in the below figure:
- As you can see in the above figure, our sensors are working perfectly, now if you change the value of the potentiometer, their output will change accordingly.
So, that was all for today. I hope this sensor will help you guys in your final year and semester projects. If you have any questions, please ask in the comments. Thanks for reading. Take care !!! :)
Soil Moisture Sensor Library for Proteus V2.0
Hello friends, I hope you all are doing fine. In today's tutorial, I am going to share a new Soil Moisture Sensor Library for Proteus V2.0. You should also have a look at its previous version i.e. Soil Moisture Sensor Library for Proteus V1.0. If you have worked on the previous version, it has only one soil moisture sensor in it, while in this library, we have added three soil moisture sensors.
First, we will have a brief introduction of the Soil Moisture sensor, then we will download the zip file containing Proteus Library files of Soil Moisture Sensor and finally, we will design a small simulation using these new sensors. So, let's get started:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | Arduino Uno | Amazon | Buy Now |
What is Soil Moisture Sensor?
- Soil Moisture sensor is an embedded sensor, used to measure the moisture level of the soil.
- It is normally used in agricultural automation projects, i.e. controlling the water flow based on the moisture level of the soil.
- Soil Moisture sensors are available with both analog and digital outputs.
- They normally have a potentiometer embedded in them, for controlling the sensitivity of the sensor.
Before downloading the sensor's library file, let's first have a look at what's new in version 2.
Difference b/w V1.0 & V2.0
- We received many complaints about the big size of the Soil Moisture sensor(V1.0), so we have reduced their sizes in this new library(V2.0).
- The first version contains only 1 soil moisture sensor, while in V2.0 we have added three soil moisture sensors.
- The output of V1.0 was quite smooth, while in V2.0 we have made the output a bit fluctuating to make it more realistic.
Now, let's download the Proteus Library zip file for this sensor and simulate it in Proteus:
Soil Moisture Sensor Library for Proteus V2.0
- First, we need to download the Proteus Library zip file, by clicking the below button:
Soil Moisture Sensor Library for Proteus V2.0
- After downloading the zip file, extract it and open the folder named Proteus Library Files.
- You will find three files in this folder, named as:
- SoilMoistureSensor2TEP.IDX
- SoilMoistureSensor2TEP.LIB
- SoilMoistureSensor2TEP.HEX
- Place these files in the library folder of your Proteus software.
Note:
- Now, open Proteus ISIS, and if you are already working on it, then restart it.
- In the components library, make a search for Soil Moisture Sensor, and you will get results as shown in the below figure:
- Let's place these three soil moisture sensors in the Proteus workspace:
- Quite pretty, aren't they? :)
Now let's design a small simulation, to have a look at its working:
Proteus Simulation of Soil Moisture Sensor
- As you can see in the above figure, each of these sensors has 4 pins in total, which are:
- Vcc: We need to provide +5V here.
- GND: We need to connect it to Ground.
- A0: It's the analog output pin, its value will increase as the moisture level of the soil will increase.
- TestPin: The voltage level of TestPin will decide the moisture level of the soil.
Why Test Pin is used?
- As it's a simulation, so we can't actually probe the sensor in real soil, so we are using this TestPin for testing purposes.
- The value of Test Pin can vary from 0 to 5V, so as the value of this Test Pin will increase, the sensor will consider the moisture level of the soil in increasing and thus its output will also increase. In simple words:
- If TestPin is HIGH: Soil has maximum moisture level.
- If TestPin is LOW: Soil is completely dry.
- We will place a potentiometer at TestPin to provide variable voltage for testing.
Adding Hex File to the sensor
- We have placed three library files of soil moisture sensor in the Library folder of Proteus, and if you have noticed, one of them is the .hex file.
- In order to operate this sensor, we need to add that hex file to our sensor.
- So, double click on the Soil Moisture sensor to open its Properties Panel.
- In the properties panel, we have a section named "Program File", here upload the hex file which we have downloaded, as shown in the below figure:
- After adding the hex file, click Ok to close the properties panel.
- Now, design a small simulation, as shown in the below figure:(I have added this simulation in the Proteus Library zip file)
- I have added the hex file in both of these soil moisture sensors.
- Now, let's run the Proteus Simulation and have a look at the output:
- As we change the value of the potentiometer(attached to Test Pin), the output of the sensor will change accordingly.
So, that was all for today. I hope this library will help embedded students in their engineering projects. If you have any suggestions/comments, please use the below comment form. Thanks for reading. Take care. Bye !!! :)
Home Security System using Arduino UNO in Proteus
Hello friends, I hope you all are doing well. In today's tutorial, we are going to design a Home Security System using Arduino UNO in Proteus software. It's the most commonly designed engineering project, especially in electrical, electronics and mechatronics engineering. Normally engineering students design it as a semester project during their engineering course.
So, today we will design a home security system from scratch in Proteus software. I have given the complete project below to download but I would suggest you to design it on your own so that you could understand it better. So, let's get started:
Home Security System: Project Description
- Before going into the detail, let's first download the complete Proteus Simulation with Arduino Code, by clicking the below button:
Home Security System using Arduino UNO in Proteus
Let me first give you a detailed project description i.e. what we actually want to design? We want to build a Home Security Project, which should follow these security protocols:
- Fire alarm: It should be able to detect the fire and sound an alarm to alert everyone at home.
- Smoke alarm: It should detect the gas(smoke) and turn on the alarm(if detected).
The above-mentioned security protocols will be followed 24/7. Moreover, there will be two security modes in the project, named:
- Secure Mode.
- Normal Mode.
Let's have a look at both of these modes, one by one:
1. Secure Mode
- This mode should be selected, when owners want to completely secure their home i.e. they are leaving home or while sleeping at night.
- If the Secure Mode is selected, the project should follow the following security protocols:
- Intruder Detection Alarm: It should detect the presence of any human being in the occupied premises.
- Windows Security Alarm: If someone tries to break through the windows, the project should sound an alarm.
- Door Security Alarm: If any intruder tries to break through the main door, it should again sound the alarm to alert everyone.
2. Normal Mode
- This mode should be selected, when owners are at home and just want to take the basic security measures.
- In this mode, only the Fire Alarm & Gas Alarm will work, while all other alarms will remain on standby.
Other Features
- There should be an LCD, to display values of all parameters.
- It should have a buzzer to generate an alarm, in case of emergency.
- There should a Push Button to make switches between these security modes.
Here's the final simulation, which we are going to design in today's lecture:
So, these are our requirements, which we want to achieve in this Home Security Project. Now let's have a look at the components selected for this project:
Home Security System: Components Selected
Now let's have a look at the list of components, which I have selected for this Home Security Project. I will also briefly explain the purpose of using each component.
1. Arduino UNO
- As clearly it's an Embedded Systems Project, so first of all we need to select a Microcontroller for our project.
- As I have mentioned earlier, we will use the Arduino UNO Microcontroller board for designing this project.
- Arduino UNO will act as the brain of the project and will control all sensors and modules.
2. Flame Sensor:
- A flame sensor is used to detects the presence of fire.
- The sensor basically consists of a photo-diode that detects the Infrared rays that emit from the fire. When it detects a fire, its output goes HIGH.
3. Gas Sensor (MQ-6)
- MQ-6 Gas Sensor is used to detect the concentration of gases in the environment.
- The sensor produces a potential difference proportional to the concentration of the particular gases.
- The type of gas that it detects depends upon the material used in the sensor.
- There are many gas sensors available in the market i.e. MQ-2, MQ-3, MQ-4 etc.
- These sensors are available as ready-made modules for easy interfacing with the microcontroller.
4. PIR Sensor(HC-SR501)
- HC-SR501 PIR sensor is used to detect any human being(intruder) in the Secure Mode.
- It detects the IR radiations from the human movement & generates a pulse on its output.
- The time period of the pulse could be varied by using the potentiometer on the sensor.
5. Vibration sensor(SW-420)
- The SW-420 vibration sensor is used to detect any forced entry through windows.
- In Secure Mode, if someone tries to open the window, the sensor will detect vibrations and will send a HIGH signal to the microcontroller.
6. Infrared Sensor
- An infrared sensor will be placed at the door and someone tried to enter through that door, the sensor will detect it.
- It consists of an IR transmitter and a photo-diode that are placed close to each other.
- If any object movement occurs in front of the sensor, the IR rays hit the object and return back with a particular angle called incident angle.
- This pulls the comparator output to ground or logic LOW.
7. LCD 20x4
- LCD 20x4 will be used for displaying the values of all these sensors.
- It will also display useful information i.e. which mode is selected.
8. Buzzer
- A small 5V Buzzer is used to sound the alarm.
9. LM7805
- LM7805 is a voltage regulator and is used to convert voltage from 12V to 5V.
- Power sources(i.e. battery, adapter etc.) available are normally 12V, as it has become a standard.
- Moreover, many components also operate at 12V like a buzzer or DC motor.
- While microcontrollers and sensors work on 5V, so in Embedded projects, it's quite necessary to design a voltage regulator from 12V to 5V and in some cases 3.3V.
- I normally prefer LM7805 for converting voltage from 12V to 5V.
10. Resistances(1kohm)
- We need to use a few resistances of 1kohm.
11. Small LED
- We will also use a small LED for power indication.
12. Capacitors(100uF)
- We will also use few capacitors of 100uF, as it removes any noise/ripples.
So, these are the components, we are going to use for designing Home Security System. Now let's get started with designing the Proteus Simulation:
Proteus Simulation of Home Security System
As I have told you earlier, I am going to use Proteus software for designing this project. Proteus is an excellent simulation tool, where we will not only design the circuit of this project but will also test its output. I always design my programming algorithms on simulations as working on real hardware is too time-consuming. You should remove all your programming bugs in simulation and once confirmed then design your project in real hardware. So, let's start:
Install Proteus Libraries
- Arduino boards & sensors' modules are not available in the Proteus components list.
- So, first of all, we need to install these Proteus libraries:
- Adding these libraries is quite simple, you just need to place their files in the library folder of Proteus software.
- If you got any issues, then read this guide on How to add a Library in Proteus 8.
Once you added all the libraries, now open your Proteus software.
Designing Circuit Diagram in Proteus
- Now we need to design a circuit for our project, so select these components from Proteus Components Search Box.
- First of all, let's design the voltage regulator circuit using LM7805, which will be simply converting the voltage from 12V to 5V.
- As you can see in the above figure, I have used 12V Battery, while the output of LM7805 is showing 5V and I have also placed an LED for power indication.
LCD Interfacing with Arduino:
- Next, we need to interface 20x4 LCD with Arduino UNO, so design the circuit as shown in the below figure:
Next, we need to interface five sensors with Arduino UNO, so let's add them to our Proteus simulation:
Sensors Interfacing with Arduino:
- These are simple digital & analog sensors and are all powered up at 5V.
- So, simply connect them as shown in the below figure:
- The Flame Sensor is connected to pin A0 of Arduino UNO.
- Gas Sensor is connected to pin A1 of Arduino UNO.
- PIR Sensor is connected to pin A2 of Arduino UNO.
- The Vibration Sensor is connected to pin A3 of Arduino UNO.
- The Infrared Sensor is connected to pin A4 of Arduino UNO.
For simulation, ensure all hex files are uploaded to each sensor for proper working. You can upload the source code hex file to the Arduino, by pressing Ctrl+E or by right click --> Edit properties.
Buzzer & Push Button:
- Finally, we need to add the Buzzer to sound the alarm in emergency cases, I have connected it to Pin A5 of Arduino UNO.
- I have also connected a push-button for switching the modes, connected to Pin 7 of Arduino UNO, as shown in the below figure:
- Here's the image of the complete Proteus Simulation for Home Security System:
Now let's design the Arduino programming code for Home Security Project:
Arduino Code for Home Security System
In the previous section, we have designed the Proteus simulation of the project, now let's design its Arduino Code to make it alive. Let's get started:
Initialization LCD Arduino Code
- First of all, we need to define all our variables, as you can see in the code shown in the right figure.
- I have included the Liquid Crystal Library, which is used to operate LCD.
- Next, I have defined all my sensors to the respective pins and then initialized boolean variables for storing the output of sensors.
- In the Setup loop, I have made the sensors' pins input pullup using the pinMode Arduino command.
- Finally, displayed an initialization message on the LCD screen i.e. "Home Security System using Arduino UNO By TEP".
- The message will display for around 1 second and then LCD will be cleared and the SensorDisplay function will be called, which will simply write sensors' names on the LCD screen.
- Now compile your code and add the hex file in Arduino UNO and run your PRoteus simulation.
- If everything goes fine, you will get results as shown in the below figure:
So far, we have just displayed the sensor's names, now let's read the sensors' data in the loop section:
Reading Sensors' Data
- In the loop section, first of all, we need to read the sensors' data using the digitalRead command, as shown in the code.
- After reading the sensor's data, I have called the SensorValues function, in which I have placed a check on each sensor's value and updated it on LCD.
- It's quite straightforward code, if the sensor is giving HIGH output, I am displaying Yes on LCD and if it's LOW, I am simply printing No.
- We haven't yet defined the modes, so the project will keep on reading the sensors and will display their respective value in the LCD.
- As you can see in the below figure, if the TestPin of the sensor is HIGH, its respective value on LCD is showing "Yes" and if it's LOW then "No" is written.
- Now, if you change any sensor's value, its respective value on LCD will be updated.
So, we have successfully interfaced our sensors with Arduino UNO and now it's time to add operational modes to our project.
Two Operational Modes
- As I mentioned earlier, we need to add two operational modes in our project, and the push button will be used for conversion from one mode to another.
- So, I have simply added an If loop in my code, as shown in the figure on the right side.
- In normal mode, I have simply displayed the name of the mode at the first line of LCD.
- While in secure mode, I am checking if either of the sensors goes HIGH, simply turn ON the Buzzer.
- Although, you won't be able to hear the Buzzer sound in the below figure, but you can see Buzzer's Pin is HIGH because two of the sensors are giving a response. Check the video for Buzzer working.
- We normally need to use an optocoupler or relay driver in between the buzzer and microcontroller as buzzers normally operate at 12V, but 5V buzzers are also available.
- Here's the complete Arduino Code:
/*
* All rights reserved to TEP www.TheEngineeringProjects.com
*/
#include
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define Flame A0
#define Gas A1
#define Pir A2
#define Vib A3
#define Ir A4
#define Buzzer A5
#define Switch 7
boolean Fire, Smoke, Intruder, Window, Door;
boolean Mode = false;
void setup() {
pinMode(Flame,INPUT_PULLUP);
pinMode(Gas,INPUT_PULLUP);
pinMode(Pir,INPUT_PULLUP);
pinMode(Vib,INPUT_PULLUP);
pinMode(Ir,INPUT_PULLUP);
pinMode(Switch,INPUT_PULLUP);
pinMode(Buzzer,OUTPUT);
lcd.begin(20,4);
pinMode(Buzzer, OUTPUT);
lcd.setCursor(0,1);
lcd.print("HOME SECURITY SYSTEM");
lcd.setCursor(0,2);
lcd.print(" USING ARDUINO UNO ");
lcd.setCursor(7,3);
lcd.print("By TEP ");
//delay(700);
lcd.clear();
SensorDisplay();
}
void loop()
{
Fire = digitalRead(Flame);
Smoke = digitalRead(Gas);
Intruder = digitalRead(Pir);
Window = digitalRead(Vib);
Door = digitalRead(Ir);
Mode = digitalRead(Switch);
SensorValues();
if(Mode==false) // Normal mode
{
lcd.setCursor(4,0);
lcd.print("Normal Mode");
}
else // Secure Mode
{
lcd.setCursor(4,0);
lcd.print("Secure Mode");
if((Fire == HIGH) || (Smoke == HIGH) || (Intruder == HIGH) || (Window == HIGH) || (Door == HIGH)){
digitalWrite(Buzzer, HIGH);
}else{
digitalWrite(Buzzer, LOW);
}
}
}
void SensorDisplay()
{
lcd.setCursor(0,1);
lcd.print("Fire:");
lcd.setCursor(10,1);
lcd.print("Smoke:");
lcd.setCursor(0,2);
lcd.print("Door:");
lcd.setCursor(10,2);
lcd.print("Window:");
lcd.setCursor(0,3);
lcd.print("Intruder:");
}
void SensorValues()
{
if(Fire == true){ lcd.setCursor(6,1); lcd.print("Yes");}
else{ lcd.setCursor(6,1); lcd.print("No ");}
if(Smoke == true){lcd.setCursor(17,1); lcd.print("Yes");}
else{lcd.setCursor(17,1); lcd.print("No ");}
if(Intruder == true){lcd.setCursor(11,3); lcd.print("Yes");}
else{lcd.setCursor(11,3); lcd.print("No ");}
if(Window == true){lcd.setCursor(17,2); lcd.print("Yes");}
else{lcd.setCursor(17,2); lcd.print("No ");}
if(Door == true){lcd.setCursor(6,2); lcd.print("Yes");}
else{lcd.setCursor(6,2); lcd.print("No ");}
}
Future Scope of Home Security System
- Embedded has taken over the whole world because of its user-friendliness and low cost.
- Instead of hiring security guards(which is quite expensive), now smart homes in modern societies are equipped with such home security systems.
- Modern Home Security systems are even linked with local police or security agencies for emergency help.
- Moreover, these security systems are not bound to homes only, nowadays offices, banks, shopping malls etc. are all equipped with such smart security systems.
Future Work on Home Security System
- Today, we have designed a very simple Home Security System, where we interfaced few sensors and have only placed a Buzzer.
- We will continue this project and will add smart features to it.
- Let's have a look at few features, which we can add to this project:
- We can interface the GSM module to send messages, in case of emergency.
- We can add more sensors i.e. ultrasonic sensors, different types of Gas sensors in it.
- We can also improve our code by using interrupts instead of polling.
- We can also add a camera for facial recognition.
- To improve the security, we can add a keypad and only authorized persons will have the access to enter.
- The fingerprint sensor can also be used for identification purposes.
No matter what happens, you should put safety first. Even a great security system won’t ensure full protection, which is why you might want to consider secondary measures. Hiring fire watch security will assist you on a daily basis, performing tasks that machines cannot. These veterans will protect your home or office, addressing potential hazards as they appear.
So, that was all for today. I hope you guys have enjoyed today's project. If you have any questions/queries, please ask in the comments and I will try my best to resolve them asap. Thanks for reading, take care. Bye :)
Download Proteus Library of Arduino Modules
Hi Friends! Glad to have you on board. In this post today, we’ll cover How to Download Proteus Library of Arduino Modules.
If you are a regular reader of our blog, you must have noticed that we are sharing Proteus Libraries of different embedded sensors & modules on regular basis. Moreover, we have also launched version 2.0 of few libraries. So, today I am going to provide links to download Proteus Library of all Arduino Boards designed by TEP.
So, let's get started with How to Download Proteus Library of Arduino Modules:
Where To Buy? |
---|
No. | Components | Distributor | Link To Buy |
1 | Arduino Mega 2560 | Amazon | Buy Now |
2 | Arduino Nano | Amazon | Buy Now |
3 | Arduino Uno | Amazon | Buy Now |
Download Proteus Library of Arduino Modules V2.0
- It's the most advanced version of Arduino Proteus Library and consists of 6 Arduino Boards in total, named as:
- Arduino UNO
- Arduino Mega 2560
- Arduino Mega 1280
- Arduino Pro Mini
- Arduino Nano
- Arduino Mini
- We have designed 7 Arduino Proteus Libraries V2.0 in total.
- First, we have designed seperate Proteus Libraries of these 6 boards while in the 7th Library, we have combined all these boards.
- So, if you just want to use Arduino UNO, then download its respective Library but if you are working on multiple boards, then download the combined version(7th).
Let's have a look at these Arduino Proteus Libraies one by one:
1. Arduino Uno Library for Proteus V2.0
This Arduino Proteus Library contains only one board named Arduino UNO. You need to download zip file of Proteus library and will be able to simulate Arduino Uno in Proteus software. Proteus Library zip file download link is given below:
Download Arduino UNO Library for Proteus V2.0
2. Arduino Mega 2560 Library for Proteus V2.0
Using this Proteus Library, you can simulate Arduino Mega 2560 in Proteus ISIS. Here's the link to download its zip file:
Download Arduino Mega 2560 Library for Proteus V2.0
3. Arduino Mega 1280 Library for Proteus V2
Here's the link to dowload Proteus Library zip file of Arduino Mega 1280:
Download Arduino Mega 1280 Library for Proteus V2.0
4. Arduino Mini Library for Proteus V2
Here's the link to download Arduino Mini Library for Proteus V2.0:
Download Mini Library for Proteus V2.0
5. Arduino Nano Library for Proteus V2.0
Download this Arduino Nano Library for Proteus(V2.0) and simulate it in Proteus ISIS. Here's the Proteus Library zip file download link:
Download Arduino Nano Library for Proteus V2.0
6. Arduino Pro Mini Library for Proteus V2.0
Check out this
Arduino Pro Mini Library for Proteus(V2). It is similar to the V1 Arduino Pro Mini board but comes in a smaller size.
Download Arduino Nano Library for Proteus V2.0
7. Arduino Library for Proteus V2.0
Arduino Library for Proteus contains all 6 Arduino boards. Simply sownload its zip file and you can use any of these 6 Arduino boards. Here's the link to download zip file of Arduino Proteus Library:
Download Arduino Library for Proteus V2.0
Arduino Library for Proteus V1.0
In this section, we’ll cover Arduino Library for Proteus V1.0. We’ve designed this library for six different types of Arduino boards.
1. Arduino Mega 2560 Library for Proteus V1
Check out this
Arduino Mega 2560 Library for Proteus(V1). Using this library you can simulate Arduino Mega 2560 in the Proteus workspace.
- Arduino Mega 2560 is a powerful and application-type Arduino board, based on the Atmega2560 microcontroller.
- It comes with 16 analog pins and 54 digital I/O pins, including 15 pins for PWM.
2. Arduino Mega 1280 Library for Proteus V1
Read this
Arduino Mega 1280 Library for Proteus(V1). In this library, we’ve discussed how to download the Arduino Mega 1280 library and use it in your Proteus software.
Arduino Mega 1280 is a compact and efficient Arduino board based on the Atmega1280 microcontroller. There are 16 analog and 54 digital I/O pins incorporated on the board. Moreover, it includes a power jack, reset button, ICSP header, and 4 UART serial ports.
3. Arduino Mini Library for Proteus V1
Download
Arduino Mini Library for Proteus(V1). You’ll get to know how to simulate Arduino Mini in Proteus.
Arduino Mini is a small-sized, robust, and powerful Arduino board, based on an Atmega328 microcontroller. It comes with 14 digital I/O pins, of which 6 pins are used for PWM.
4. Arduino Nano Library for Proteus V1
Click this
Arduino Nano Library for Proteus(V1) and simulate Arduino Nano in Proteus software.
Arduino Nano is a small, flexible, and breadboard-friendly Arduino board, based on ATmega328p/Atmega168 microcontroller. It features 8 analog pins, 14 digital I/O pins, 2 reset pins & 6 power pins.
5. Arduino Pro Mini Library for Proteus V1
Check out this
Arduino Pro Mini Library for Proteus(V1). Arduino Pro Mini is a compact, small-sized Arduino board, based on the Atmega328 microcontroller.
It features 8 analog pins, 14 digital I/O pins, of which 6 pins are used as PWM.
6. Arduino Uno Library for Proteus V1
Download
Arduino Uno Library for Proteus(V1) and simulate Arduino Uno in Proteus software. Arduino Uno is a unique, application-type Arduino board, based on the Atmega328 microcontroller.
7. Arduino Library for Proteus V1.0
That’s all for today. Approach me in the section below if you need any help, I’d love to assist you the best way I can. Thank you for reading this post.