Plastic Injection Molding: Reasons To Adopt This Production Method

Plastic injection molding involves exposing plastic pellets to extreme temperatures to melt and become malleable. Afterward, manufacturers inject the melted plastic into a mold cavity so that upon cooling, the plastic adopts a specific shape producing the final product.

The versatility of the process makes plastic injection molding a highly beneficial method of producing plastic parts. It's similar to steel forging, finer grains are molded making the final product much stronger. If you decide to go for the plastic injection molding method of creating plastic parts, you will realize the reliability and simplicity that the technique provides. Here are some of the significant benefits of plastic injection molding to consider:

It is highly efficient

If you are looking for a way to produce plastic parts faster, plastic injection molding is your technique. This method of producing plastic parts offers high production output rates, making the process efficient and cost-effective. Many factors like the complexity and size of the mold will influence the speed at which you produce the final result.

However, cycle times remain tight, with the longest being two minutes, more than enough time to make more significant quantities of mold. Plastic injection molding is the best way to increase your profit margins. All you need to do is to leverage the short period between cycles that offer quick turn injection molding to produce more products for the market.

It can handle complex part designs

One of the things manufacturers seek when looking for a production method is handling complex part design and making precise replicas. The best way to ensure efficacy is to hire qualified designers to develop the right design that will maximize efficiency. Not all plans are immune to processing mistakes.

High-volume injection molding can help optimize efficiency in the process, but you will still need a good design that your machines can produce consistently. If you are a manufacturing manager, take time to learn about the fundamental design elements like wall thickness and rib design to ensure the injection process runs smoothly.

Enhanced strength

Before you begin the plastic injection molding process, you need to understand the flexibility and rigidity that the final product needs. Afterward, you can design a plastic part with appropriate integrating ribs or gussets that will offer the right strength to the final product.

Another essential factor in helping you determine how much strength and stability you need to incorporate into the plastic part is how the customer intends to use the product. It would be wise to carefully select suitable materials for your final product, especially considering its exposure to specific external environments.

Diversity in material and color

One of the most incredible things about plastic injection molding is that manufacturers do not limit themselves to specific materials or colors. Although material and color are critical components influencing plastic parts creation, the possibilities are endless. If you want the best out of your injection molder, choose the one that can handle a wide variety of resin.

Some things to consider when choosing a plastic injection molder are water absorption, impact and tensile strength. Moreover, there are various coloring systems for plastics. Consider each coloring system's unique benefits, properties, and drawbacks before settling on one.

Reduced waste

Manufacturers must comply with a company's green initiative. The production process should accommodate sustainability and safety while still preserving quality. It is not uncommon to generate excess plastic during the production process.

The wise thing to do would be to implement a circular economy model by finding another company, a recycling company, to help manage the excess plastic. Alternatively, manufacturing managers should have effective machinery to minimize waste.

Low labor costs

Plastic injection molding offers high output rates. This advantage, coupled with the high-level production of plastic parts, contributes towards cost savings and effectiveness. Moreover, the entire process usually requires minimal supervision because molding equipment typically has automatic tools that ensure streamlined operations.

The final result of the plastic injection molding process is high-quality plastic parts that enhance customer satisfaction. The low labor costs enable manufacturers to enjoy high-profit margins.

If you are seeking a way to make high-quality plastic parts, purchase computerized and automated plastic injection machinery to enjoy the manufacturing advantages of this production method.

What is the Purpose of FDM 3D Printing?

The usage of 3D printing has received a lot of attention, but what exactly is FDM 3D printing or FFF 3D printing? FDM 3D printing is used in a variety of sectors. Automobiles and a broad range of consumer products makers are among the industries. They use FDM to aid with product design, prototyping, and manufacturing. Some product companies employ FDM 3D printing since the thermoplastic utilized during creation is ideal for children's toys to sports gear.

Gifting

FDM, as previously said, is among the most democratized 3D printing services, enabling hobbyists and amateurs to produce new goods quickly. They can quickly develop, iterate, revise, and print parts that meet their specifications.

The gifting business is also adopting 3D printing technology to make present products, riding the wave of customization. FDM 3D printing technology is ideal for gifting since it provides dimensionally correct, durable, and cost-effective options.

Furthermore, FDM 3D printed parts can be post-processed in various ways, allowing for the creation of visually pleasing goods.

Industrial Applications 

It's a widespread misperception that FDM 3D printing can only be used to make gift items and prototypes. FDM is well-known for producing durable and valuable items that may be put in end-use applications.

Manufacturing 3D printers can generate end-user application components in aerospace, automobiles, production, and healthcare implementations.

Pre-surgery Models

FDM 3D printing innovation has aided many physicians worldwide in better planning surgeries by supplying them with organs that are an identical reproduction of the patient in question. They have a precise structure, may be made hollow or solid depending on the requirements, and can be printed in a matter of hours.

This has enhanced surgical preparation and quality, decreased surgery duration, and even helped patients have a more significant operation encounter.

Prototyping

This is one of the initial examples of FDM printing in action. It is well known that 3D printing was developed to produce prototypes fast, and as a result, 3D printing was dubbed Rapid Prototyping for a long time.

Because FDM printing can manufacture incredibly intricate items, it's an excellent alternative for companies that have to produce parts that must be fit and form checked.

As a result, prototyping remains one of the most common applications of FDM technology. FDM provides a simple, cost-effective, and rapid way to create prototypes.

Architecture 

Architectural prototypes of housing projects, power stations, arenas, and other structures were once created using various materials such as wood, polystyrene, acrylic, and other similar materials. In addition to the considerable production lead time, these were not only more expensive to produce but also more cumbersome to move.

Architectural models may now be quickly manufactured, carried in parts, and assembled on-site thanks to the advent of FDM 3D printing technology. They also have a strong resemblance to the original design.

Conclusion

Because of its ease of use and low cost, this additive manufacturing process is quite prevalent among businesses. Fused deposit modeling is a lifesaver for beginners, aspiring engineers, and bootstrapped firm owners.

How to Find the Right Tech Solution for Your Business?

When is a tech solution the right one? How do you identify the right tech for the problem you are facing? A common problem in many organizations is essentially trying to throw tech at a challenge without fully exploring the parameters of the challenge.

Figuring out what to do can become even more overwhelming when you start asking whether you need a custom-made solution or you can purchase one off the shelf, if you need to simply upgrade a system or if an entire overhaul is necessary, and how much can be done in-house. You can find yourself lost in the details before you have even had a chance to really examine the big picture. However, the good news is that there is still a process you can follow even when the situation is a complex one. Consider the points below as you move forward.

Know the Problem

Do you know what your problem is? Before you say yes, think carefully. It is not uncommon to confuse symptoms with the cause. It may be worthwhile to talk to others within your organization to make sure that you are correctly identifying the issue. If the issue is one that affects your customers, you may want to get some feedback from them.

You might be struggling with meeting compliance standards when it comes to dealing with refrigerated assets. You might assume that the issue is with some of your staff or with how these assets are handled. This could cause you to overlook the fact that reliable refrigeration monitoring systems are what you need. Reefer monitoring solutions are cost-effective, but you might need to dig to the root of your problem to identify them as the answer. Of course, there are a few additional steps you should also go through from examining the impact on employees to choosing the tech solution.

Employee Impact

If your employees are affected by the change you're making and they are resistant to that change, you need to figure out why. It could be because there is something that you are unaware of in their processes that will be negatively affected. It might be because they have higher priority issues that they want you to address or because they have a different perspective on what the solution should be, which is one reason why you should seek feedback widely in the planning stages.

On the other hand, if the change is necessary, you will need to get them on board. This can be tricky because while there may be an overall advantage to the company, their own processes might become more cumbersome in certain ways. You will need to find a way to present the change to them that shows how it can benefit them as well. There is also simply the issue of resistance to change that many people have. In this case, they will eventually adjust, but you may need to provide incentives or find another way to balance the inconvenience of a potentially frustrating learning curve. Letting them be part of the discussion and the process can also help prevent the feeling that a top-down decision is being imposed on them.

Check Your Goal Alignment

Your solution needs to be in alignment with your organization's strategic plan over the next few years and your goals. How does it complement the priorities you have set? This can also help you decide whether the problem is something that needs to be addressed immediately or if there are other issues you should be focusing on more instead.

Sometimes, as in the case of compliance issues around refrigerated assets mentioned above, the issue is not one that can be shelved for a later date, but often teams and individuals can find themselves distracted by shiny new tech that can certainly deliver but which may not aid you in meeting your most important benchmarks in the years ahead. Taking all of this into account can also help you narrow down which solution might be the best since some may be better at aligning with your medium-term aims than others.

Create a Plan

Planning can help you avoid some of the pitfalls described above. Is it true in other areas of life, like preventing your car from theft and putting identification on your pets’ tags in case they run off, planning does not prevent problems, but it can make them more manageable. There should be two aspects to this plan for finding tech solutions for your business.

First, if you develop a kind of blueprint for implementation, you can see how the tech fits into the overall operation, including existing systems and processes. Like a good business plan, this can also highlight gaps in your thinking and anything else you may have overlooked. The other aspect of the plan is articulating criteria that will tell you whether the solution was the right one. This criterion should be as specific and measurable as possible in the same way that a goal should be. In fact, once you have established it, you can use it to work backward and see if what you have chosen is likely to deliver the necessary results.

Choose the Right Solution

When you start to look at the actual tech, there are a number of things you should consider before you make your decision. To start with, look for something that is scalable so that it can grow with your business. You should also look for an effective user interface. Look at how adaptable and customizable it is. Consider as well what kind of balance you want between accessibility and security. It may be important that employees can access a platform from anywhere.

However, you also need to make sure that any important data is protected. Be sure that you consider how much training will be necessary. Even if your employees are enthusiastic about the new tech, if learning how to use it is going to be very costly in terms of time and money, you may want to consider another option. Another thing to look at is how much support you will get with the transition, installation, updates and any troubleshooting. In all of these areas, see what experiences others report as well. You may not be an early adopter, but the advantage of this is that you can be more certain that the tech you have chosen is stable and reliable.

Top 4 Best Fabrics for Table Runners

If you want to decorate your landscape and table for any formal events or holidays, table runners should be the first thing to cross your mind. Table runners are known as the base of your decorations. This is why most house owners prefer table runners instead of other decorating methods. Even though the primary objective of table runners is to protect the table from damages, its effectiveness is much more than that. Table runners will allow you to add style and color to your dining table. It will also help you to increase the overall design and mood of the event.

