Hello readers, I hope you all are doing great. In this tutorial, we will learn how to update a webpage using Server-Sent Events and the ESP32 web server.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | ESP32 | Amazon | Buy Now |
It is a server push technology that enables the client devices to receive automatic updates from a server over HTTP (Hypertext Transfer Protocol) connection. SSE also describes how the server can initiate data transmission towards the client once an initial connection with the client has been established.
We have already posted a tutorial on how to implement Web socket protocol with ESP32 which is also a protocol used to notify events to a web client. Both the Server-Sent Events (SSE) and Web-Socket technologies seem to be quite similar but they are not.
The major difference between the two is that SSE is unidirectional, where the web client can only receive the updates from the ESP32 but it can’t send updates back to ESP32. On the other hand, the Web-socket protocol is bi-directional where both the web client and ESP32 can send and receive updates/events.
Fig. 1 Server-Sent event
The Server-Sent Event process initiates with an HTTP request from the web client or web page to the ESP32 web server. After that, the ESP32 is ready to send updates or events to the web client as they happen. But the web client can’t send any response or data to the ESP32 server after the initial handshake takes place.
Server-sent event technology can be used to communicate an event, GPIO states or to send sensor readings to the web client, whenever a new reading is observed.
For demonstration purpose, we are using a DHT11 sensor with the ESP32 module. ESP32 web server will display two things i.e., temperature and humidity observed using the DHT11 sensor. So, whenever a new reading is being observed, the ESP32 sends the reading to the Web Client over Server-sent events. After receiving the latest sensor reading the client updates the web page data.
Fig. 2 DHT11 sensor
DHT11 is a humidity and temperature sensor that measures its surrounding environment. It measures the temperature and humidity in a given area. It is made up of an NTC (negative temperature co-efficient) temperature sensor and a resistive humidity sensor. It also has an 8-bit microcontroller. The microcontroller is in charge of ADC (analog to digital conversion) and provides a digital output over the single wire protocol.
The DHT11 sensor can measure humidity from 20% to 90% with +-5 percent accuracy (RH or relative humidity) and temperature from 0 degrees Celsius to 50 degrees Celsius with +-2C accuracy.
DHT11 sensors can also be used to build a wired sensor network with a cable length of up to 20 meters.
Table 1
Note: Connect a 10K resistor between data and power (+5V) pin of DHT11 sensor module.
Fig. 3 ESP32 and DHT11 connections/wiring
We are using Arduino IDE to compile and upload code into the ESP32 module. You must have ESP32 board manager installed on your Arduino IDE to program the ESP32 module. To know more about Arduino IDE and how to use it, follow our previous tutorial i.e., on ESP32 programming series. The link is given below:
https://www.theengineeringprojects.com/2021/11/introduction-to-esp32-programming-series.html
Fig. 4 manage libraries
Fig. 5 Install DHT sensor library
ESP32 board manager doesn’t come with inbuilt libraries to create an asynchronous web server. So we need to download the library file from external sources and then add into Arduino IDE.
We need to install two library files:
Once you have successfully downloaded the required libraries, next step it to install or add these libraries in Arduino IDE.
To add the libraries in Arduino IDE, go to Sketch >> Include Library >> Add .zip library and then select the downloaded library files.
Fig. 6 adding necessary libraries
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "DHT.h"
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
// Initializing the DHT11 sensor.
DHT dht(DHTPIN, DHTTYPE);
// Replace with your network credentials
const char* ssid = "SSID";
const char* password = "password";
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
// Create an Event Source on /events
AsyncEventSource events("/events");
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 20000; //20 sec timer delay
//==== Creating web page
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
<title>SSE with ESP32 Web Server</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link rel="icon" href="data:,">
<style>
html {font-family: Times New Roman; display: inline-block; text-align: justify;}
p { font-size: 1.2rem;}
body { margin: 0;}
.topnav { overflow: hidden; background-color: blue; color: white; font-size: 1rem; }
.content { padding: 20px; }
.card { background-color: #ADD8E6; box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); }
.cards { max-width: 600px; margin: 0 auto; display: grid; grid-gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.reading { font-size: 1.4rem; }
</style>
</head>
<body>
<div class="topnav">
<h1>Server-Sent Events </h1>
<h2> DHT11 Sensor Data </h2>
</div>
<div class="content">
<div class="cards">
<div class="card">
<p> DHT11 Temperature</p><p><span class="reading"><span id="temp">%TEMPERATURE%</span> °C</span></p>
</div>
<div class="card">
<p> DHT11 Humidity</p><p><span class="reading"><span id="hum">%HUMIDITY%</span> %</span></p>
</div>
</div>
</div>
<script>
if (!!window.EventSource)
{
var source = new EventSource('/events');
source.addEventListener('open', function(e)
{
console.log("Events Connected");
}, false);
source.addEventListener('error', function(e)
{
if (e.target.readyState != EventSource.OPEN)
{
console.log("Events Disconnected");
}
}, false);
source.addEventListener('message', function(e)
{
console.log("message", e.data);
}, false);
source.addEventListener('temperature', function(e)
{
console.log("temperature", e.data);
document.getElementById("temp").innerHTML = e.data;
}, false);
source.addEventListener('humidity', function(e)
{
console.log("humidity", e.data);
document.getElementById("hum").innerHTML = e.data;
}, false);
}
</script>
</body>
</html>)rawliteral";
void setup() {
Serial.begin(115200); //initialize serial monitor
//===set and initialize Wi-Fi
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi ..");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print('.');
delay(1000);
}
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); // print the IP address
//====Initialize DHT11 sensor
dht.begin();
//====Handle Web Server
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html);
});
// Handle Web Server Events
events.onConnect([](AsyncEventSourceClient *client)
{
if(client->lastId())
{
Serial.printf("Client reconnected! Last message ID that it got is: %u\n",
client->lastId());
}
// send event with message "hello!", id current millis
// and set reconnect delay to 1 second
client->send("hello!", NULL, millis(), 10000);
});
server.addHandler(&events);
server.begin();
}
void loop()
{
delay(2000);
float humidity = dht.readHumidity();
// Read temperature as Celsius (the default)
float temperature = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(humidity) || isnan(temperature))
{
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
if ((millis() - lastTime) > timerDelay)
{
// Send Events to the Web Server with the Sensor Readings
events.send("ping",NULL,millis());
events.send(String(temperature).c_str(),"temperature",millis());
events.send(String(humidity).c_str(),"humidity",millis());
Serial.print(F("Humidity(%): "));
Serial.println(humidity);
Serial.print(F("Temp.: "));
Serial.print(temperature);
Serial.println(F("°C "));
}
}
Fig. 7 Header files
Fig. 8 Global declarations
Fig. 9
Fig. 10 Enter Network credentials
Fig. 11 Server port
Fig. 12 Event source
Fig. 13 Timer Variables
Fig. 14
Fig. 15
Fig. 16
Fig. 17
Fig. 18
Fig. 19
Fig. 20
Fig. 21 Fetch/obtain the IP address
Fig. 22 Initialize DHT sensor
Fig. 23
Fig. 24 Handling server events
Fig. 24 initializing web server
Fig. 25
Fig. 26 If error occurs while reading data from DHT11
Fig. 27 Sending events to the server
Fig. 28 Print Sensor data on the Serial monitor
Fig. 29 Select development board and COM port
Fig. 30
Fig. 31
This concludes the tutorial. I hope you found this of some help and also hope to see you soon with a new tutorial on ESP32.
Hello! Welcome to the next lesson in this Python course. In the last session, we learned about python tracebacks and how to deal with them. A dictionary, like a list, is a collection of items, and we'll look at that in this tutorial as well.
This tutorial introduces you to the fundamentals of dictionaries in Python and teaches you how to work with dictionary data. After reading this article, you should be able to tell when and how to utilize a dictionary as a data type.
Data structures that use associative arrays, or dictionaries in Python, are known as dictionaries. Dictionaries store key-value pairs. Every pair of key-values has a corresponding value assigned to it.
With curly bracketed lists of value pairs, you can define a dictionary (). Each key and its corresponding value are separated by a colon (:):
The following is a definition of a dictionary that links a place's name to the MLB team that occupies that location:
The built-in dict() function can also be used to create a dictionary. Key-value pairs should be passed to dict() as an argument. In this case, a list of tuples works well:
The following is an alternate definition for MLB team:
Key values can be supplied as keyword arguments if they are simply strings. MLB team can also be defined in another way.
You can display the contents of a dictionary in the same way you do a list once it has been defined. When presented, the following is what each of the three definitions provided above looks like:
An alphabetical list of words and phrases is shown in the dictionary. When it comes to getting them back, however, none of it matters. There is no numerical index for dictionary elements:
Dictionary elements, of course, need to be accessible in some way. What if you can't find them using an index?
To get a value out of a dictionary, use the square bracketed key ([]):
Python throws an error if you try to use a key that doesn't exist in the dictionary:
It's as simple as setting a new key and value to the existing entries in a dictionary:
In order to make a change to an existing record, you can assign different value to the current key.
A record can be deleted by issuing the del command with the key you want to delete specified:
For some reason, the interpreter throws a Key Error whenever an undefined key or numeric index are used to retrieve a dictionary's keys.
A mistake has been made in both cases. However, [1] does not represent an index in the second instance.
To utilize an immutable object as a dictionary key, you'll discover later on in this lesson that it's possible. It follows that integers are perfectly acceptable:
The integers enclosed in square brackets [] appear to be indexes. It's only that they don't have anything to do with the dictionary's order. They're being treated as dictionary keys by Python. The same values can be obtained by defining the dictionary in the reverse order:
Despite the similarity in syntax, a dictionary cannot be treated as a list:
As a reminder, Python guarantees that the order of entries in a dictionary will be retained even if access to them is not required. Order matters when it comes to displaying items and iterating over the keys; this is how they'll appear when you see them. Items that are added to a dictionary are inserted in its final paragraph. Even after deletion, the remaining items retain their original order.
When all the other keys and values are known ahead of time, a dictionary can be defined as shown above by use of curly brackets and a value. It's a difficulty if you want to build a vocabulary on the fly.
Empty curly braces specify an empty dictionary, so that's where you want to start. Adding additional keys and values one at a time is possible.
It's the same as using any other dictionary once the dictionary has been constructed in this manner:
A secondary index or key is required to retrieve the values from the sublist or subdictionary:
Another advantage of dictionaries is that they don't require all of their entries to be of the same type. There are some strings, some integers, a list and a dictionary among the values in person.
The keys and values don't have to be the same.
Integers, floats, and Booleans make up three of the four keys. Although it isn't immediately clear how this could be of benefit, you never know.
Python dictionaries can be used in a variety of ways. As a part of the MLB_team, the baseball team's name can be found in a number of places. There is only one entity that can be used to identify an individual: the person.
There are few restrictions on the types of keys and values that can be stored in dictionaries, making them useful for a wide range of tasks. But there are a few exceptions to this rule. Continue reading for more information!
It is possible in Python to utilize almost any value as key in dictionary. You saw how to use integer, float, and Boolean values as keys like:
It's also possible to use pre-existing objects like types and functions in your code:
Dictionary keys, on the other hand, are subject to a few restrictions.
It is important to note that a single key can only be used in a dictionary once. It is not permitted to use two different keys. So, it doesn't make any sense to have more than one entry for the same key in the dictionary.'
You can't create a new key by introducing a new value to the current dictionary key; rather, you can simply replace the existing value.
Second-occurrence key names take precedence over first-occurrence ones in the dictionary-building process.
It's also important that a key in dictionary is of a type that cannot be changed. In the examples you've already seen, several of the types that are immutable, such as integers, floating points, strings, and Bools, have been used as dictionary keys.
Tuples, by virtue of their immutability, can also be used as dictionary keys:
When an immutable type is needed, a tuple is preferable to an array. One of them is this.)
Lists and dictionaries can't be used as a dictionary key because of the mutability of both:
For a dictionary key to work, an object does not necessarily need to be immutable. It must be possible to send an item via a hash function, which means it must be hashable. For database lookup and comparison, data of any size can be hashed using a hash function to produce a fixed-size result known as a hash (or simply hash).
When an object is hashable, the built-in hash() method delivers its hash value; otherwise, it raises an exception.
As you've learned so far, immutable types and containers (lists/dictionaries) that can be hashed are all built-in. For the time being, you can consider the terms "hashable" and "immutable" to be nearly interchangeable.
You'll see changeable objects that are also hashable in upcoming lectures.
Dictionary values, on the other hand, are unrestricted. In fact, there is nothing at all. For example, lists and dictionaries can be mutated and user-defined objects can be created in Python.
In a dictionary, there is no limit to the number of times a single value can appear.
A large number of the built-in and available operators and functions for working with texts, lists, or tuples will be known to you at this point. As well as other dictionaries, several of these are useful.
Using the in and not in operators, for example, you can determine whether or not an operand is a dictionary key.
A key that is not in the dictionary can be avoided by using the in operator and short circuit evaluation:
Dictionary key-value pairs are counted using the len() method.
Similarly, to strings and lists, dictionaries include built-in methods that can be used. Although lists and dictionaries share names in some circumstances, it is not always the case. Since various kinds might have methods with the same names, this is totally appropriate when discussing object-oriented programming.)
There are a few approaches that can be used for dictionaries:
Clears elements in the dictionary.
The function d.clear() removes all key-value pairs from the dictionary d:
Whether or not a key exists in the dictionary is checked, and the value associated with it is returned.
This method can be used to retrieve the value of any key without having to verify that the key exists.
If a value matching the supplied key (<key>) is discovered in dictionary d, Get (<key>) returns it. If it is unable to locate the appropriate key, this procedure returns 0.
We're going to use -1 instead of None in case <key> could not be located and the <default> argument had been provided.
The key-values` list in a dictionary is returned by this command.
items(‘value’) will return a tuple`s list containing the values in d. Key value tuples consist of two items: the key and the value.
This function will return a list of the dictionary's keys.
A list of all d keys can be found using d.keys()
Values of dictionary are returned in response to this method.
The list of all values in d is returned by d.values()
If d contains any duplicate values, all of those values will be returned:
A "view object," which is a collection of objects, keys, and values, is returned by these functions. The keys and values of a dictionary can be seen through a similar window in a dictionary view object, the keys and values of the dictionary are returned as an array by these methods.
A key is removed from the dictionary and its value is returned if it exists.
pop(key) will remove key and return its related key when <key> is in d:
In a dictionary, this function removes one key-value pair.
d.popitem() will remove and return any last key pair added to d.
Merges the dictionary and iterable key-value pairs.
A dictionary can be updated with update(<obj>), which merges all of the items from obj>. For each key in obj>:
If the value pairs from obj do not already exist in d, they are added to d.
Changes to the value of the key in d are made by use of values from <obj>.
The following is an example of how two dictionaries can be combined:
Therefore, its value is set to 200 because b is contained in d1, which is derived from d2's entry for that key. D1 does not include the key d, hence the key-value pair is taken from d2.
Key-value pairs can also be utilized to define a dictionary using the dict() function. As an example, a list of tuples, such as obj:
It is also possible to specify the values to merge in the form of a list of keywords:
Throughout this course, you learned how to read and manipulate the data in a Python dictionary.
Lists and dictionaries are two of Python's most commonly used data structures. It is clear from the comparison that they have many commonalities yet are different in how their elements can be found. Index numbers are used to locate items in lists, and keys are used to locate items in dictionaries.
Therefore, lists and dictionaries are appropriate for different circumstances. You should now be able to tell whether one or the other is the best option in a given case.
Python sets are the next topic you'll study. Unlike lists and dictionaries, the set is not a simple collection of elements.
Any time an exception is thrown in your code, Python shows you the stack trace. If you don't know what the traceback output is showing you, it can be a little overwhelming. Python's traceback, on the other hand, provides a goldmine of information that can assist you in figuring out why an exception was triggered in your code and fix it. It's essential to learn how to use Python traceback to become a better coder.
After completing this session, you will be able to do the following:
This is a list of all the function calls you made at a certain time in your code. Stack traces, stack tracebacks, backtraces, and maybe other terms refer to tracebacks. Traceback is the term used in Python. Python will report the current traceback if your program throws an exception, so you can figure out what went wrong. The following is an example of how this may play out:
Someone is passed to greet() as an argument. But in greet(), the name of the variable is not used. In the print() call, the word someon was used instead. On startup, you'll get a traceback like this:
All of the details you need to investigate the problem can be found in this traceback output. What sort of exception was thrown and what information about it can be found in the last line of the traceback report? Using the traceback, it is possible to identify the code that caused the exception to be raised. When an exception like the one seen above occurs, it implies that a reference to an undefined name (variable, function, or class) is being used. Somebody is the person being referred to in this instance.
Here, the final line gives you enough information to figure out how to fix the issue. You may find the correct code by searching for the misspelled name "someone" in the source code. However, it is common for your code to be far more complex.
When you're attempting to figure out what caused an exception to be thrown in your code, the Python traceback provides a wealth of information. Throughout this part, you'll learn about the many pieces of information that can be found in a traceback.
It is critical to pay attention to each section of a Python traceback. As shown in the picture below, there are several different components:
Using Python, it's better to start at the bottom and work your way up the traceback
For example, traceback output differs between command-line execution and the REPL's execution of code. The same code from the previous section was run in a REPL and the traceback output is shown below:
You'll see "<stdin>" in place of filenames. This makes it reasonable because you entered the code using normal input. In addition, the traceback does not indicate the executed lines of code. You may notice a big difference in the look of a Python traceback compared to other programming languages' stack traces. Other languages often begin at the top and work their way down the list, going from the most recent calls to the oldest ones, in that order.
You can get a better idea of what information the traceback will give you by going through some of the traceback output. In the following instances, the traceback information provided by Python is illustrated using the code below:
who to greet receives a value, a person, and either return it or prompts for a value to return instead. Then welcome() takes a name to be greeted, a person and an optional greeting value, and calls print() (). This function is also invoked with the passed-in value of "someone."
Finally, greet many() calls greet after iterating through the list of persons (). If welcome() returns an error, then a simple backup greeting is printed instead of the original greeting. There are no issues in this code that would cause an exception to be thrown if the correct input is provided. You'll see the following traceback if you call greet() at the bottom of greetings.py with a keyword argument that it doesn't expect (for example greet('Chad', greting='Yo’)).
If you're dealing with a Python traceback, you should always start by tracing backward. The traceback shows that the exception was a TypeError at the end of the last line. Everything after the colon in the message after the exception type gives you a wealth of information. It informs you that a keyword argument was passed to greet() that it wasn't expecting. Greting is the name of the unknown argument. The line that caused the exception can be seen as you move up the tree. We inserted the greet() code at the bottom of greetings.py in this example.
There is a second line of information that tells you exactly where the code is, what module it's in, and how you may get to it. module> indicates that this is the file that is being executed in this situation since our code doesn't use any other Python modules. Using a new file and different input, you can see where the traceback is leading you. Remove the faulty greet() function from greetings.py and add this file to your directory: greetings.py
You've created a new Python file, greetings.py, which imports greetings.py and uses greet(). If you now run example.py, you'll see what I mean:
This time, a TypeError is thrown, but the message it contains is less instructive. It was expecting to deal with a string but instead received an integer at some point in the program's code. You may see the code that was performed by moving up a few levels. The code's location and filename are then provided. Greet is the function name instead of module> this time around ().
The incorrect greet() call is now passed to the next line of code to be executed. When an exception is thrown, it may be caught by another piece of code, which will then throw an exception of its own. Even if there are many exception tracebacks, Python will always print the traceback of the most recently raised one first.
Here's an example to help clear things up. The bottom of welcomes should include a call to greet many(). py:
All three people should receive printed greetings as a result of this. To see an example of several tracebacks being output, run this code.
In the output above, look for the highlighted line that begins with the phrase "During handling." This line appears in the middle of every traceback. Its message is crystal clear: another exception was produced while your code was trying to handle the prior exception.
Previously, when you called greet() with an integer, you saw the same problem. We can assume the same outcome because we added a 1 to the list of individuals to greet. The welcome() call is redirected to a try-and-except block in the greet many() method. If greet() throws an exception, greet many() will output a generic welcome.
Greetings.py's pertinent paragraph is reprinted here.
As a result, greet many() attempts to produce a simple greeting when greet() fails due to a TypeError caused by an invalid integer input. In this case, the code results in a similar exception. However, it's still attempting to combine two different types of data. Traceback output can help you identify the root cause of an exception by displaying all of the possible causes. When you view the last exception and its traceback, you may not be able to figure out what went wrong. Moving up to the prior exceptions will usually give you a clearer grasp of the underlying problem in these situations as well.
When your program throws an exception, it's helpful to know how to read a Python traceback, but it's also helpful to know some of the most typical tracebacks. Listed here are some of the most typical exceptions you'll encounter, along with the reasons they're raised and what they mean, and how to track them down.
If you attempt to access an attribute on an object that does not have that attribute declared, you will receive an AttributeError exception. When this exception is thrown, according to the Python manual:
AttributeErrors have an error message indicating that a certain object type, in this example an int, does not have the attribute accessed, an attribute. If you see the AttributeError in the error message, it will assist you to identify the attribute you attempted to access and where you need to go to fix the problem.
If you get this exception, it's likely because you're working with an object that isn't what you expected.
An ImportError is thrown when an import statement fails. The ModuleNotFoundError exception or a subclass thereof will be thrown if you try to import anything from a module that does not exist in the module you are trying to import it from. When this exception is thrown, according to the Python manual:
The ModuleNotFoundError occurs when an attempt is made to import a module that does not exist, like in the above example. An ImportError is thrown if you try to import something that doesn't exist from a module that does exist. Both asdf and asdf can't be imported because of the error message lines at the bottom of the tracebacks.
What causes the NameError to be raised is the fact that you've used a name that hasn't been specified in your code. When this exception is thrown, according to the Python manual:
Greet() in the following code accepts a person as a parameter. Persn, on the other hand, is the incorrect spelling of this parameter in the function itself:
Your missing name can be found in the NameError traceback error message. In the example above, a misspelled variable or parameter was passed into the function.
If you misspelled the parameter, you'll get a NameError:
In this situation, it may appear as if you've done nothing wrong at all. A clean traceback can be seen after the last line of code was executed. Look through your code to see where the person variable is used and defined if you find yourself in this circumstance. An error in the parameter name can be easily seen in this example.
Making a decision after receiving a Python exception and associated traceback can be difficult. It's always a good idea to address your code first, however, in certain cases, the problem is caused by inaccurate or unexpected user input. There are instances when silence or hiding an exception by logging the traceback and doing anything else is more appropriate than providing for those situations in your code.
The following code needs to suppress some Python tracebacks in the real world. The requests library is used in this example.
This code works perfectly. A command-line argument is required to launch this script, which will call the URL and print its HTTP status code and response content. Even if the answer contained an HTTP error status, it still works:
Your script may be unable to obtain a URL because it does not exist or the host server is unavailable. Uncaught ConnectionError exceptions and tracebacks will now be raised and printed in those circumstances.
Many other exceptions may be raised before the ConnectionError is raised by the requests themselves in the Python traceback. Line 5 of urlcaller.py is where the trouble began, as you can see in the final exceptions traceback.
For example, if you put the offending line in a try and except block, you can catch the proper error and continue to work:
Instead of using a try/except block, the above code uses an else clause. To learn more about this feature of Python, see the section on else clauses in Python Exceptions: Introductory remark
You'll now see a -1 for the status code and the text "Connection Error:" written when the script is run with a URL that raises a ConnectionError.
This is fantastic. But in most real-world systems, you want to log the traceback rather than just mute the exception and its traceback. Tracebacks, help you figure out what's going wrong with your programs. It is possible to log the traceback in the script by importing the logging package, creating an exception, and calling.exception() on the logger in the except portion of the try and except block. In the end, your script should look like this:
Using Python traceback is a wonderful way to find out what is wrong with your code. These tracebacks may appear frightening at first, but if you understand what they're trying to tell you, they can be really useful. You may get the most out of tracebacks if you go through a few of them line by line. When you execute your program and get a Python traceback, you have an opportunity to make improvements to your code. Python does its best to assist you in this way.
Knowing how to decipher a Python traceback opens the door to learning about other diagnostic tools and approaches that can help you figure out what's wrong with your code. Tracebacks can be seen and worked with using Python's built-in traceback module. When you want to gain more from the traceback output, the traceback module can be useful. It's also a good idea to brush up on your Python debugging skills. In light of this, we'll take a look at dictionaries in Python in the next tutorial.
Welcome to chapter 9 of our python tutorial. In the previous chapter, we looked at frequent examples of invalid Python syntax and learned how to fix them. Up to this point, you are well aware of errors that may occur in your Python program and how you can solve them easily and quickly. Therefore, in this tutorial, we will look at a few more causes of syntax errors and zero-error divisions.
As you learned before, omitting the comma from a dictionary element can result in a syntax error. In Python dictionaries, the equals symbol (=) is used instead of a colon to separate key and value pairs.
This error message is once again useless. In this case, the repeated line and caret come in handy! All signs lead to the main antagonist. In addition, if you mistakenly believe that defining a dictionary is the same as calling dict(), you'll get this error. A colon could be used in place of the equals sign to correct this. It's also possible to use dict() instead:
If the dict() syntax is more useful, you can use it to define the dictionary.
Syntax Error has two subclasses that deal especially with indentation issues:
Python employs whitespace instead of curly brackets to represent blocks of code in other computer languages. Python, on the other hand, assumes that your code's whitespace will behave predictably. If a line in a code block has an incorrect number of spaces, an Indentation Error will be thrown:
A quick inspection may not reveal that line 5 is indented by two spaces. It should be four spaces over from the for-loop expression. Fortunately, Python can detect this and instantly inform you of the problem. However, there's some gray area here as well. Do you want the print("done") to appear before, or after the block with a for-loop? if you run the following code, you'll get the following error message;
It appears like a Syntax Error traceback, but it is an Indentation Error. Error messages are also highly helpful. There is a discrepancy in the line's indentation level compared to other indentation levels. Print('done') is an alternative that is indented by two spaces, but Python can't identify any additional lines of code that match this amount of indentation. To resolve the problem quickly, make sure the code is aligned with the anticipated indentation level. Tab Error is another type of Syntax Error, which is the result of indentation using tabs or spaces, while the rest of the file has either spaces or tabs instead. You may not see this until Python does!
All lines may be indented at the same level when the tab width is the same as the number of spaces used in each indentation criterion. For example: Using tabs instead of spaces when indenting a line will cause Python to raise an error message.
Instead of four spaces, a tab denotes indentation on line 5. Depending on your system, this code block may appear correct to you, or it may appear incorrect to you.
Python, on the other hand, will be alerted to the problem right away. As a way to view whatever Python tells us is wrong; it might be beneficial to view an example of what the code looks like under various tab-width settings:
The three examples above show a considerable difference in how they are shown. Even though most of the code utilizes four spaces per level of indentation, Line 5 only uses one tab in all three circumstances. The width of the tab changes when the tab width is set:
The print statement will appear to be outside the for loop if the tab width is set to 4. After the loop, the console will display the word 'done. If the tab width is set to 8, the print statement will appear to be inside the for loop (which is common on many computers). After each number, the console will display the word 'done.' Using the print statement with a tab width of 3 appears strange too. In this case, there is no indentation level associated with line 5.
There is a traceback and error message when you run this code.
Instead of a Syntax Error, there's a Tab Error. A useful error message from Python identifies the problematic line. It's easy to see that the file contains a mix of tabs and spaces for indentation. There is no need to utilize both tabs and spaces in the same Python code file as a workaround. It would be better if we replaced the tab with four spaces, which would output "done" when the for loop completes.
When defining or calling functions in Python, you may encounter syntax errors. If at the end of a function definition, you place a semicolon instead of a colon, you'll get a Syntax Error.
With the caret pointing directly at the problematic character, this traceback is helpful. The semicolon can be replaced by a colon in Python to correct this erroneous syntax. As an additional requirement, keyword arguments must be placed in the correct sequence in both function definitions and function calls. Positional arguments are always followed by keyword arguments. A Syntax Error will be thrown if this ordering is not followed:
Again, the error notice makes it quite clear what went wrong with the line in question.
When upgrading from one version of Python to another, it's not uncommon for previously working code to malfunction. This is the result of standardized grammatical adjustments. Most notable is the print statement, which was a keyword in Python 2 but was converted to a built-in function in Python 3.
The Syntax Error's error message shines in this case! It also informs you exactly how to fix a print call that has missing parenthesis. Additionally, it's possible to come across syntax that is correct in one Python version but is not correct in the one you're working in. The f-string syntax, for example, does not exist in Python before 3.6:
Before Python 3.6, the interpreter had no concept of the f-string syntax and would simply produce an error stating that the syntax was invalid. Python version 2.7 was used in this example, and while the code seemed to be correct, it was running on an older version. Double-check the Python version you're using if you're unsure.
The new Syntax Warning is also included in Python 3.8. This alert will appear if the syntax is correct, but there is something fishy about it. A comma would be needed between two tuples in a list as an illustration of this. Because a tuple cannot be called, this code would trigger a Type Error in earlier versions of Python.
The Python interpreter interprets your attempt to use a tuple as a function, which results in this Type Error.
This code still raises a Type Error in Python 3.8, but now you'll see a Syntax Warning that tells you how to solve it.
New Syntax Warning even includes a clue ("maybe you skipped a comma?") to put you in the right way!
It's possible to get a ZeroDivisionError when you divide by zero. In mathematics, an integer split by zero yields an infinite number. Infinite numbers are physically impossible to write down. A ZeroDivisionError: division by zero "is thrown by Python if the result is infinity. It is possible to divide two numbers by one another. A division procedure is all about dividing an int or float value into equal parts or groups. It's harder to interpret a number when it's broken into zeroes. When a number is divided by zero, the outcome is unclear.
Infinity is the result of dividing a number by zero. Since an infinite number cannot be expressed in a concrete form, Python cannot handle it. A "ZeroDivisionError: division by zero" is thrown in this case by Python. The following is an example of an error that would be thrown if it occurred.
Python's Zero Division Error can be thrown in many different ways. The following is a list of ZeroDivisionError's various forms.
Zero-division errors occur when numbers are divided by zero or when they are modulo zero. A non-zero numeric number should be used as the denominator in the division operation. If the denominator is 0, the interpreter throws the exception ZeroDivisionError. It is illogical to divide a number into units of zero. So, you end up with an unrepresentable, infinitely large integer in Python. Python throws an exception because of the "ZeroDivisionError: integer division or modulo by zero" error. An integer, long, float, or complex number can all be affected by this issue.
It is necessary to divide an integer by a non-zero number. ZeroDivisionError is thrown by the Python interpreter when a number is divided by zero in a program. A division error will occur if the numerator is set to 0.
The code that follows demonstrates how to get the error to occur again.
x = 8
y = 0
z = x / y
print z
Results:
Solution 1
In Python, zero cannot be divided by anything. The denominator must be nonzero before performing any division or modulo operations. When the denominator is 0, the code below explains how to handle it.
x = 8
y = 0
z = x / y
print z
Results:
Solution 2
Denominator values can be zero in some circumstances when the program is uncertain about the denominator value. Handle the ZeroDivisionError if it occurs in this situation. Using the code below, you can see how to handle a ZeroDivisionError.
try:
x = 8
y = 0
z = x / y
except ZeroDivisionError:
z = 0
print z
Output:
Solution 3
The output of a division operation can be set to zero if the numerator is 0 in the program. This may not be correct in terms of mathematics. Real-time calculations will no longer have this problem if the division is set to zero. Here's how to establish the zero for the division operation using this code.
x = 8
y = 0
if y == 0:
z = 0
else:
z = x /y
print z
Output:
At this point, you might have met or heard the term debug somewhere during your programming journey.
As a multi-step process in computer programming and engineering, debugging begins with the discovery of an issue before being followed by an attempt to isolate the problem's cause and either resolve it directly or find an alternate solution. Finally, a patch or workaround must be tested to see if it fixes the problem. The debugging process has two stages: the discovery of a bug and the ability to replicate it. It is necessary to include debugging in every stage of software development and testing.
Debugging in hardware development often focuses on finding hardware components that are incorrectly installed or configured. A JTAG connection test, for example, could be used by an engineer to look for bad connections on a computer chip.
You've seen how the Syntax Error traceback provides you with information in this tutorial. Several frequent Python syntax problems have been demonstrated, along with solutions. In addition to speeding up your work, this will make you a better code reviewer because you will be able to do more. It is highly recommended that you use an editor that understands Python syntax and provides feedback as you write code. To make sure you don't write any bad Python code, look at the examples from this course in an IDE before you start writing your own. When studying Python, a syntax error can be frustrating, but now you know how to comprehend traceback warnings and what sort of erroneous Python syntax you may encounter. You'll be more prepared for the next time you encounter a syntax error!
Here, in this project, we are going to make an Up-Down counter. A simple counter counts in increasing or decreasing order but the Up-Down counter counts in increasing and decreasing order, both depending upon the input it has given.
But I am having an interesting question about the counter. Let suppose if the counter is counting in increasing order then up to which value, it will count because it can not count to infinite which means it has to reset after some certain value, and I believe that you must be having the same doubt as well. Basically every counter resets itself after a certain value and that value depends upon the bits of a counter.
Let suppose, we have a 8 bit counter which means it will count a maximum of up to 255 after which, it will reset to 0. So the size of the counter depends upon the bits of the counter.
So, in this project, we are going to make a counter which will count from 0 to 9 after which it will again reset to 0.
We will make this project in the simulation first, for that we will use a simulation software which is Proteus.
Proteus is a simulation software for electronics based circuits. In this software we can make different types of electronic circuits and we can run the simulation and can monitor the working of that project in real-time only.
And it is a good practice also while making any new project. First of all, we should make a simulation of that project so that we can debug any issues without damaging any real components.
Proteus has a very huge database of all types of electronics components pre-installed.
In this project, we will use the following components:
Truth Table for Modes
In this project, we will use two push buttons for controlling the counter as an Up counter or Down counter. The outputs from the push buttons will work as input for the BCD/DECADE UP/DOWN COUNTER IC. When we press the push button, there will be a change in the signal pin of the IC and according to the truth table when the signal changes from logic HIGH to LOW and the other input clock pin is at HIGH state then it will change the output count value depending upon the selected pin.
Which means if we push the Up counter push button, it will send a pulse to CpU pin of the IC, afterwards it will process as the increment in the output value, so it will increase the current output value by one. Similarly, for the Down counter push button, when we press the button, it will send a pulse to the CpD pin of the IC, thereafter it will process as the decrement in the output value so it will decrease the current output value by one.
And the outputs of the BCD/DECADE UP/DOWN COUNTER IC will work as the input for the BCD to 7-Segment Decoder. And the output pins of the BCD to 7-Segment Decoder will be connected to the 7 segment LED with some protection resistor to prevent them from damaging.
The 7-Segment Led display will glow the LEDs depending upon the output values on the BCD to 7-Segment Decoder/Driver.
Now we know the workflow of our counter.
So let‘s move to the circuit of the counter.
For making the project, we will be using the Proteus simulation software.
Now we have our circuit ready, it is time to test it.
I hope we have covered all the aspects of this project. And I think it will be a very useful learning project as well. Now if we see any scoreboard, immediately we will be knowing the electronics behind it. I hope you have enjoyed reading this project. Please let us know in the comment section if you have faced any issues while making this project.
Thanks for reading this article. See you in the next project.
Hey readers! I hope you are doing good and learning something. Have you ever thought about electric vehicles, which are rechargeable and run on a battery? Now, it is possible, and today, we will discuss electric vehicles.
All over the globe, EVs have made a major difference by being a cleaner and cheaper way to travel than gasoline and diesel cars. Unlike cars with engines, electric cars are environmentally friendly because their engines use rechargeable batteries and give out no emissions. The rise in buyers and producers of EVs is thanks in part to new kinds of batteries, better motors, and certain actions taken by the government.
Because of their various operating systems, Battery Electric Vehicles (BEVs), Plug-in Hybrid Electric Vehicles (PHEVs), Hybrid Electric Vehicles (HEVs), and Fuel Cell Electric Vehicles (FCEVs) are each designed for different situations. All kinds of EVs offer several main benefits: they are better for the world, use less energy, perform well, and cost less to run.
But difficulties such as shorter driving ranges, fewer places to charge, batteries losing their power, and cars costing more upfront keep many people from using EVs. Even then, progress in EVs is being pushed forward by innovations in batteries, using wireless chargers, and technology for cars and the grid. On the road to sustainability, EVs will show the way and help cut down on pollution worldwide.
Here, you will learn about electric vehicles, their main components, working, types, charging structure, advantages, and future. Let’s start.
Electricity, not gas or diesel, is what an EV needs to work. Its motor operates on rechargeable batteries, and those batteries get recharged whenever the toy is connected to an electric power source. No emissions at the tailpipe means EVs are green and save energy.
Some EVs are named Battery Electric Vehicles (BEVs), some are called Plug-In Hybrid Electric Vehicles (PHEVs), and there are a few called Fuel Cell Electric Vehicles (FCEVs). Many methods exist, but all technology is about lowering the use of fossil fuels.
The reduced expense to run EVs, as well as how quiet they are and how little maintenance they require, are bright reasons many choose them for future journeys.
Electric vehicles are not a 21st-century invention; they have existed since the early 19th century. Here’s a short chronology:
1828 -1835: Inventors such as Ányos Jedlik and Thomas Davenport developed the first crude electric motors and electric vehicles with non-rechargeable batteries.
1870s -1880s: Advances in technology (for example, lead acid batteries developed by Gaston Planté) made electric vehicles somewhat practical.
1890s -1900s: Mentioned above, electric vehicles gained popularity (in the U.S.) because they were quieter and cleaner than steam and gasoline-powered cars, and by 1900, it was estimated that 28% of vehicles in the U.S. were electric.
1920s: Ford's mass production of gasoline-powered vehicles, better roads, and the refusal to stop using electric vehicles forced electric vehicles into oblivion.
Late 20th Century: Increasing oil prices and awareness of environmental issues saw a renewed interest in electric vehicles. The GM EV1 (1996) was a landmark, however, it was recalled.
2000-Present: Tesla Motors has completely disrupted the electric vehicle market by focusing on performance, design, and battery range, and today, nearly all major automobile manufacturers are heavily investing in electric vehicle technology.
The electric vehicle (EV) derives its propulsion from electric batteries instead of gasoline or diesel, which is the primary difference from a traditional internal combustion engine (ICE) vehicle. What we refer to as an electric vehicle is the electric powertrain/s, which is a rechargeable battery and delivers clean and efficient transportation without fossil fuels.
The battery pack is the core of the energy system of an EV, which is constructed mainly out of lithium-ion cells. The worth of the battery pack is that it stores electrical energy for its drive system and delivers power to the electric motor. Batteries, pack capacities may vary by vehicle battery size according to the manufacturer, but larger battery packs mean longer driving range. You can attach EVs to outside electricity sources, such as at your home or public EV charging spots. It depends on the charger: you can be charged in under an hour with a DC charger, but a Level 2 charger can take hours.
EVs need to convert the direct current (DC) electrical energy in the battery pack with an inverter first to alternating current (AC). AC electrical energy is currently used to drive the electric motor to generate torque to move the vehicle in a given direction. EVs commonly use a single-speed gear reduction transmission, which is less complex than traditional ICE vehicles ' multi-speed transmission; hence, a mechanical system is simplified, and maintenance needs are also reduced. The takeoff and acceleration in EVs are smooth with instantaneous torque.
A unique part of electric vehicles is that they can slow down using regenerative braking. If you push the brake or let off the gas, the system will make you slow down more quickly. After that, the electric motor turns in reverse and assists in producing energy. In the old way, braking lost the vehicle’s energy as heat. With regenerative braking, the energy is turned into electricity and is fed back to the battery. As a result, less energy is needed, and the vehicle has a greater range.
Types |
Description |
Energy Source |
Battery Electric Vehicle (BEV) |
Fully electric, no fuel engine |
Battery only |
Plug-in Hybrid Electric Vehicle (PHEV) |
Combines an electric motor and an internal combustion engine; can be recharged |
Battery + Fuel |
Hybrid Electric Vehicle (HEV) |
Uses an electric motor to assist ICE, not rechargeable externally |
Fuel + Regenerative energy |
Fuel Cell Electric Vehicle (FCEV) |
Generates electricity from hydrogen gas |
Hydrogen fuel cells |
The organization and construction of Electric Vehicles (EVs) differ greatly from that of traditional vehicles with Internal Combustion Engine (ICE) engines. These components work in conjunction to afford isolated and locally sourced clean green transportation that will connect efficiently. Below is a description of how the main components work together to allow EVs to operate and be controlled:
The EV battery pack is like a fuel tank in any car, the batteries are the basic source of energy. A new generation of carbon-free liquid-fuel equivalent. They supply enough electricity to power the motor and run all the car’s electronic circuits. Most EVs use Lithium-ion batteries today, since they deliver a high amount of energy, last over time, and are efficient. A higher power pack kWh rating commonly means your battery will provide a longer driving range. Safety, top performance, and a long life for the batteries of an electric vehicle depend on the Battery Management System.
The electric motor is what converts electrical energy to mechanical energy and provides power to move the vehicle. There are a multitude of motors available for use in EVs:
AC Induction Motor: is utilized because of its robust construction and low price, used by every Tesla vehicle in earlier versions.
Permanent Magnet Synchronous Motor (PMSM): Found for its high efficiencies and compact design; used widely in EVs today.
Brushless DC Motor (BLDC): Marries the best attributes of both AC and DC motors; provides high torque, efficiency, and is ideal to use in smaller vehicles.
The job of the inverter is to change the DC battery’s current to AC so that the electric motor can use it. The inverter will also change the AC into DC during regenerative braking, so the power goes back to the battery. The inverter will likewise convert the AC to DC during regenerative braking to be sent back to the battery. The inverter controls how much power to send to the motor by changing the frequency and voltage of the AC supply.
The onboard charger is responsible for taking in electricity when the EV is plugged into a charging station. It will convert the grid's AC power into DC suitable for the battery. The ratings of the chargers' power can dictate the speed at which the battery will charge. Higher kilowatt ratings will allow one to charge the battery sooner.
The thermal management system controls the temperature of vital components such as the battery, inverter, and motor to provide optimal operating conditions. Thermal management systems will have cooling circuits, pumps, and in some instances heating elements. With the right thermal management, there are no upsets in system behavior, fragile components are kept safe, and temperatures are controlled so going too high or too low because of harsh ambient conditions is avoided.
For many automakers, the controller is the brain of an EV because it supervises nearly all of the vehicle's systems. The controller manages the speed of the vehicle, how much torque is generated, regains energy through braking, and allocates power to each part. The controller gets input information from the vehicle accelerator, brake pedal, and a variety of on-board sensors, and applies efficiency commands to the vehicle to ensure smooth operation and optimal performance.
Charging Level |
Voltage |
Time Required |
Typical Use |
Level 1 |
120V |
8-20 hours |
Home |
Level 2 |
240V |
4-8 hours |
Home/Public |
Level 3 (DC Fast Charging) |
400V+ |
30 mins to 1 hour |
Commercial |
Rather than ordinary gas or diesel cars, EVs are better in many different ways. EVs are better for the environment, cost less, and are much more comfortable to operate.
Because there is no tailpipe, EVs have no air emissions when driving. Once again, this keeps the air cleaner and is also an advantage for cities. And if you charge your EV from solar, wind, or other clean energy, it helps reduce the disease rate and the levels of global warming since it doesn't create toxic gases like carbon dioxide.
It is normally cheaper to drive an EV rather than a fuel car. Electricity is cheaper than gasoline, and EVs have fewer moving parts and, therefore, less maintenance costs. For example, you are not getting oil changes, and you also will not have engine issues. In the long run, this can lead to substantial cost savings.
EVs will provide a fast and smooth drive. The beauty of an EV is that the motor provides power instantly; therefore, you do not need to wait for the engine to rev up or change gears, and there is no noise, providing a smoother experience for you, as well as reducing, in a smaller way, the impact of noise pollution on roads.
By using EVs, we lessen our reliance on imported oil and fossil fuels. Since our nation can produce electricity in several ways, it could mean we depend less on other countries for fuel, become more energy secure, and save money on our fuel needs.
Countries everywhere are providing benefits to encourage both consumers and businesses to use electric vehicles. There are incentives such as lower taxes, money back, reserved parking, no highway tolls, and free rides in HOV and carpool lanes. With these offers, it’s easier to own and drive electric vehicles.
Within the next decade, the technology for electric vehicles will undergo developments previously not considered possible:
Higher energy density
Faster charging rates & longer life span
Convenient and easy charging with no bother of cables
EVs could double as mobile grid storage
A combination of electrification and driverless technology
Less carbon footprint in electric vehicle manufacturing
Technology will incorporate recycled materials or green materials
Electric vehicles (EVs) are far more than a trend; they're the future of transportation. Because they provide a cleaner, more efficient way of traveling, EVs help to reduce pollution and simply our dependence on fossil fuels as which is critical in protecting the environment. Better battery technology has greatly improved the consumer purchase price and capabilities of an EV, with improved driving ranges and charging times.
Although there are issues regarding the battery production problem (the costs) and the availability of charging stations, and there are ongoing efforts of innovation and investments in those issues, EVs are becoming the preferred transportation option globally.
More concisely, EVs are also propelling us to a cleaner, smarter, and more sustainable future, transforming the way we move, while equally protecting the planet and its people for generations to come.
Hi Everyone! Glad to have you on board. Thank you for clicking this read. In this post today, I’ll cover the Role of Cloud Computing in IoT.
Digital transformation has gained momentum in the past few years, the reason traditional technologies are becoming obsolete over time. Now organizations are incorporating modern technologies into their business model at an accelerated pace. These technologies produce the influx of data and at times it becomes very difficult to process and handle that data, thanks to cloud computing that has made the handling of data easy and effective. You don’t need traditional data centers anymore to store and process information. Everything will be taken care of remotely in the cloud with data centers.
Not to mention, this is the era of automation. Companies strive to accommodate automation in the activities of their business so they can achieve maximum output without the interference of humans. And this trend complements the arrival of IoT (internet of things). The IoT is nothing but a data source and cloud computing is used to store and process that data. We’ll touch on this further in this article.
Scroll on.
Both cloud computing and IoT are separate terms but can work together for better efficiency and productivity. The former is an architecture that offers on-demand computing resources to the end-users to process, store and handle data over the internet while the latter is a technology that acts as a data source from where data is produced. In simple words, IoT (internet of things) is a network of ‘things’ like physical objects, humans, and machines connected and collect and exchange data in real-time through embedded sensors. For instance, a human with a heart monitoring device and a car with sensors that send an instant alert to the driver for any danger fall under the umbrella of IoT.
According to Statista, “the total Internet of Things (IoT) connected devices worldwide is expected to reach 30.9 billion units by 2025, compared to 13.8 billion units that were expected in 2021.”
This projects that billions of devices connected will produce enormous data which makes cloud computing a major part of the IoT technology. Both IoT and cloud computing are inseparable and make an effective integration. In the following, we’ll stretch on this further.
As touched on earlier, IoT devices are connected with each other and can produce a flood of data that needs to be handled and processed somewhere. Cloud computing serves that purpose. If IoT devices are connected with traditional data centers, it takes a capital investment to install, manage, scale and upgrade machines on-premises to handle that data. While with cloud computing, virtual infrastructure is created that allows the developers to access and handle computing resources remotely without having to worry about the management of on-site IT infrastructure.
There are cloud service providers that offer cloud computing services to end-users. The common service providers include AWS (Amazon Web Services), Google Cloud, and Alibaba Cloud. The computing capabilities they offer are virtually endless that can effectively process and store the information produced by IoT devices. These providers commonly offer pay-as-you-go service which means you can scale up or scale down the resources as per the requirement of connected IoT devices.
Cloud computing and IoT are not the same but they complement each other. The following are the main advantages of combining IoT data with cloud computing infrastructure.
Security is the top priority for any organization to run its business activities successfully. And when companies use cloud computing to their advantage, it gives them a sense of security because your data is processed and stored in remote data centers managed globally. The cloud service providers have a network of servers located at multiple locations which means your data is not stored at one data center, instead, the system creates files of your data at multiple locations in different data centers. If one server goes down, you can get a copy of data from another server.
Whether you pick private cloud or public cloud is another parameter to guarantee the security of your sensitive data. This is how it works – companies use the public cloud for storing a large amount of data and the private cloud to process sensitive data locally. If you want to keep your IoT safe and secure, you can pick a private cloud for this purpose.
Cloud makes IoT data easily accessible which means you can remotely access information produced by IoT devices from anywhere in the world. Quick and on-spot data access is crucial when it comes to monitoring information gained by connected IoT devices. In IoT technology, we often get continuous readings from the attached sensors and that readings need to be stored and monitored quickly to make instant decisions.
To stretch this further, you can even use edge computing (which is the extension of cloud computing) to your advantage for handling IoT data. The difference between edge computing and cloud computing is the time it takes to process the information. In edge computing, data doesn’t go to the cloud, instead, it goes to the edge device installed near the data source which takes less time to process it.
IoT-based businesses often pick cloud computing to speed up their business operations. Since on-site IT infrastructure is costly and requires up-front payment for the management of traditional data centers. While cloud models remove the hassle of hardware maintenance and give you the flexibility to pick the pricing package best suitable for your business needs.
The following are the frequently asked questions when it comes to integrating IoT with cloud computing.
Technically speaking the answer is no and yes. NO, if you want to locally process your data in on-site IT infrastructure. YES, if you want to leverage the cloud since it’s preferable to pick the cloud model when there is a flood of information to be handled and stored.
There are four different cloud models named public cloud, private cloud, hybrid cloud, and community cloud. You can pick any model based on your business needs and requirements. It all depends on the type of data you want to manage and store. For sensitive information to manage, you can prefer the private cloud model, and for non-sensitive, you can opt for the public cloud model. A hybrid model is another option that gives you the option to integrate both private and public clouds into your business.
It depends on the requirement of IT infrastructure. Do your current IT requirements constantly change over the year? Do local data centers cost you more? What is the type of data? The number of connected IoT devices? These are the main questions you need to ask if you need a cloud model or not. This cloud architecture is mainly suited for you if want cost-effective and reliable solutions to handle enormous data.
Technology is evolving and every business uniquely works to keep up with the pace of this technology.
Billions of devices are expected to be connected through IoT technology, the information produced by these devices is difficult to handle if you apply the traditional approach to handle and process that information.
As the demand to handle and manage a data grows, organizations will integrate cloud computing into their business models.
And on-demand availability with cloud computing is what makes this model more attractive since this way you can monitor and access your information remotely from anywhere in the world. This trend will complement the usage of more IoT devices in the cloud computing model.
It is safe to say that cloud computing is expected to open new and flexible opportunities for IoT-based businesses to handle, store and process a bulk of data.
That’s all for today. Hope you loved reading this article. If you’re unsure or have any questions, you can ask me in the section below. I’d love to help you the best way I can. Feel free to share your experience with the IoT and cloud computing integration. Thank you for reading this article.
However, today we will focus on the additive manufacturing technique and what you should look for during your search. Numerous businesses embrace the technology by delegating tasks to professional 3D printing services.
In the globally competitive environment, adding a supply partner to the company's value chain is the way to go because the technology is capital-intensive to implement. To help more businesses adopt the technology, we've created a simple guide to help them select the best 3D printing solutions partners.
Working with a 3D printing provider gives you direct exposure to a broad scope of 3D printing technologies. A 3D printing service can handle a wide range of industrial projects thanks to its extensive capabilities. As a result, one of the essential criteria in selecting the best 3D printing service for you is the wide variety of current technologies.
The service provider has significant expert knowledge in all technologies due to their broader technology scope. As a result, they can recommend and help consumers with the technology that will help them get the most out of their initiatives.
Choosing a 3D printing service isn't complete without considering the materials. Material considerations play an essential role in decision-making. Not all materials can be utilized successfully with all techniques.
Only some technologies can efficiently use solid materials. As a result, consider material availability when selecting a 3D printing service. The 3D printing service you hire should be experienced in printing with the required material.
The importance of design in 3D printing is frequently overlooked. While any design can be 3D printed, some can't be done well. Methods for additive manufacturing precepts should be used when designing for 3D printing.
A service agency must be aware of the difference and, as a result, strongly recommend or endorse design changes that are compatible with 3D printing. This compatibility can help customers save time, money, and materials while improving part effectiveness, longevity, and trustworthiness. As a result, choose a 3D printing service that specializes in design.
While contacting a 3D printing service with a wider variety of technologies is usually a good idea, it is not always the best option. Numerous service providers specialize in a specific area of expertise. This is commonly seen in medical and healthcare settings.
Medical implementations of 3D printing, as well as some aerospace implementations, must meet specific rules and regs. Service bureaus with FDA or ISO-approved amenities, technologies, materials, and procedures should be chosen for particular applications.
If you're working on a one-off 3D printing project, the 3D printing service you choose won't have an impact on your long-term work, product, or public image.
However, if you want to integrate 3D printing or outsource long-term work, finding the right 3D printing provider should be a priority.
Nowadays, more businesses across many industrial sectors adopt 3D printing as a viable alternative to subtractive manufacturing (acquiring machined parts online) and injection molding. We'll look at the benefits of 3D printing and how you can use this production method to benefit your company. Is it worthwhile to use 3D printing for your project?
One of the best aspects of 3d printing is the reduced labor costs. Operating costs heavily influence the quantity of money spent on building a structure. Whenever it comes to traditional manufacturing, production costs are incredibly high, and skilled machine operators are required. In 3D printers, however, all that is needed is for an operator to press a button, and the printer's automated process will take care of the rest. Furthermore, 3D printing is comparable to both small-scale and large-scale manufacturing.
Due to the speed and lower expenses of 3D printing, item life cycles are decreased. Organizations can improve and upgrade an item permitting them to convey better things in a more limited time.
3D printing permits the actual show of another item to clients and financial backers instead of passing it on to their minds, accordingly lessening the gamble of data being misconstrued or lost during communication.
It also enables low-cost test marketing, allowing prospective clients to provide feedback on a physical item without the risk of high upfront prototyping costs.
Traditional production techniques can lead to shoddy designs and, as a result, shoddy prototypes. Consider baking a cake where all of the ingredients are blended and mixed before being baked. If the ingredients were not extensively combined, the cake would have air bubbles or fail to bake thoroughly. The same thing can happen when using subtractive or injection techniques; quality isn't always guaranteed.
Because of the nature of 3D printing, it is possible to assemble a part or product step by step, resulting in improved design and higher quality parts/products.
Traditional manufacturing techniques are efficient at making dozens and dozens of identical items, but the models are devoid of life and repetitive.
While 3D printing allows designers to create unique models with limitless personalization, it also makes it easy to include unique features that customers demand. Meaning you can get precisely what you want after handing over your 3d printing quote to a form well-versed in this sector.
The majority of additive manufacturing's constraints relate to how to generate a print quickly enough to eliminate the need for support. As a result, developers are free to create intricate geometries and concepts.
3D printing is a cutting-edge technology that is preferable, cost-effective, speedier, more viable, adaptable, and environmentally friendly than previous generations. We currently reside in a fast-paced universe where everything needs to be done quickly, and 3D printing technology can help us turn our ideas to life; this is a massive advantage in the printing world.
JLCPCB (JiaLiChuang Co. Limited) is a worldwide PCB & PCBA Fabrication enterprise. It is a leading company in high-tech manufacturing products specializing in PCB and PCBA production. With over a decade of experience in PCB manufacturing JLCPCB has made over a million customers through online ordering by the customers of PCB manufacturing and PCBA production.
JLCPCB is a professional manufacturer of large-scale manufacturing of PCBs, well equipment, strict management, and superior quality. It deals with the production of all types of PCBs, Stencils, and SMT.
In this article, we are going to discuss widely how the company operates its ordering system of the PCBs by their customers for production through the online booking process.
Normally, SMT components are used in professional/industrial PCBs and JLCPCB offers the best SMT services. You should first check these JLCPCB SMT services to get an idea. Let me highlight its important points:
So, it's quite easy to order for manufacturing of Metal Core PCB on JLCPCB.
Ordering of PCB at JLCPCB is not a complicated process, since the system is user-friendly to every customer. The steps below show the steps to be followed when placing an order.
Register on the official site of JLCPCB, if you don’t have an account. if you already have an account just log in
After login into one account. It will display a home page with a quotation calendar that will display an ordering page. On the quotation calendar, the customer would be asked to enter the size of PCB which he/she requires, quantity, layers, and thickness of their choice
In this step, the customer is required to enter the PCB board details on the online calculator to get the price of the quoted items in step 2. Also, there is the minimum price which is the cheapest one for a particular PCB.
Then click to “Add your Gerber file” this will upload the file. There are written guidelines on how to generate different Gerber files in the best format on the well-known circuit design program found in the company industry. A very small customer ID is always added to the PCB ordered to distinguish the PCB order from all others.
If one wants to put it in a specific location you are required to indicate the location by adding a unique text like “PBCJLPBCJL”
The system will analyze the file Gerber to confirm the dimensions and layers of the board after uploading the Gerber file.
Then click the “Gerber viewer” to the design of the boards. Customers are advised to confirm the Gerber file carefully for any errors. After checking and confirming the errors and no problem is detected just click “save to cart” and continue to the next step
After saving to cart then click “add new item” if you want to order multiple PCBs repeat the same steps from the beginning as you add both of them to the cart.
Expand the cart and view all the details of the PCBs ordered, including the price of each one of them, its specifications, and all the number of PCBs ordered.
After viewing all the details in the cart and seeing all the PCBs you wanted click the “checkout securely” button
On the checkout, menu add your shipping address where are the PCBs are to be shipped. The country where the PCBs are shipped determines the rates. Also, the shipping options are found on the same page just below the address. The shipping methods available are DHL and Airmail both of them vary in their delivery time.
This is the payment method. JLCPCB offers two kinds of payment methods which include
When the order payment is made the company arranges the production where you can go through your “ACCOUNT” menu to track your order status.
Customers may sometimes feel the urge to add a new order to the existing order. This may be because may feel the items ordered are not enough or an increase in demand for the PCBs which were previously ordered
Here below we are going to go through the steps of how to add a new order to the existing order in JLCPCB.
STEP 1: log in to your account and locate the existing order.
When you log in the process will only go through if the existing order is still in the production process. If the order is finished and delivered you will not be allowed to add an order unless you make a fresh order.
STEP 2: You will open the ordering page, upload the Gerber file and add the items you want and click “combine”. Also, this will only appear if there is an extra shipping cost for the order added.
STEP 3: when you click “combine” a new order will be added to the existing order and you can check on its progress.
After placing your order and payment has been made successfully, you can track your order through your account on the company website. Let’s discuss the steps to track your orders.
Login to your account and account menu click order history. After clicking on order history it will direct you to a previously placed orders page where all your previous orders are listed indicating their current status
Once you open the product files column file review status will appear and also the order status in the order status column. Then click order details to learn more.
When you are put I am production-ready to be processed. Click the production progress to check the process.
Once the order has been put into production and processed shipment process takes place. Once the shipment process has started a shipment notification will be sent through your email advising you on the shipment status of your order and the shipping tracking number. One can also use the JLCPCB company website to track the parcel. While on the website click shipment tracking and all the details about your parcel and delivery time information will be displayed.
When the person ordering the PCBs does not specify on the solder mask bridge which is importantly required, it will be ignored. When doing the solder-resistance bridge a spacing between the pins needs to be 0.254mm and special notes on doing that are required.
Zip file attachments such as PDF files, EXCEL, DXF files, etc are ignored and PCB will be done according to the Gerber file provided. One should ensure the correct parameters are chosen and those needed to be converted into a Gerber file when placing your order. If otherwise, zip files attachment are important should be added to the remark field.
In the presence of plated slot or edge, they should not be longer than 6mm, and make a note about it when placing the order or the system will make it for you. In the case where no note is provided the company will assume it and make it in the normal process.
Since there is the use of different software by different clients to design the printed circuit board and the software where Gerber data is processed is not the same as the software used in designing the data it sometimes causes the software incompatibility problems to appear. Due to the reason of no warning notification when transferring and importing the data into the software so it is not easily noticeable and cannot be confirmed to the customers. This makes the company responsible for some of the problems caused by software incompatibility.
There are some marking that sometimes appears on the base material. This is because of some security issues and there is a way it can be removed. There is no track on which PCB will have the mark so all the PCBs have equal chances of having the marks. One should check from their side whether it is accepted while placing the order.
This tab is functional for reasons of reviewing the file quickly before paying for the order. Acts as the preview button on the website. At times the website causes errors when there is something wrong to display it exactly so it is advisable before placing the order to check the file carefully when you feel there is doubt.
The customer should ensure the v-cut line, cut out and millings are located on the same layer with the board outline. If not on the same layer with the board line it will not appear. It is advised when one is placing the order should check carefully because when it is missed due they are not in the same layer with the board outline the company will not be responsible.
When you want the silkscreen clear on the PCB board the width of the texts and space between letters should not be less than 0.15mm and a width of not less than 1mm. when outline is the font is made and the solid part is filled with lines the fillings then should not be less than 0.15mm. the company will not modify the silkscreen on the Gerber file but the text may be widened. If the text is not enough the company will not be responsible for any complaints made regarding unclear texts caused by nonstandard design.
JLCPCB company does not make 3 layer PCBs. If one orders a 4 layer PCB with a single inner layer, the company will process it with the 4 layer process directly and confirm with the customer again. So before placing an order confirm whether there is an inner layer miss or not.
This is the placing of orders same just as the previous one which had been successfully processed. With these orders, the company will not make any changes to the file which was used in the production. The customer should ensure not to leave any related note for the order to be changed while placing the order since the repeated order will not be checked manually by the engineers.
The board outline is used to show how the PCB will look like when made. So everything that needs to be included in the board should be cut out clearly on the board outline. You should avoid the least useful items to avoid confusion. When both the GKO layer and the GM1 layer are found on the Gerber file the engineers will ignore the GKO layer and make boards according to the GM1 layer. when GMI, GM2 or GM2, GM3, GM4 layers are in the Gerber file at the same time, engineers will go for the smallest number after the letter GM as the outline layer by default.
When you place an order to JLCPCB the JLCPCB panel will panel the order by default with the v-cut. JLCPCB only panels PCBs with rectangular and circle shapes. When you penalize the boards yourself but choose “Single PCB” when ordering, the numbers of designs/boards in the Gerber file should not be greater than 5, otherwise, we may cancel this order. If “Panel by Customer” has been chosen, the designs in the panelized Gerber file should not be greater than 10.
The remark field is used when you place your order so that you can leave a note in case of any import, but the company does not recommend the use of this option since all the orders with an English note will take a longer time to get through the audition process.
Large boards sometimes the company might consider them, but if the good board available can not meet the quantity like the one ordered on the website due to the high cost of production they will ship the good boards and refund the difference to you.
The recommended thickness design of boards outlined by the company is 0.15mm. in a case when the board is greater than 0.15mm the centerline will be followed to make the board outline
Orders missing crucial information such as the board outline, solder mask layer the order will be canceled out clearly during the audit process.
Orders beyond the company and engineers’ capabilities, will be canceled directly and an email will be sent to inform you about the reason. So before placing an order kindly check your file carefully before you pay for the order to save the loss due to the cancellation.
Order removal will not affect the functions of the boards if JLCPCB puts the order number at random or miss to remove. The removal of the order number will be refunded.
Easyeda is a free online tool that we provide to design the PCB, and you can place your order on JLCPCB easily and quickly. But if there is a manufacturer error due to the design error, we may not responsible for that.
When the silkscreen overlaps with the openings on the board surface, the principle of openings first will be put into consideration. we will ignore the silkscreen and make the openings on the boards only. In the case where you want to keep the silkscreen on the openings, kindly make a note in the remark column so that the company engineers and factories pay attention to it and meet the required standards.
solder mask clearance is larger than the copper pad it’s exposing, in most PCBs, these pads are known as Non-Solder Mask Defined pads (NSMD).
Some of the other components have another type of solder mask called Solder Mask Defined pad. Which has a clearance of solder mask that is smaller than the copper pad. One can suggest pad and solder mask clearance size in the datasheet when applying. One should ensure that at least 3 mils (0.076mm) of the mask will be printed on all sides of the copper pad. The reason is registration tolerance on the solder mask placement if the mask is smaller than the pad there are possibilities that the mask could move enough exposing bare substrate which will lead to bad results.
In the ordering system, there is no given option to add details on whether the board required has an SMD pad. If CAM engineers don’t get this kind of information the solder mask clearance for SMD pads will be enlarged to its default size.
When transferring SMD information to JLCPCB the following steps are used
On your account page in the ordering system, there is a text box called “PCB Remark”
Write a special instruction informing JLCPCB that your order design has an SMD pad
On clicking yes, the JLCPCB engineers will come up with a production file that is required to manufacture the PCB. When the production is put into consideration a check notification will appear where you can check and confirm it before reproduction. An email will be sent to you when the file is complete and ready for production. Download the processed Gerbers, pay attention to inspect the solder mask clearance for the SMD pads
and their able logistics partners make every step to deliver your PCBs faster.
JLCPCB is a good company since it provides great customer satisfaction, as long as you consider the time differences, and try to make orders with enough time to respond during your working days, and making orders, not near the weekend, they are well worth the money saved and the simple interface.
Their chat support is fairly good, and the assembly service is also mostly good.