Sensing Devices in Embedded C code

Spread the love

Sensing devices also known as sensors is widely used in almost all applications of embedded systems whether it be Rain sensing wipers in cars or sensing an upcoming missile from opponent. Sensors are everywhere. The use of sensors is to minimize human efforts and efficiently use the time so that upcoming situation can be handled well in advance.

Today a large variety of sensors are connected through internet, this field is booming by the name of IOT i.e. Internet of things. What happens in IOT is that sensors send the real time value of data to the system which can be collected by the user at any point of time provided with Internet connectivity at both ends.

Sensing Devices in Embedded C  code
Sensing Devices in Embedded C code

which is Sensing Devices in Embedded

Now to gather the information provided by the sensor, we need to program the sensors and microcontroller or microprocessor by a means of language which is understood by the computer. Here the gap is bridged by using a variety of Programming languages like Python, C, assembly, etc. Widely Embedded C is used. C language when used in the application of Embedded System is referred to Embedded C.

As we discussed in the above section (ADC0808), sensors send the values in analog but computers only understand Binary i.e. the digital language. So we need an interfacing medium that is ADC’s which we have studied above.

Apart from ADC we need a sensing medium which is created after a lot of research and practice which actually senses the physical aspect of the environment and convert into useful graphs which can be later processed by the microcontroller.

For eg. as you can see in the image of the MQ-135 Gas sensor , this is the main sensor, which extracts the data of air quality in the form of graph and later sampled to create an array of binary values. So to interface the tis gas sensor to the microcontroller we need to first study the data sheet, Pin description to understand the requirements of the device. After that we need to create libraries or function that would extract the data from physical world and give it back to us in the usable form.

Once we have all the resources we can start programming. In programming first we need to assign all the pins to the microcontroller bins so that we can communicate it later easily.(Usually we use Sbit ) Next step is to write the function and set values of register as per preference. Now we need to run the function and display the value. Now there are 2 ways to display – Serial Monitor or LCD displays. LCD displays are used when building an autonomous system. Serial Monitor is usually used for testing circuits. So we need to display it on LCD we need to write a code again to interface with microcontroller. We can use a library in case of Arduino which is a development board. So instead of writing code in binary or assembly we use C language to ease out the difficulty of understanding of the code at user end. Because Human tend to learn C language easily as compared to Binary or coding via instruction sets.

Summary :

In this article we learn Sensing Devices in Embedded C code so about this section you have any query then free to ask me

sachin Pagar

I am Mr. Sachin pagar Embedded software engineer, the founder of Sach Educational Support(Pythonslearning), a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Reply