Table runners are available in various fabric materials such as linen, polyester, cotton, and satin that might make the purchasing process of the table linens a daunting task. No matter if you’re purchasing table runners for the first time or want to replace your old table runners, you should know the variation and availability of fabrics for the table runners. Here are the top 4 fabrics for table runners.

Cotton Table Runners

Cotton is one of the most durable fabrics for table runners. As per Fabrictime, cotton is versatile. Additionally, the maintenance of cotton table runners isn’t complicated. The tight weave of the cotton table runners creates embroidery designs whereas; the material can also be dyed into various colors without compromising your choice. Another great benefit of cotton table runners is that they are highly absorbent. This way you can prevent spillage from damaging the table surface. You can wash them in the machine with bleach or stain treaters that will help you to clean the table runners perfectly.

Polyester Table Runners

Polyester is one type of chemically made fabric that offers similar advantages to cotton. However, the polyester table runners come with a couple of additional perks. Just like cotton table runners, polyester table runners are also durable. They are also machine-washable and available in various designs and colors. Additionally, polyester table runners don’t shrink like cotton yet provide a thinner experience. Polyester table runners are cost-effective. You can use them multiple times without damaging their appearance. This is why polyester table runners are an ideal choice for casual and formal events.

Vinyl Table Runners

If you want to purchase table runners for informal dining, you should consider vinyl as the material for a table runner. The vinyl table runners are highly weather-resistant. If they do get dirty, you can also clean them easily. Vinyl table runners are also waterproof and they protect the surface of the table from air exposure, UV rays, and stain. Vinyl table runners are available in massive color patterns to complement any color scheme. However, they aren’t perfect for luxurious and formal events.

Satin Table Runners

Satin is another alluring example of synthetic fabric. But, the satin table runners are glossier and smoother than the polyester table runners. The fabric provides an eye-catching allure that binds both elegance and glamor perfectly. Apart from that, satin table runners are highly customizable. Despite being durable, satin table runners require tremendous care and maintenance.

Conclusion

These are the top 4 best fabrics for table runners. Table runners are undoubtedly one of the most attractive décor materials. However, make sure you determine the purpose of using the table runners before purchasing them.

Designing Logic Gates in PLC Simulator

Hello friends, I hope you all are doing great. In today's tutorial, we are going to design logic gates in PLC Simulator. It's our 4th tutorial in Ladder Logic Programming Series. We come today to elaborate the logic gates with comprehensive details for their importance in PLC programming. you can consider logic gates as the building blocks of ladder logic programming. Like every time we start with telling what you guys are going to have after completing this session? For those who like to buy their time and calculate for feasibility, I’d like to say by completing this article, you are going to know everything about what types of logic gates, how they are designed and how they work, how you can translate the logic in your head into the logic gate and some about logic calculation which is so-called logic algebra, and for sure the connection with examples between logic gates and the Ladder logic programming. In our previous tutorial, we have Created First Project using Ladder Logic, where we designed a simple logic by using contact and coil. Today, we are going to extend that code and will design different logic gates in ladder logic.

We are discussing these logic gates because they are the main building block of complicated logic. Normally, complex logic is designed using multiple logic gates. So, today, we will simulate the basic logic gates i.e. AND, OR, and NOT, while in the next lecture, we will simulate NAND, NOR, XOR and XNOR in PLC Simulator. So, let's get started:

Logic gates

In very simple language, it is a Boolean decision that has one of only two values either “TRUE” or “FALSE”, not both. For instance, the decision to run or shut down a motor, open or close a valve etc. Well! For deciding such Boolean nature thing, there are two things, inputs and logic to apply on those inputs. On the other way, logic gates apply some sort of logic to the inputs to determine the state of the output.

Truth table

It’s a table that lists all possible combinations of the inputs and the state of the output for each record. For example, a gate with two inputs has four possible combinations of the inputs and four states of the output. inputs.

Basics of logic gate

There are seven basic logic gates. Some of them have only one input while others have two inputs. There are seven basic logic gates which are “AND”, “OR”, “NOT”, “NOR”, “XOR”, “XNOR”, and “NAND”. So let us enjoy a short journey with them having a fast stop at each one’s station. Our trip will include, how they work, design, timing diagram, and connection with ladder logic programming.

Simulating ANR, OR, and NOT logic

  • The AND, OR, and NOT logic are considered the basic building block logic for designing the complicated logic to decide the output status.
  • By using two switches A and B and one output representing lamp or MOTOR, we can design and program these logics and simulate them on the PLCSIM simulator.
  • Table 1 lists the truth table of the three logic AND, OR, and NOT.

Table 1: Truth table of the AND, OR, NOT logic

Switch A Switch B Motor
AND LOGIC
0 0 0
1 0 0
0 1 0
1 1 1
OR LOGIC
0 0 0
0 1 1
1 0 1
1 1 1
NOT LOGIC
Switch Output
0 1
1 0

The “AND” Logic Gate

The “AND” logic gate has two inputs and one output. Like its name, the only condition for having the output become true, is by having both inputs, input A and input B are true. Table 1 lists the truth table of the “AND” gate and Fig. 1 images the symbol of the “AND” gate. In addition, Fig. 2 shows a sample of ladder logic rung that uses “AND” gate logic. It decides the status of the motor based on two switches. The two switches must be in true status for running the motor. ‘to sum up, the logic of the “AND” gate, is that, the output comes to true when and only when both inputs A and B are true.

Table 1: the truth table of “AND” logic gate

Input A Input B Output
False False False
True False False
False True False
True True True

Fig. 1: symbol of “AND” logic gate [1]

In the ladder logic rung shown in Fig. 2, there are two contacts I1 and I2, they are of normally open (NO) type, these two contacts are connected in series, so the only way to set the output to true is that both contacts I1 and I2 must set to true. For full imagination, please notice the timing diagram of the inputs and output signals shown in Fig. 3. It shows the output is only high when both inputs are high.

Fig. 2: sample ladder logic rung for “AND” logic [2]

Fig. 3: The timing diagram of the “AND” logic gate

AND logic in PLC simulator

  • Let us once more enjoy learning further by validating and practicing on the simulator, here you can see in figure 19, on the right the AND logic has been programmed by connecting two switches A and B in series.
  • The motor status is the result of the AND logic between the two switches.
  • On the left, you can see the results of the simulation by setting the status of switches to simulate all truth table conditions and see the motor status changed accordingly.
  • In addition, you can see the truth table of the AND logic on the most right of the figure. So you can review and validate what is going on in the simulator.

Figure 19: Simulating AND logic

The “OR” Logic Gate

This logic gate has two inputs and one output like the “AND” gate. Like its name, the output comes true when either input A or input B comes true as shown in Fig. 4.

Fig. 4: The symbol of “OR” logic gate [1]

Table 2 lists the truth table of the “OR” gate. It lists all possible combinations of inputs and the output status as well. It shows that the output comes to true when input A or input B comes to true.

Table 2: The truth table of the “OR” gate

Input A Input B Output
False False False
True False True
False True True
True True True
 

Figure 5 shows an example of a ladder logic rung that implements the “OR” logic. We can implement this by connecting two inputs I1 and I2 in parallel branches and to the output. like this way of connection, the output can be set to true by simply setting I1 or I2 or both true. Once more, let us see the timing diagram in fig. 6, it is clearly shown that the output goes high as long as either one or both of the inputs are true.

Fig. 5: sample ladder logic rung for “OR” logic [2]

Fig. 6: the timing diagram of the “OR” logic gate

OR logic in PLC Simulator

  • You can see in figure 20, on the right the OR logic has been established and programmed by connecting two switches A and B in parallel.
  • The motor status is the result of the OR logic between the two switches.
  • On the left, you can see the results of the simulation by setting the status of switches to simulate all truth table conditions of the OR logic and see the motor status charged accordingly.
  • In addition, you can see the truth table on the most right of the figure. So you can review and validate what is going on in the simulator.

Figure 20: Simulating OR logic

The “NOT” logic gate

This logic gate has only one input and one output. In a very simple language, the output is the invert logic of the input. So when the input is true, the output would come to false and vise versa as shown in Fig. 7.

Fig. 7: The symbol of the “NOT” logic gate [1]

Table 3 lists the truth table rows of all possible combination of input and output.

Table 3: the truth table of the “NOT” logic gate

Input Output
True False
False True
 

Figure 8 depicts a very simple example of a ladder logic rung that shows the output Q1 is the reverse logic of the input I1. In addition, Fig. 9 shows the timing diagram of input and output of the “NOT” logic gate. It shows clearly that, the output is the reverse of the input.

Fig. 8: Sample of the ladder logic rung representing “NOT” logic [2]

Fig. 9: The timing diagram of the NOT logic gate

Before going further with the logic gates, I want to let you know the good news that, you can implement any logic by using the aforementioned three logic gates “AND”, “OR”, and “NOT”. However, for simplification, the other logic gates are designed based on using these three logic gates in different topologies to perform a specific logic functions.

Not logic in PLC Simulator

  • Also, the NOT logic is one of the primary logic functions, you can see in figure 21, on the right the NOT logic has been designed and programmed by connecting switches A in negative logic in series with the motor.
  • The motor status is the result of the NOT logic of switch A. On the left, you can see the results of the simulation by setting the status of the switch to simulate the two-state of the NOT logic truth table and see the motor status charged accordingly.
  • In addition, you can see the truth table on the most right of the figure. So you can review and validate what is going on in the simulator.

Figure 21: simulating Not logic

Now! I appreciate your follow-up to our PLC tutorial. I am very happy to feel that, by moving further in our plc tutorial our experience is getting increasing bit by bit. However, some questions may come to our mind like does the operator needs to keep pressing input like the push button to keep the motor running? What happens if he released it, does the motor stop? Well! By asking such questions, I can affirm you start your way to master PLC programming and its logic. And let me say the answer to your questions is yes the operator needs to keep pressing the input push-button until the motor has done its task. But that is not the best practice in the real life. There are other techniques to keep the motor running by one touch of the push button, thanks to latching, setting, and resetting techniques as we will show you in the next sections.

Latching output

  • Figure 22 depicts the latching technique that we simply use to keep the motor running by pressing the input push button and having it keep running even after releasing the button.
  • As you can see, I have used the Output as a Virtual Input and placed it in parallel with actual input.
Figure 22: Latching output
  • Table 2 lists the First three scan cycles to show the sequence of operations and how the latching process works when someone will press the Input.
  • In the first scan cycle, when the input gets HIGH, the plc will scan the input "Run (I0.0)" and will find it pressed/ON and thus will make the output "Motor (Q0.0)" HIGH.
  • In the second scan cycle, the input "Run (I0.0)" turned off after being released, but the motor contact is still ON from the previous scan cycle.
  • So, the compiler won't change the status of the OUTPUT and we can say it's latching the output.

Table 2: The first three scan cycles of latching operation

Scan cycle Run (I0.0) Motor status (Q0.0) Motor coil (Q0.0)
1 1 0 1
2 0 1 1
3 0 1 1
  • Now let’s add a way to terminate the latching and stop the motor as per request.
  • Well! Simply figure 23 shows a stop button is added for terminating the latching condition.
  • So in table 2, the RLO for letting the motor running will be unfulfilled by hitting the stop push button in the third scan cycle.
Figure 23: latching with stop button

Simulation of the latching in ladder logic

We may be sure of the logic we wrote for coding the ladder logic of the latching technique. However, at this point how about going to the simulation lab to work out our latch ladder logic program to enjoy validating our ladder code by putting it in the simulator and see how far it match what it is designed for.

Latching Ladder code simulation

  • Now let’s try our latching ladder program in the PLCSIM simulator, by entering our ladder logic and starting the simulator.
  • Figure 24 shows the first four scan cycles. Notice on the left we can set the inputs on and off and see the effects on the right part.
  • In the first scan, every single input and output is at its initial state, so the output is not energized.
  • In the next scan cycle, you can notice we switch on input at I0.0 which is the start push button.
  • Therefore, the motor has been started and running. In the third scan cycle, the start button is switched back off.
  • However, the motor still runs thanks to the latching technique. WOW, we can see our logic is working as we designed for.
  • In the last scan cycle, we tried to test stop latching by hitting the stop pushbutton and indeed it stopped latching and the motor stop running.

Figure 24: simulation result of the first ladder program

We will concentrate on moving forward with ladder coding which is our target. However, we just tried to show you at any time you can validate your ladder at any point to enjoy and confirm you are on the right track as long as you are working on your project.

Latching using set and reset

Let’s use another approach for latching which is based on using set and reset coil. Figure 25 shows the set and reset methods.

  • By hitting set_valve at address I0.2, the valve at Q0.0 will be set ON until a reset command is present by hitting the reset_valve pushbutton at I0.3.
  • It is very easy but you need to take extra care while using set and reset as the last set/reset command will overwrite the previous commands.
  • But wait, what’s if an operator keeps pressing the rest or set button for a long time or if the pushbuttons are the stuck and same thing for the stop button.

Well! The rational expectation is that the motor won’t be able to start. However, the good thing is there is a magic solution to differentiate between the situation of this is a normal stop request by the operator or the button is hold pressed unintentionally or due to an issue with the switches. The one-shot technique can magically recognize the event of pressing or releasing the pushbuttons. Therefore, when it is held for a long time or forever that is only one button press event and for triggering it needs to release and pressed once again. That’s amazing but how does it work? Well! Let’s go demonstrate the concept of how it works, implementation using ladder logic, and give an example to understand it consistently and enjoy the magic of one-shot action.

Figure 25: set and reset for easy latching output

The signal edges

Two edges happened when a pushbutton pressed and released which are falling edge and rising edge as shown in figure 26. It depicts the rising edge when the button is pressed and the falling edge when it has been released. Now, let's move to ladder logic, there are two equivalent rising and falling edge contacts that can be used to tell the PLC this is a one-shot signal. Figure 27 shows how the use of the rising edge of the reset pushbutton |P| at address I0.3. it shows that despite the reset being pressed, its effect in the moment of pressing and then it needs to be released and pressed again to reset the valve at Q0.1. in the next section, let’s get to business and work out one practical example which represents a real problem in the industry just to harvest the fruit of what we have learned so far.

Figure 26: The rising and falling edge [2]

Figure 27: The effects of one-shot technique in ladder logic

So, that was all for today. I hope you have enjoyed today's lecture. In the next tutorial, we will simulate Advance Logic Gates using Ladder Logic Programming. We will design NAND, NOR, XOR and XNOR gates in the next lecture. Thanks for reading.

ESP32 BLE (Bluetooth Low Energy)

Hello readers, I hope you all are having fun in your lives. Welcome to the 2nd Chapter of Section-2 in the ESP32 Programming Series. In today's lesson, we'll go over another built-in feature of the esp32 module that helps it stand out from the competition: BLE or Bluetooth Low Energy.

In the previous tutorial, we discussed the Classic Bluetooth in ESP32, which is considered the predecessor of Bluetooth Low Energy(which we are going to discuss today). We will first look at, what is BLE? and why is it used?, and then will design some examples to utilize the ESP32 BLE in Arduino IDE.

Where To Buy?
No.ComponentsDistributorLink To Buy
1ESP32AmazonBuy Now

What is BLE?

  • There have been numerous adjustments and upgrades to Bluetooth's characteristics since its inception, where Bluetooth 4.0(also called BLE or Bluetooth Smart) is the most influential.
  • BLE or Bluetooth Smart is also known as Wibree. The Wibree protocol was designed by Nokia in 2006 and was later included in Bluetooth 4.0 as Bluetooth Low Energy in December 2009.
  • Bluetooth Low Energy is a slightly different protocol from Classic Bluetooth, which is used in phones, headphones, TVs etc. Rather than continuously streaming data, BLE "servers" can "notify" clients to send the data chunks on a regular basis(which makes it preferable over traditional Bluetooth). As a result, BLE is better suited to low-power IoT applications that don't require significant volumes of data.
  • Both the server and clients now utilize a "service UUID", to determine which server and client needs to be connected. There are various "characteristics" that can be found inside these services.
  • Bluetooth Low Energy was developed and promoted by the Bluetooth Special Interest Group (SIG) for use in healthcare, beacons, fitness, home entertainment etc. It does not work with standard Bluetooth and does not have any compatibility, although it can coexist with BR/EDR and LE.
  • The Bluetooth Special Interest Group (SIG) recognizes several industries for low-energy technology, including smart homes, health, sport, and fitness.

Difference b/w traditional Bluetooth and BLE

Bluetooth Technology was created with the intention of allowing data to be streamed indefinitely. That implies you can send and receive a large amount of data over a short distance with Bluetooth.

  • It's crucial to discuss power usage while discussing the differences between Bluetooth and Bluetooth Low Energy. Bluetooth Low Energy is intended to transfer data only when the client is available to receive the data from the server; otherwise, the BLE device will go into low energy or sleep mode. Thus, use significantly less power as compared to traditional Bluetooth, while retaining a similar communication range.
  • Bluetooth Low Energy uses the same 2.4 GHz radio frequencies as traditional Bluetooth, but a different FHSS (Frequency Hopping Spread Spectrum) technique.
  • Classic Bluetooth uses Scatter-net topology whereas BLE uses Star topology.

Although Bluetooth Low Energy differs from the previous Bluetooth Basic Rate/Enhanced Data Rate protocol, both can be supported by the same device: the Bluetooth 4.0 specification allows devices to implement any or both of the LE and BR/EDR systems.

Because both, Bluetooth Low Energy and traditional Bluetooth use the same 2.4 GHz radio frequencies, allowing dual-mode devices to use a single radio antenna.

How does BLE work?

BLE Client & Server

  • Any BLE device can operate as both a server and a client.
  • Server ESP32 will announce its presence to nearby clients so that clients can establish a connection with the BLE server for communication.
  • Broadcast mode and mesh networks both are also supported by BLE.
  • In broadcast mode, only the BLE server transmits data to all the connected clients.
  • In mesh mode, all the devices are connected to each other.  Therefore, all devices can communicate with all other available devices.

GATT

  • GATT is an acronym for Generic Attributes.

It defines a data structure that is visible to all BLE devices linked to it. GATT defines how BLE devices can communicate with each other. Understanding this structure is crucial to understand the working of BLE.

The GATT protocol includes a set of commands that allow the client to learn more about the server.

  • Read through all of the descriptors for a specific characteristic.
  • Find out everything there is to know about a specific service.
  • Find qualities that match a UUID.
  • Find UUIDs for all major services.
  • Find a service using a UUID.
  • For a particular principal service, locate subsidiary services.

BLE Service

A service is nothing more than a collection of data, such as data from a temperature sensor.

  • A profile, which is made up of multiple services, is at the top of the structure. Typically, a BLE-supported device will have multiple services.
  • The SIG  has preset services for a variety of data kinds, such as battery level, weight, blood pressure, heart rate, and so on.
  • Every service has at least a single feature and can also refer to different services.

BLE Characteristics

The characteristic attribute is always held by a particular service, and it is where the hierarchy's real data is stored.

The characteristic has two attributes:

  • Characteristic value.
  • The characteristic declaration contains the metadata.

It essentially consists of the operations that can be used like Indicate, read, write, notify, broadcast etc.

UUID or Universally Unique Identifier

  • In a Generic Attribute (GATT) profile, the UUID is a universally unique 128-bit or 16-byte integer that is used to identify profiles, services, and data kinds.
Note:
  • In the code description, we will provide a link where you can generate a new UUID.

BLE network topology

BLE uses Star and mesh topology for communication.

A Broadcast Type or a Connection Type communication between two BLE devices is possible. The 'broadcaster' BLE Device sends data to any 'observer' BLE Device in broadcasting. It's a data transfer that only goes one way.

A 'Connection' between the BLE Devices is required for two-way communication. A Central (Master) BLE Device continuously checks for advertising data packets sent by a Peripheral (Slave) BLE Device.

BLE Applications

  • BLE is ideal for applications that need to exchange modest amounts of data on a regular basis.
  • BLE is used extensively in healthcare, fitness, tracking, beacons, security, and home automation etc.
  • Bluetooth Low Energy is natively supported by mobile operating systems such as iOS, Android, and Windows Phone, as well as macOS, Linux, Windows 8 & 10.

ESP32 BLE

  • You can use ESP32 BLE either as a BLE server or a client.
  • Examples are available in the ESP32 BLE library(Arduino IDE) which you can use to implement BLE services.

Note:

  • The Arduino IDE must have the ESP32 board manager file and libraries installed. If you haven't previously prepared your Arduino IDE to operate with the ESP32, then read our previous tutorial, i.e., Introduction to ESP32 Programming Series.

BLE Server Code Description

  • For coding, we are using Arduino IDE’s inbuilt example and will make the required changes in that code only.
  • I will also explain the code in detail for beginners to understand.

In this code, ESP32, BLE will be used as a server.

  • Import the necessary/required libraries for the BLE application.
  • Define a UUID for the Service and Characteristic.

  • To generate UUIDs, go to the following link:

         https://www.uuidgenerator.net/

 
  • You can either use the default UUIDs if you wish to or go to the above link to generate random UUIDs as per your services and attributes.
  • Call back or acknowledge the server whether the client is connected or not

Arduino Setup() Function

  • Serial Communication at a baud rate of 115200.
  • Create a name for your BLE device for identification, we named it Wibree.
  • Set the BLE device as a server.
  • Create a service for the BLE server with the UUID defined earlier.
  • The characteristic for that service is then set. As you can see, you're still using the UUID you created previously, and you'll need to supply the properties of the characters as arguments. It's read and write in this scenario.
  • You can also add other services like battery, indicate, notify etc.
  • The setValue() method can be used to set the value of a characteristic.
  • The above value can be changed to whatever you like. This could be a sensor reading.
  • Finally, activate the service and advertising so that other BLE devices can scan and locate this BLE device.

Arduino Loop() Function

  1. Here we can check if the device is connected to the client or not
  2. If connected then do some tasks like transmitting data or receiving input from the client.

Data Size Per Packet

20 bytes per packet.

Unfortunately, BLE isn't built to handle large amounts of data. The maximum data size per packet in the BLE specification is 20 bytes, so if you wish to communicate more, you'll have to divide it up into many packets. Fortunately, this isn't a challenging task. Simply put, use a delimiter like "!" or "*" or something unique at the end of your whole message to signal the app that the message is done and to start listening for future communications. If you want to send + > 20 bytes cumulatively, for example, you can send and then proceed with the next message if needed.

Testing ESP32 BLE Server

After creating a BLE server using ESP32, we can use a BLE application available on the Play store for testing purposes.

Demonstration with BLE scanner app:

  1. Go to the play store
  2. Search for the BLE scanner and download the app
  3. After installing the app turn on the Bluetooth.
  4. Open the app and search for nearby devices.

  • Now connect to ESP32 BLE  by clicking on the ESP32 device.
  • In our case, we named the device ‘Wibree’.
  • Now you can use the various services provided by BLE like writing and reading data packets, checking battery levels etc. and a lot more.

This concludes the tutorial. I hope you find it helpful.

Create a Web Server with ESP32

Hello readers, I hope you all are doing great. Today, we are going to start the second section of the ESP32 tutorial series and today's our first tutorial, where we will have a look at How to Create a Web Server with ESP32. In our previous tutorial, we introduced you to the basics of the ESP32 microcontroller. where we discuss How to set up Arduino IDE to program ESP32. In this tutorial, we will discuss creating a web server using the ESP32 module.

One of the most interesting features of the ESP microcontroller series is its wireless connectivity via WiFi & Bluetooth. Wireless connectivity protocols supported by ESP32 are:

  • Wi-fi: 802.11b/g/n/e/i
  • Bluetooth : BLE(Bluetooth low energy) and V4.2
Where To Buy?
No.ComponentsDistributorLink To Buy
1ESP32AmazonBuy Now

What is a Web server?

A web server is software or hardware that stores, processes, and delivers web pages to users on request. In other words, it serves users all over the World Wide Web (www). The web server uses the hypertext transfer protocol (HTTP or HTTPS) for communication with the clients(normally, web browsers). We know that HTTP is a set of rules to format and exchange messages.

The following are some important features of a web server:

Features of a Web Server

  • A web server, either physical or virtual, is a computer that hosts one or more websites.
  • The HTTP protocol is the foundation of any data exchange within the network when using the server. So a web server uses it to communicate with the client.
  • The web server uses static content and the files do not change dynamically. Some such files used in a web service are:
    • HTML files
    • Images
    • Stylesheets
    • JavaScript files
  • The web server has multiple settings to avoid unnecessary attacks. This helps to maintain the health and integrity of a website. There are multiple types of web security attacks, such as:
    • DDoS attacks
    • SQL injection
    • Cross-site scripting (XSS)

Hence, a web server has multiple features to serve the users on the web.

Web Server & Client Communication

A client is an entity that initiates communication with the web server and then the server provides the information required. In simple words, the client is a program, device, or user that requests services or resources from the devices, such as the web server. The communication and relationship between these two is called the server-client model. The following are the general server-client model steps that will help to understand the whole scenario:

The client sends an HTTP request to the server. The request includes the URL of the web page that the client wants to retrieve.

  • The client (when the user requires data) sends an HTTP request to the server. This request may include the URL of the web page from which the client wants to retrieve the information.
  • The server receives the request instantly and processes it. It does it when it looks up the URL saved in its database to find the corresponding web page file a client requires.
  • If the web page file is found, the server sends it back to the client in the form of an HTTP response. This response also includes other important types of information, such as the page's content type and expiration date, etc.
  • The client then receives the response and renders the web page on the user's screen. The client uses the content type information to determine how to display the web page.
  • If the page is not found in the URL database, the server shows the error.

Web browsers like Chrome, Firefox, and Safari are examples of clients. 

ESP32 as a Web Server

The ESP32 is a microcontroller famous for its wireless capabilities, which makes it ideal for a large number of fields, especially IoT. We are talking about WiFi connectivity as a web server and here are the key features of this module related to it:

  • The ESP32 is made under the IEEE 802.11b/g/n standards; therefore it has a 2.4 GHz frequency band. Therefore, it can be used as:
    • Common WiFi routers
    • Access point
  • The built-in WiFi capabilities of the ESP32 allow it to be used as a server and carry out the easiest and most effective communication at a distance without any physical connection.
  • It has three operating modes:
    • In station mode, the ESP32 is operated as a WiFi client. It means it can be connected to the existing Wi-Fi network. (We are covering today)
    • In access point mode, it is operated as a WiFi access point; therefore it allows other devices to create a connection with it. (will be covered in the next lecture)
    • In dual mode, it can act as a server and as a client and allow the features of both at the same time. (will be covered in the 3rd lecture of section 2)
  • It has a dual processor that helps in handling multiple tasks at the same time. Therefore, ESP32 is more capable of managing a large network of devices and making it responsive for concurrent connections.
  • It has asynchronous web server libraries, such as “ESPAsyncWebServe” to handle the HTTP requests asynchronously. These are useful because they allow it to effectively manage the connections without blocking the execution of other tasks.
  • ESP32 has multiple security protocols that are used when creating the web server. As a result, it provides secure and protective communication between the devices.
  • It has over-the-air updates, which means it can update the device's firmware without physically accessing it. It helps with remote updates and maintenance.
  • The ESP32 is suitable for use as a server because of its multiple features, including:
    • It can serve static files
    • It can handle different HTTP methods (GET, POST, etc.)
    • It supports features like server-side scripting
  • The WebSockets feature of ESP32 allows it to carry out bi-directional communication between servers and clients. You will learn about both of these in just a bit.
  • The ESP32 supports WiFi Direct, which is also referred to as the Peer to Peer (P2P); therefore, it can form a direct connection with other devices with no need for an external WiFi network.

ESP32 WebServer Working Principle

We know that the ESP32 has a built-in WiFi feature. This makes it suitable to use as a server. The example of the server-client relationship we have just discussed shows the internet connection of the whole world. The ESP32 can be used for the intranet connection, which is defined as:

"An intranet is a private network that has limited functionalities and is only accessible to users within a specific organization/location."

Usually, this network may consist of different devices, such as mobile phones, computers, laptops and tablets. The Arduino IDE is for the programming of the ESP32, just like we have done in the previous session. If your Arduino IDE is ready with the boards and ports, then let us try the built-in example of the ESP32 to use as a server. 

What is an SSID?

  • An SSID is a service set identifier that is the unique name of a wireless local area network (WLAN).
  • It can be 32 characters long.
  • It may include numbers, letters, and signs.
  • The SSID can be set by the user as well.
  • In simple words, the SSID is the name of the WiFi connection people use for their connection.

In the experiment we are just performing, the user has to replace the SSID with their own SSID to connect with the ESP32.

Using the ESP32 Server Built-in Example

Using the ESP32 as a server is easy with the web server example. It has the basics, and here are the steps to follow:

  • Open the Arduino IDE.
  • Connect the esp32 to your system through the cable. Make sure the ESP32 is connected accurately.
  • Click on tools>boards>ESP32>Node32s. This is my board and you can choose according to the model of ESP32.
  • Go to the files> examples>examples of Nose32s>WiFi and from the side menu, choose “SimpleWifiServer".
  • It will create a new project with the code in it to run the ESP32 (connected to your system) as a server.
  • Press the encoder (EN) button of the ESP32.
  • Change the SSID and password according to your choice. In my case, it is PTCL-BB.
  • Go to lines 38, 103, and 106 by one and replace the pin “5” digit with pin “2” because the built-in light is at pin 2.
  • Replace lines 70 and 71 with the following:

client.print("Click <a href=\"/H\">here</a> to turn the LED on pin 2 on.<br>");

client.print("Click <a href=\"/L\">here</a> to turn turn the LED on pin 2 off.<br>");

  • All the instructions are given in the code. Go to line 30 and place your SSID there.
  • Go to line 31 and enter the password of your choice.
  • Read the code carefully and hit the “verify” button.
  • Once the code is compiled, press "Boot" on the ESP32 when the uploading process is carried out.
  • Wait for the loading to complete.
  • Click on the “Serial Monitor” button at the upper right corner of the screen to open the monitor. You can go to Tool>Serial Monitor for the same task.
  • Choose the baud rate of 115200 from the drop-down menu at the right corner of the monitor.
  • Right now, the monitor is blank:
  • Click the EN button on the EPS32 to see the information.
  • Now that the monitor has data and is loading, it starts to connect with the WiFi connection of the system.
  • Once the loading is complete, it will provide the IP address. Copy this address.
  • Go to the new tab in the browser and paste the address there.
  • You will see that merely placing the “H” or “L” just after the IP address (as given in the code comment) will turn on and off the LED on ESP32 according to the URL.

Note: Make sure you have installed the port and board before you try this code and have selected all the right options; otherwise, you can face errors. 

ESP32 Server as Messenger

  • The ESP32 can be used to send the message through the browser.
  • The microcontroller connects to the internet connection of the system.
  • The serial monitor shows the IP address.
  • The ESP32 acts as a server and through the URL of the browser, the user will send the message to the Arduino IDE.
  • This message will be shown on the serial monitor.
  • The user can change the message through the URL pasted in the web browser.

Material Required

  • Internet connection
  • System (e,g, laptop)
  • ESP32 microcontroller
  • Connecting cable

Code for ESP32 as Server

#include <WiFi.h>

const char *ssid = "My-SSID";

const char *password = "My-Password";

WiFiServer server(80);

void setup() {

  Serial.begin(115200);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {

    delay(1000);

    Serial.println("Connecting to WiFi...");

  }

  Serial.println("Connected to WiFi");

  Serial.println("IP address: ");

  Serial.println(WiFi.localIP());

  server.begin();

}

void loop() {

  WiFiClient client = server.available();

  if (client) {

    Serial.println("New Client.");

    while (client.connected()) {

      if (client.available()) {

        String request = client.readStringUntil('\r');

        client.flush();

        // Check if the request contains a specific message

        if (request.indexOf("GET /message") != -1) {

          int startPos = request.indexOf("message=") + 8;

          int endPos = request.indexOf("HTTP/1.1") - 1;

          String message = request.substring(startPos, endPos);

          Serial.println("Received message: " + message);

          // Send a proper HTTP response

          client.println("HTTP/1.1 200 OK");

          client.println("Content-type: text/plain");

          client.println("Connection: close");

          client.println();

          client.print("Message received!");

          // Close the connection

          client.stop();

          Serial.println("Client disconnected.");

          break;

        }

      }

    }

  }

}

Procedure

  • Connect the ESP32 to the system using the cable.
  • Open the Arduino IDE.
  • Create a new project and remove the current code.
  • Make sure you have the respective port and board installed successfully.
  • Connect the right port and board.
  • Paste the code given above into the new project.
  • "Verify" the code by using the button.
  • Once verified, compile and upload the code.
  • Once the code is compiled, press the Boot button.
  • Once the installation is completed, go to the serial monitor.
  • Press the EN button.
  • The serial monitor will show the information. Copy the IP address shown on the end of loading.
  • The general ULR for sending the message through the server is given as: http://esp32-ip-address/message?message=Hello
  • To send the “Hello” message to the ESP32 through the browser, use your IP address and the message. In my case, I am pasting the following URL in the browser: http://192.168.43.251/message?message=Hello
  • Once reloaded, go to the serial monitor and check for the message:
  • You can change the message through the URL.

http://192.168.43.251/message?message=I_am_using_The_Engineering_Projects

  • This will create the following output:

How ESP32 WebServer works with hardware?

  • For the demonstration purpose, we will create a webpage and will launch it through our ESP32 module, so ESP32 will be acting as a web server, serving the page.
  • This webpage will have 3 Buttons on it, which will be controlling three LEDs, we will turn ON or OFF respective LEDs using these buttons.
  • WebServer Page is shown in the below figure:
  • Now the question arises, how will ESP32 understand which Button has been pressed?
  • For that, we have created multiple links i.e. the HomePage Url will look like:

http://192.168.43.188/

  • When a user will click on LED 26 ON Button, we will redirect the user to:

http://192.168.43.188/26/on

  • Now, when the client wants to turn OFF the LED, we will redirect to:

http://192.168.43.188/26/off

  • So, actually, we are checking the request from the client and based on that request we are turning ON or OFF the respective LED.
  • Moreover, we are providing the same webpage to all the links but with the change in the state of each button i.e. if it's ON then Blue, otherwise Green.

If it looks too complicated, don't worry. These things will get more clear when we will cover the Arduino coding.

Note:

ESP32 server Modes:

ESP32 Wi-Fi module includes a number of useful characteristics, including the ability to use a soft access point mode, a station mode, or both modes at the same time. Only station mode will be discussed in this session. I'll also cover how to use this board in soft access mode in future tutorials.

  1. Station Mode: The ESP32 board connects to your Wi-Fi network via a router in Station mode. The router serves as the communication channel between the web client and the ESP32. The IP address is obtained from the Wi-Fi router. Web clients can connect to the Web server using this IP address across a local network.
  2. Access Point Mode: In this mode, the ESP32 creates its own wireless Wi-Fi network, similar to the one provided by your existing router. We don't need to connect the ESP2 to a Wi-Fi network in this mode. This Wi-Fi board can link up to 5 devices to the Wifi network it creates.
Controlling peripherals Using ESP32 Web Server

Connect the peripherals to the ESP32 board which you want to control through the ESP32 Web Server.

Here, we are going to control two external LEDs connected to LED1 (GPIO 26), LED2 (GPIO 27), and an inbuilt LED.

The following are the requirements for creating an ESP32 webserver to control peripherals:
  • ESP32 module
  • Internet connection
  • LEDs
  • Resistors
  • Connecting Wires

Arduino IDE Code

  • Using the Arduino IDE, upload the following code to the ESP32 module:
#include // Replace with your network credentials char* ssid = "ESP32"; //enter SSID char* passphrase = "asdfgf@123"; // enter the password // Set web server port number to 80 WiFiServer server(80); // Variable to store the HTTP request String header; // Auxiliar variables to store the current output state String output26State = "off"; String output27State = "off"; String builtin_led_state = "off"; // Assign output variables to GPIO pins const int output26 = 26; const int output27 = 27; // Current time unsigned long currentTime = millis(); // Previous time unsigned long previousTime = 0; // Define timeout time in milliseconds (example: 2000ms = 2s) const long timeoutTime = 2000; void setup() { Serial.begin(115200); // Initialize the output variables as outputs pinMode(output26, OUTPUT); pinMode(output27, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); // Set outputs to LOW digitalWrite(output26, LOW); digitalWrite(output27, LOW); digitalWrite(LED_BUILTIN, LOW); // Connect to Wi-Fi network with SSID and password Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, passphrase); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } // Print local IP address and start web server Serial.println(""); Serial.println("WiFi connected."); Serial.println("IP address: "); Serial.println(WiFi.localIP()); server.begin(); } void loop(){ WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, currentTime = millis(); previousTime = currentTime; Serial.println("New Client."); // print a message out in the serial port String currentLine = ""; // make a String to hold incoming data from the client while (client.connected() && currentTime - previousTime <= timeoutTime) { // loop while the client's connected currentTime = millis(); if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor header += c; if (c == '\n') { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println("Connection: close"); client.println(); // turns the GPIOs on and off if (header.indexOf("GET /26/on") >= 0) { Serial.println("GPIO 26 on"); output26State = "on"; digitalWrite(output26, HIGH); } else if (header.indexOf("GET /26/off") >= 0) { Serial.println("GPIO 26 off"); output26State = "off"; digitalWrite(output26, LOW); } else if (header.indexOf("GET /27/on") >= 0) { Serial.println("GPIO 27 on"); output27State = "on"; digitalWrite(output27, HIGH); } else if (header.indexOf("GET /27/off") >= 0) { Serial.println("GPIO 27 off"); output27State = "off"; digitalWrite(output27, LOW); } else if (header.indexOf("GET /LED_BUILTIN/on") >= 0) { Serial.println("BUILTIN LED on"); builtin_led_state = "on"; digitalWrite(LED_BUILTIN, HIGH); } else if (header.indexOf("GET /LED_BUILTIN/off") >= 0) { Serial.println("BUILTIN_LED off"); builtin_led_state = "off"; digitalWrite(LED_BUILTIN, LOW); } // Display the HTML web page client.println(""); client.println(""); client.println(""); // CSS to style the on/off buttons // Feel free to change the background-color and font-size attributes to fit your preferences client.println(""); // Web Page Heading client.println("

ESP32 Web Server

"); // Display current state, and ON/OFF buttons for builtin led client.println("

LED_BUILTIN - State " + builtin_led_state + "

"); // If the LED is off, it displays the ON button if (builtin_led_state=="off") { client.println("

"); } else { client.println("

"); } // Display current state, and ON/OFF buttons for GPIO 26 client.println("

LED_1 - State " + output26State + "

"); // If the output26State is off, it displays the ON button if (output26State=="off") { client.println("

"); } else { client.println("

"); } // Display current state, and ON/OFF buttons for GPIO 27 client.println("

LED_2 - State " + output27State + "

"); // If the output27State is off, it displays the ON button if (output27State=="off") { client.println("

"); } else { client.println("

"); } client.println(""); // The HTTP response ends with another blank line client.println(); // Break out of the while loop break; } else { // if you got a newline, then clear currentLine currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } } } // Clear the header variable header = ""; // Close the connection client.stop(); Serial.println("Client disconnected."); Serial.println(""); } }
Note:
  • You need to modify the SSID and password with your network credentials.

Code Description:

Here, we'll take a closer look at the code to see how it works.

  • The first task is to add a Wi-Fi library.
  • As mentioned previously, you must type your SSID and password inside the double quotes in the following lines.
  • As we are creating a web server, so we need to assign a port to it and normally we use port 80 for a local webserver.
  • So, in the below code, Port 80 is assigned to the webserver and then initialized a few variables:
  1. String header: variable to store the header of the HTTP request.
  2. Below the header variable, we have variables to store the current state of connected peripheral LEDs and built-in LED. If you wish to add more peripherals and save their states, you need to create more variables. By default, all LEDs are in the OFF state.
  3. Next, assigned GPIOs to each peripheral device or component. Here we are using GPIO 26(LED1) and GPIO 27(LED2). You can use any other suitable GPIOs.
  4. Lastly, we have initialized a few variables to check the connection timeout, we will check their working soon.

Arduino Setup() Function

  • Now let's first have a look at the Arduino setup loop.
  • First, we have initialized our Serial Port at a baud rate of 115200, so that we could monitor the results at the serial terminal.
  • Define the GPIOs as OUTPUTs and set them to LOW, as by default LEDs will be off.
  • To set up a wifi connection, we called the WiFI.begin() and here we have provided our SSID and passphrase as variables.
  • Now our ESP32 will try to connect to the provided WiFi connection.
  • As you can see, we have a while loop, where we are checking the WiFi Status.
  • If ESP32 gets connected with WiFi, the while loop will break and a message will get printed on the Serial Monitor "WiFi Connected".
  • Now our ESP32 is connected to the WiFi, so the router must have assigned an IP address to ESP32 and we are printing it on Serial using WiFi local IP Function.
  • Finally, we begin our server, to which we have assigned Port 80 at the start.

Arduino Loop() Function

Now, we are done with all the basic settings in the setup function. Let's have a look at the code in the Loop function:

  • At the last line of the Setup function, we have started our webserver, so now ESP32 is acting as a webserver and is waiting for incoming clients.
  • But what will happen, when someone will hit the IP Address of this webserver?
  • So, in the loop function, first of all, we are listening to the incoming client using the server.available() function.
  • If any client is available i.e. someone has entered our IP Address in the browser then we will print the HTML page.
  • So, we are going to write the rest of our code in this IF loop.
  • AS you can see in the below code, if the client is available, we have printed "New Client" on Serial Monitor.
  • After that, we have a while loop checking for client connection, so as long as we have a connection with the client, we will remain in this loop.
  • Inside this while loop, we have an If loop, checking if the client is available.
  • Now, if we are connected to the client, we need to read for the incoming request.
  • So, If there are any bytes to read from the client, read those bytes:
  • The client request ends at New Line Character \n, so we are checking for that.
  • Once we received the New Line Character, we are sending the response back to the Client.
  • In response, we have first sent the HTTP header, which is the default for webpages so that browsers should understand the response type.

Checking Request Type

  • As we discussed earlier, on each button press, we are redirecting our client to its respective link.
  • Depending on which button is pushed, we make requests to different URLs to turn the LEDs on and off using if else statements, as shown below:
   
  • As you can see in the above code, we are repeating the same code three times for 3 LEDs.
  • In the first block, we are simply checking the header response and if it's a GET request and from "/26/on", we have turned that Pin HIGH, changed the LED state variable to "on" and sent a message on the serial monitor.
  • So, if a client clicks on the LED 26 ON button, ESP32 will understand the GET request and glow the LED.
  • The other buttons work in the same way. If you wish to add more outputs, you'll need to change this section of the code.

 HTML to display a web page

  • We have designed the output part i.e. what we are going to do when a user clicks any button.
  • And now we are going to design those buttons themselves i.e. we are designing the webpage.
  • As you can see in the below figure, we have standard HTML tags at the start.
  • After that, we have some CSS text to design the buttons and the appearance of the web page. We use the Helvetica font and set the information to be shown as a block with the center aligned.
  • Next, displaying Web page heading i.e. "ESP32 Web Server".
  • Next, comes the If Loop for the first Button, we are checking the LED state variable and based on LED state, we are displaying our Button.
  • So, if the LED state is OFF, we are redirecting the user to /LED_BUILTIN/on and vice versa.
  • That's how we are changing the Buttons on the webpage, as you can see buttons are using different CSS classes for on and off states.
  • Similar loops are used to display the states on other connected LEDs.
  • Finally, we are closing the web connection and clearing the header that was used to store the HTTP request header using client.stop() function.
  • Printing information about the closed web connection on the serial monitor.

Uploading Web Server Code to ESP32

  • Please reread the previous instruction, "Introduction to ESP32 programming series," if you are unfamiliar with the procedure of uploading code in the Arduino IDE.
  • After uploading the code, open the Serial Monitor with a baud rate of 115200.
  • Enable the ESP32 by pressing the EN (enable) button. The ESP32 establishes a Wi-Fi connection and the Serial Monitor displays the ESP32 IP address. To connect to the ESP32 web server, you'll need that IP address.
Note:
  • Make sure you have selected the right board and COM port.

Getting IP address and Access ESP32 web Server

  • After successfully uploading the code in esp32 module.
  • Open Serial Monitor from the top right corner of Arduino IDE screen as shown in figure below:
  • The IP address required to connect to the ESP32 point will be displayed on the Serial Monitor. It's 192.168.43.223 in this scenario.
 
  • To access the webserver, type the IP Address of the ESP32 into a Web Browser on a laptop or a mobile phone. It's 192.168.43.223 in our case.
  • You should be able to see a simple web page served by the ESP32's Web Server if everything goes well.

A screenshot of a Web Browser on a laptop accessing the ESP32 Web Server is shown below.

  • The image below is displaying the ON state of the inbuilt LED.
  • The inbuilt LED is Blue in color.
  • The below image is displaying the OFF State of the inbuilt LED

Hence, We have done a lot of work on the ESP32 by using it as a server. In the beginning, we saw what is a web server and studied its features in detail. After that, we saw that ESP32 can be used as a server and we saw the feature that makes it ideal for this task. Then we experimented to learn the concept, in which we saw the built-in example of ESP32 as a server in Arduino IDE. We saw the step-by-step procedure to experiment and once it was completed, we moved on to a more complex example. I hope you find this tutorial useful and have performed it by yourself but if you are stuck at any point, you can ask in the comment section.

Using the ESP32 web server and the preceding process, you can control the peripherals linked to the ESP32 module from any mobile, tablet, or computer. The only need is that all of the devices to be linked to the same network.

This concludes the lesson. I hope it becomes useful to you. In the next tutorial, we will have a look at How to work the ESP32 BLE, so stay tuned. Have a good day. :)

Automatic Plant Watering System using Arduino

Hello friends, I hope you all are doing great. In today's tutorial, we are going to design a Proteus Simulation for Automatic Plant Watering System using Arduino. We have designed this project for engineering students as it's a common semester project, especially in electrical, electronics and mechatronics engineering.

The two most significant hazards to the agriculture industry are the need for extensive labor and a scarcity of water. According to the World Wildlife Fund (WWF) organization, water shortages might affect two-thirds of the world's population by 2025, putting both the ecosystem and human health at risk. The use of automatic plant watering systems eliminates both of these problems by watering plants at specified times and amounts while monitoring their hydration levels through measuring moisture in the soil surrounding the plants. Automatic plant watering systems can be used in homemade gardens and can also be deployed in fields for large-scale use. Whenever designing an automatic watering system, it is important to keep in mind that the system should be expandable, allowing for the simple integration of new devices in order to broaden the applicability of the system.

Where To Buy?
No.ComponentsDistributorLink To Buy
1BuzzerAmazonBuy Now
2LEDsAmazonBuy Now
3DS1307AmazonBuy Now
4LCD 20x4AmazonBuy Now
5Arduino UnoAmazonBuy Now

Software to Install

We are not designing this project using real components, instead, we are going to design its Proteus simulation. So, first of all, you should Install Proteus Software itself. Proteus software has a big database of electronics components but it doesn't have modules in it. So, we need to install Proteus Libraries of a few components, so that we could simulate them. So, these are the PRoteus libraries which you should install first, before working on this project: You can download this complete project i.e. Proteus Simulation & Arduino Code, by clicking the below button: Download Complete Project Note: You should also have a look at these other Proteus Libraries:

Project Overview:

Three main components of an autonomous watering system are:

  • Water Level Sensor: monitors the water reservoir level.
  • Moisture Sensor: monitors the soil moisture level.
  • RTC module: responsible for supplying water to the plant at predetermined intervals or at a predetermined time.
  • Arduino UNO: serves as a hub for connecting and controlling all these components.

It is necessary to integrate the water level sensor with the microcontroller before it can be installed within the water reservoir. The location of the water level sensor within the reservoir is variable and is determined by the user and the application for which it is being utilized. The Arduino receives continuous data from the water level sensor and warns the user when the water goes below a certain level, either by an alarm or a buzzer, as appropriate.

The soil moisture sensor operates in a manner similar to that of the water level sensor. The tip of the sensor is inserted into the soil near the plant, and the sensor is activated. In the case of a moisture sensor, the closeness of the sensor to the plant is also variable, and the user may adjust it depending on the features of the plant for which it is being used. In vast agricultural fields, a single sensor may be used for numerous plants if they are closely spaced and their hydration levels can be determined by measuring the soil moisture at one location that overlaps with another spot on the soil surface.

The RTC module operates on the same concept of time monitoring in the background as other electronic devices such as computers and smartphones; even when these devices appear to be turned off, they continue to keep track of the current time. The RTC module, on the other hand, is capable of exchanging time information with the Arduino board. On a specific day of the week, at a specific time of day, the Arduino is pre-programmed to turn on the water pump and turn off the water pump after a specified length of time.

Components Needed:

  1. Arduino UNO
  2. Water Level Sensor
  3. Moisture Sensor
  4. RTC Module (DS1307)
  5. LCD
  6. 4 LEDs
  7. Buzzer
  8. Relay
  9. Water Pump
  10. PCF8574

Component Details:

Arduino UNO:

  • Arduino UNO is a programmable microcontroller board.
  • It contains Atmel's ATMega328 as is based on that microcontroller.
  • The Arduino board also contains an in-built voltage regulator to protect it from burning out and supports serial communication to help programmers.
  • The Arduino board is culturally programmed through the Arduino App designed by the board's developers and the programming is done in C language.
  • The Arduino App compiles code and interfaces the firmware into the Arduino hardware.
  • Arduino UNO has 14 digital I/O pins out of which 6 are PWM pins as well.
  • Arduino also takes analog inputs and has 6 analog input pins.

Figure # 1: Arduino UNO

Soil Moisture Sensor:

  • The soil moisture sensor is a resistive sensor that consists of two electrodes with a small charge and the resistance in those electrodes is measured and then the resistance in between the soil is used to find the moisture levels.
  • A soil moisture sensor normally comes equipped with an amplifier such as LM393. It has a VCC, GND and analog output pin.

Figure # 2: Soil Moisture Sensor

Water Level Sensor:

  • The water level sensor is a module that helps calculate the amount of liquid in a container.
  • When a liquid is present in the tank, the Submersible level sensor detects the hydrostatic pressure generated by the liquid.
  • Since hydrostatic pressure is a measure of two variables, the first of which is the density of the fluid and the second of which is the height of the fluid, it is a useful tool.

Figure # 3: Water Level Sensor

RTC Module:

  • RTC stands for real Time Clock and as the name suggests the module keeps track of time even when the external power supply is cut off.
  • It has a battery cell installed within it for that purpose, moreover, it is capable of communication with other devices such as Arduino too.

Figure # 4: RTC Module

Relay:

  • Relays are basically electrical or electromechanical switches that operate on the principle of magnetic field controlling the switching within the relay.
  • A relay has two modes of operation, normally open and normally closed.

Figure # 5: 12V Relay

PCF8574:

  • The PCF8574 is a silicon-based CMOS integrated circuit.
  • Using the two-line bidirectional bus enables general-purpose remote I/O extension for the majority of microcontroller families (I2C).
  • It is used in our project for I2C communication of LCD.

Figure # 6: PCF 8574

 

Proteus Simulation of Plant Watering System

Now, let's design the Proteus Simulation of Plant Watering System first and then will work on the Arduino Code.
  • First of all, make sure that Proteus is installed on your computer and download all the necessary libraries for Proteus beforehand.
  • For this project, you will need libraries for Arduino, LCD, RTC Module, Water Level Sensor and Soil Moisture Sensor. Make sure that you read how to use each library in Proteus as well.
  • Open a new project on Proteus, import all the components required and place them within the working area or the blue line of Proteus.
  • Select below components from Proteus Components' library:

Circuit Diagram and Working:

  • Now, place these components in your Proteus workspace, as shown in the below figure:
  • For the water level and moisture sensor, place a variable POT(potentiometer) at the test pin and place an RC filter at the output pins. (This is only for simulation purposes)
  • Start with the input side of Arduino and connect the soil moisture, water level output pins to the A1 and A0 pins of Arduino respectively.
  • To use the LCD for I2C communication, Place PCF8574 and connect with LCD.
  • Connect the SDA and SCL pins of PCF8574 and the SDA and SCL pins of the RTC module with the SDA and SCL pins of Arduino.
  • For the output side of Arduino, Connect the D7 to the relay controlling the pump.
  • Connect the buzzer at D2 and the LEDs to their respective Arduino pins as well.
  • Make sure appropriate power and ground are provided to each component. With that the making of the circuit on Proteus is complete.

Figure 7 shows the circuit diagram of the system. Proteus was used to simulate the circuit and Arduino App was used for the simulation of the Arduino code. The circuit was designed in a way that is easy to understand and further integrated easily. We will now go through a step-by-step guide on how the circuit was built.

Figure # 7: Proteus Circuit diagram

Arduino Code for Plant Watering System

A normal Arduino code has two main segments:

  • void setup
  • void loop
We will look at both of them separately here.

Declaration Code

  • The first step in setting up our code is defining libraries, download if you don’t have any libraries already integrated in the Arduino App.

Figure # 12: Arduino Code

  • The next step in the code is tone definition for buzzer and pin definition of variables being used in the project.

Figure # 13: Arduino Code

  • After pin definition, the variables used must be defined so that Arduino knows where to find them and how to identify them.

Figure # 14: Arduino Code

  • The next step is defining the system messages that will appear on the LCD.
  • It is not necessary to define those messages in the setup, they can be easily defined within the main code but it is an easier way to define those beforehand and call them whenever needed.
  • This is especially useful when a system message is used multiple times in the code.

Figure # 15: Arduino Code

  • Now we define the objects being used in the project.
  • The two objects being defined are the RTC module and LCD. In the syntax below we used 20x0 in the argument for the LCD, that is because there are no libraries for I2C LCDs and we had to turn a simple LCD into an I2C LCD by the means of PCF8574.

Figure # 16: Arduino Code

Void setup:

Now we start the programming of void setup.
  • At first is the initialization of various components, such as initializing the RTC module and setting the time and date of RTC with respect to our computer.
  • Wire initialization and library are used for I2C communication.

Figure # 17: Arduino Code

  • The next step is defining the digital pins of Arduino being used as input or output pins and displaying the initial message on our LCD.

Figure # 18: Arduino Code

 

Void Loop:

  • The first step in the loop is to read the date and time from the computer through the RTC and read the values from the sensor.
  • Since this part of the program runs in the loop, Arduino will keep reading and refreshing the sensor inputs every time the loop starts.

Figure # 19: Arduino Code

  • In the next segment of the code, we will check various conditions of the sensor values and RTC and actuate our outputs on the basis of these conditions.
  • At first, we check the water level of the container, if it is below the set level, Arduino will actuate the buzzer to alarm the user of low tank on LCD.

Figure # 20: Arduino Code

  • In the next step, we check the values of the moisture sensor and place the conditions in three categories, namely, moist soil, soggy soil and dry soil.
  • The Arduino will light up the respective LED whenever its condition is true. Red LED for dry soil, yellow LED for soggy soil and green LED for moist soil.
  • The LCD will also display respective messages for each of those conditions.
  • The following code is for the condition of dry soil.

Figure # 21: Arduino Code

  • The following code is for the condition of moist soil.

Figure # 22: Arduino Code

  • And finally the code for the condition of soggy soil.

Figure # 23: Arduino Code

  • In the next step of the code, we check the condition of time, whether it is time to water the plants or not and the condition of the water reservoir to see its level as well.

Figure # 24: Arduino Code

If you see the code closely, you may see the function of the right hour, which is called various times in the main code. The function code in itself is written at the bottom of the main code. This function is used for displaying the time and date on the LCD and also for fixing the date and time.

Results/Working

  1. Open Arduino and generate a hex file for that program.
  2. Put the hex file in the Arduino UNO board placed in Proteus.
  3. Run the simulation.

Figure # 8: Proteus circuit simulation when soil is soggy

Figure # 9: Proteus circuit simulation when soil is moist

Figure # 10: Proteus circuit simulation when soil is dry

Figure # 11: Proteus circuit simulation when soil is dry and it is time to water the plant

As you can see from figure 8 that our simulation is running according to the program set at Arduino. You can increase or decrease the values coming from the sensors through the Potentiometer. So, that was all for today. I hope you have enjoyed today's lecture. If you have any questions, please ask in the comments. Thanks for reading.

Databases and CRUD operations in C#

Are you here to learn about Databases and CRUD operations in the C# programming language? If so, then you will be an expert in no time. Learning Databases and CRUD operations in C# is not a piece of cake. But, if you know all the terms and steps of CRUD operations and databases in C#, it will not be rocket science for you. This article contains all the information you should know regarding databases and CRUD operations. So, keep reading till the end!

C# Programming Language: An Overview 

We know that you are already aware of the C# programming language. So, here is a quick overview of the C# programming language before we move to the actual topic:

C#, also known as C-Sharp, is an object-intended coding language that operates on the .NET Platform and is developed by Microsoft. ISO and ECMA have certified the C# programming language. C# is a broad programming language that can help accomplish hundreds of activities and purposes in different fields. It resembles Java, C++, and other programming languages but, it is truly one of a kind. The best thing is that it is object-oriented and is easy to use. It has an infinite list of advantages.

Some of the advantages of the C# are listed below:

  • C# programming language offers automated garbage pickup.
  • In C# programs, classes may be specified within domains.
  • No obligation to add the “.h” extension within header folders.
  • Because non-Boolean values are not utilized as conditionals, the scripts are less vulnerable to errors.
  • Multithreading is genuinely uncomplicated in C# as compared to other programming languages like C++ or Java.
  • All parameters in the C# are immediately set to their standard settings before being utilized.
  • C# offers reflection skills, which means it can look at and change its composition at execution.
  • With the help of the C# programming languages, many apps and programs have been built like KeePass, Banshee, Paint.NET, FlashDevelop, and many others. In fact, the application where I am writing this article is also an application of the C# programming language (Microsoft Word).

All the above advantages make the C# programming language stand out in other languages. It is undoubtedly the most contemporary and exceptional language out there!

What is a Database In C#?

Before we begin learning about CRUD operations in a database within the C# programming language, it is crucial to know what a Database is.

A database is basically a coordinated set of formatted data kept digitally within a computer network. A database administration tool is generally in charge of a dataset. The DBMS, the dataset, and the programs that interact with these are collectively called a database platform. Every database operation can access a single relational database. It is generated as an inclusion within the data catalog by the data proprietor (usually a database manager with authority for that collection), who gives it a title and a specification. Several databases utilize structured query language (SQL) when generating and accessing data.

What is CRUD?

Here is the most awaited section of the entire article: CRUD operations. Please grab a notebook to note every detail for your better understanding. And if you do not wish to write these, you can always read our article from the website. Let us begin:

The abbreviation CRUD refers to Create, Read, Update, and Delete in software coding. Permanent memory has these four primary functions. Additionally, every letter of the abbreviation may relate to every functionality within a relational network program that is linked to a standard HTTP service, SQL declaration, or DDS action.

It may also apply to consumer-interface standards that let users browse, explore, and alter data using computer-based documentation. Objects are viewed, produced, modified, and removed in this way. Furthermore, CRUD is data-driven, and HTTP operation verbs are regulated.

Standard CRUD Operations In C#

The CRUD feature is present in almost all programs. CRUD is something that every coder has to use at some stage. In the C# programming language, CRUD operations in the database are quite crucial to learn because they are a fundamental component of programming. CRUD is important because of its Create, Read, Update, and Delete features. A brief explanation of these features is listed below:

  • CREATE Operations: Inserts a fresh entry using the INSERT command. This operation is required when we wish to add new data to the database. It basically enables you to add extra rows to your table. When you use the INSERT INTO command, the system will show two possibilities. You can choose the one which is according to your requirement. The two possibilities are:
  • READ Operations: The READ operation retrieves table entries depending on the main key inside the given variable. It works in a similar way to the search feature.
  • UPDATE Operations: Performs an UPDATE assertion on the database depending on the main key provided for an entry in the WHERE statement. You must specify the destination table and attributes to be modified when using UPDATE. The corresponding variables and the rows are also required. Use the code below to make changes to a preexisting record:
  • DELETE Operations: Erases a specific order within the WHERE statement. Certain relational database systems may enable a final delete or a temporary delete, depending on the requirement. The DELETE code is:
  • Here's the table, showing all operations with their description:

Standard CRUD Operations In ASP.NET MVC Utilizing C#

In this section, we will discuss the steps required to operate the standard CRUD operations in ASP.NET MVC within the C# programming language. So, please pay extra attention to this section so that you do not have to face any difficulty while coding.

You must be thinking about the term MVC. Well, MVC abbreviates for Model View Controller. It is actually a development paradigm that isolates the business strategy from the display strategy and information. In a nutshell, it is a framework for designing online applications. According to MVC, the program can be divided into three layers:

  1. Model Layer: The Model element relates to everyone's data-associated reasoning. It will reflect the content being transmitted among the Display and Controlling portions, as well as any additional business logic-associated data. A Client class, for example, will receive client details from a server, change them, or utilize the content.
  2. View Layer: The View element is used for the UI functionality of the device. For example, the Client view will have all of the UI elements that the final user encounters, like input forms, dropdowns, and others.
  3. Controller: Controllers serve as a link among the Framework and View elements to execute all administrative functions and incoming applications, manipulating information with the Framework element, and interacting with Viewpoints to display the final result. For example, the Client manager would manage all activities and entries from the Client Page and use the Client Model to refresh the database.

Now that you know about the MVC, we can begin the discussion of the steps of CRUD operations in C#:

  • Construct A Database Using The Columns Listed Below: It is merely a demonstration to ensure that you comprehend the script. You may construct your custom database based on your requirements. You can also understand it better by the illustrations in each step like the one below:
  • New Project: Build a new project in Visual Basic.
  • Create a Fresh Record: Next, within the freshly formed controller, enter the following script to generate a fresh record within your dataset.

Afterward, select the initial activity outcome and select AddView. Choose to Generate as your theme, model type as your developed model, and info context category as your EDMX developed prototype. After that, execute the project.

  • Read: Next, to view the latest values on your display, use the code provided below.

Then, insert the View. However, make sure the style is set to List. After that, launch the project.

  • Update: Now, use the following code to modify the present record.

Next, insert a view in the same way you did before, but ensure to set the theme to Edit. After that, launch the project.

  • Delete: To erase an entry from the system, use the following code.

Now, just set the theme to Delete and execute the program.

Please remember that you can always change the HTML according to your needs. We hope that you understood how CRUD operations work in databases of the C# programming language.

CRUD Operations in C# Connecting SQL Database

We want our readers to have crystal clear concepts regarding CRUD operations in the C#. That is why we also included this brief section of CRUD operations in C# connecting the SQL Database. Let us begin:

  • Add DLL: First, you must include Dynamic Link Library (DLL).
  • Namespace: To link to a SQL system, you can utilize the System.Data.SqlClient; namespace.
  • Declaration: Next, you should specify the relationship string beyond the class.
  • Insert the Data: Enter data into the system as shown below:
  • Update: Afterwards, you have to update the record like the code mentioned below:
  • Display: Then, display the information like the code below:
  • Delete: Then, follow the code below to erase the record.
  • Use Clear Technique: Lastly, utilize the Clearing technique to remove all the text fields, as shown below:

Please remember these steps. If you mess up in one step, your program will not execute the right way. So, it would be great for you if you note the steps down!

Benefits Of Using CRUD Operations

Now that you know about the launch of CRUD operations in databases within the C# programming language, it is time to know the benefits of using CRUD operations. You must have this question that why do programmers prefer CRUD? In simple words, developers use CRUD because of its exceptional productivity. Additionally, performing CRUD operations protects against SQL manipulation attacks. Because all SQL Entries utilize saved methods rather than string synthesis to generate flexible queries from client input info, everything entered into a variable is quoted.

It would not be wrong to say that CRUD is just too crucial to be overlooked. Mastering it initially can help you feel more confident when working with unknown stacks. CRUD Operations help in our daily desktop tasks. Some of these are:

  • Signing up for a webpage
  • Saving a hyperlink in your account
  • Modifying configurations
  • Deleting a Facebook status

These are just some of them. CRUD is a part of everyone’s life whether one is a programmer or not.

CRUD Restricts Casual Surfing and Changes

Program permissions are a SQL Administration feature that allows code to alter credentials without requiring the person's permission. Individuals should have the necessary rights on the relational records to execute ad hoc SQL queries. Clients can view and change data in apps like Microsoft Excel, PowerPoint, and others after authorization is allowed. Customers can even ignore the app's corporate rules.

However, it is an undesirable scenario that may be avoided by using the Application Authority. Such kind of flaws can be prevented by combining database access protection with an Application License. Because Application licenses are uploaded to the system via a recorded method, CRUD is required. It can also be done by providing authorization to run the CRUD saved methods and removing immediate table entry.

After an Application Account is established, authorization and passcode are granted. The passcode is also hard to change because it is programmed into the program. CRUD is indeed the procedure to utilize while modifying data. Thus, the world of programming would be incomplete without CRUD Operations.

Summing Up

In this article, we discussed the CRUD operations in databases within the C# programming language. We also discussed Standard CRUD Operations In ASP.NET MVC as well as in Connecting SQL Databases Utilizing C#, with some benefits of using CRUD. These might seem complicated to you. Once you become an expert, all the CRUD operations in the C# will not be rocket science for you. Just make sure to follow all the steps correctly to avoid any mistakes.

Happy Programming Precious Readers!

ESP32 Programming Series: Install ESP32 in Arduino IDE

Hello everyone, I hope you're all doing well. In the previous lecture(Chapter 0: ESP32 Pinout), we discussed the ESP32 features & specs in detail. Today, we are officially starting this ESP32 Programming Series. In this ESP32 Programming Series, we will start with basic concepts and will gradually move towards complex topics. I will try to keep this ESP32 series as simple as I can. But still, if you encounter any issues, please ask in the comments, will try to resolve the issues as soon as possible.

As ESP32 has numerous features & applications, so I have divided this series into different sections. I have named the 1st section "ESP32 IDEs". In this section, we will discuss different IDEs used to program ESP32 boards. In each Chapter of this section, we will install one of these ESP32 IDEs and will test a simple LED Blinking Code in it. We will set up the ESP32 Development Environment for Windows, Mac, and Linux users.

As I am sharing the 1st Chapter today, so first we will unbox the ESP32 board, set up the most commonly used ESP32 IDE i.e. Arduino IDE, and test a simple WiFi Scan Code on the ESP32.

Here's a video lecture for better understanding:

Where To Buy?
No.ComponentsDistributorLink To Buy
1ESP32AmazonBuy Now

ESP32 IDEs

IDE is an abbreviation of Integrated Development Environment. IDE is a software package used to write & compile the code. As ESP32 is one of the most popular microcontroller boards, there are numerous third-party IDEs available to program it, and each IDE supports its own programming language. So, if you are a C# developer or an Arduino expert, you can quickly and easily get your hands dirty with ESP32. The below table shows the most commonly used ESP32 IDEs along with their supported programming language:

ESP32 IDEs
No.
ESP32 IDEs
Programming Language
1
Arduino IDE
Arduino C
2
Thonny IDE
MicroPython
3
Visual Studio Code
Arduino C
4
PlatformIO IDE
C++
5
ESP-IDF(official IDE by EspressIF)
C
6
nanoFramework
C#

In today's lecture, we will install the Arduino IDE and configure it for ESP32 Programming. So, let's get started:

Install ESP32 in Arduino IDE

First of all, we need to install the Arduino IDE itself. To program ESP32 with Arduino IDE, we need to install the ESP32 Boards in Arduino IDE. Before installing the ESP32 Boards, we first need to add a JSON File containing information about ESP32 Boards. JSON format is used to share information between two computers. So, this JSON file will add the information of ESP32 boards in the Arduino IDE. So, let me summarize these 3 steps in proper order:

  1. Installing Arduino IDE
  2. Adding ESP32 JSON File
  3. Installing ESP32 Boards
  4. Installing COM Port Driver for ESP32(if COM Port not detected automatically)

Installing Arduino IDE

We need to first download & install the Arduino IDE.

After installing the Arduino IDE, we need to add the ESP32 JSON File in it. So, follow the below steps:

Adding ESP32 JSON File in Arduino IDE

Steps to install ESP32 JSON File in Arduino IDE:

  • In the Arduino Preferences Window, you will find a textbox named "Additional boards Manager URL".
  • Add the ESP32 JSON File link(provided above) in it, as shown in the below figure:

  • If you have already added any third-party board URLs, then add a comma (,) between the JSON links OR click on the button and it will open up a new window, add URL in the new row, as shown below:

  • Click "OK" to close the Preference Window.
  • Once you close the Preference Window, Arduino IDE will extract the information of all ESP32 boards by downloading the ESP32 JSON file.

Now, we are ready to install the ESP32 Boards in Arduino IDE:

Installing ESP32 Boards in Arduino IDE

  • In the Arduino IDE, click on "Tools > Board > Board Manager", as shown in the below figure:

  • It will open up a Board Manager Window in Arduino IDE.
  • From this Board Manager, we can install the packages for third-party modules.
  • In the Board Manager, make a search for "ESP32" and you will get many third-party ESP32 packages.
  • Here, we need to install the "ESP32 by Espressif Systems" as it's the official package, I have highlighted it in the below image:

  • So, click on the Install button to install ESP32 boards in Arduino IDE.
  • Arduino IDE will take some time to install the ESP32 package.

  • Once installed, click on "Tools > Boards > esp32" and you will find a list of newly added ESP32 boards, as shown in the below figure:

  • From this list, we will select "ESP32 DEV KIT V1", it's the most commonly used ESP32 board.

  • In the COM Port, select the available COM Port, in our case, it's COM5:

In some cases, the Arduino IDE won't automatically detect the ESP32 COM Port, so here we need to install the COM Port driver for ESP32. Let's do it:

Installing ESP32 COM Port in Arduino IDE

If you don't find the ESP32 COM Port in the Port Section of Arduino IDE, then you need to install the COM Port Driver manually. So, follow the below steps:

  • Download the Windows COM Port Driver by clicking the below button and install it on your computer:

CP210x_Windows_Drivers

  • If you are using 32-bit Windows, then install the x86 version and if working on 64-bit Windows, then install the x64 version.

After installing this COM Port Driver, restart your Arduino IDE and it's recommended to restart your computer as well.

So, we have successfully installed the ESP32 Boards in the Arduino IDE. Now, let's upload a simple LED Blinking Code in the ESP32:

Code Upload to ESP32 from Arduino IDE

Now that the Arduino IDE is ready to handle the ESP32 Dev Kit module, you can write the code for the ESP32 module. We will just upload a simple WiFi Scan Code to verify that our ESP32 installation is correct.

  • Open Arduino IDE and navigate to "File > Examples > WiFi > WiFiScan".

  • Click on the Tools and verify that you have selected the correct ESP32 board and the COM Port.
  • Now, click the "Upload " button to upload the code to the ESP32 board.
  • If the code is uploaded successfully in the ESP32 board, you will get the confirmation message in the Output pane, as shown in the below figure:

Now open the Serial Terminal and you will start receiving the List of all available WiFi connections, as shown in the below figure:

That concludes today's discussion. We hope you found this post informative. In the next tutorial, we will install the ESP32 Boards in the Visual Studio Code. If you have any questions, please ask in the comments. Take care. Have a good day.

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir