Almost all the data captured from real world is in analog form. Analog sensors play an important role in sensing such parameters, be it the temperature of the room or vibrations produced by machines. In this post, we are going to create a small project to show you how to capture analog signal from Raspberry Pi 3 and visualize it for further analysis.
An analog signal is any continuous signal for which the time varying feature (variable) of the signal is a representation of some other time varying quantity, i.e., analogous to another time varying signal (Source Wikipedia).
In most cases, an analog signal is represented by a continuous signal plotted on an x-y graph. The x-axis represents time and y-axis represents the dimension of a physical parameter.
Within the analog world, we use different sensors to measure various physical parameters such as color, chemical reaction, pressure, temperature, position, force, proximity, presence, flow, light, sound, speed, magnetic & electric field, etc. These parameters play a significant role in a large industrial setup where we need to track a multitude of equipment to make the system work efficiently as a whole.
Let’s have a look at the hardware components that we are going to use for capturing analog signal.
Raspberry Pi is the credit card sized computer which has rich peripherals to interface various sensors. The Raspberry Pi does not have inbuilt ADC module but has rich features of serial communication SPI, UART, I2S, I2C, etc. So for applications where analog signal is input, we need an ADC(Analog to Digital Converter) Chip to read analog values from the sensors.
MCP3008 is a low cost SPI-based 8-channel 10-bit analog to digital Converter. This module is appropriate for the single ended and differential input analog sensors such as LDR, Temperature, 3 Axis accelerometer etc.,
The precision of this ADC module is similar to any of 8 bit micro-controllers and the module provides 8 channels with SPI Interface.
MCP3008 Pin Out
A potentiometer is a simple knob that provides a variable resistance, which we can read as an analog voltage value. It has three pins to which we connect three wires as follows,
By turning the shaft of the potentiometer, we change the amount of resistance on either side of the wiper which connects to the center pin of the potentiometer. This changes the relative “closeness” of that pin to 3.3 volts (Vcc) and ground, giving us a different analog voltage input. When the shaft is turned all the way in one direction, there is 0 volt going to the pin. Turning it all the way in other direction results in 3.3 volts of input going to the pin. When connected to MCP3008, this analog voltage in the range of 0 to 3.3 volts is proportionately sensed as a number between 0 and 1023, therefore giving us a digital output.
For visualizing the data captured through analog signals, we will use Thingspeak. We need a registered account with Thingspeak and set it up for our project.
Now we are ready to setup the hardware. Follow the schematic and make the connection between the Raspberry Pi, MCP3008 and Potentiometer.
Make sure that the connection are given as per the schematic.
We are now ready to execute the project.
The application software for this program is written in python and is available under GitHub.
Before executing the program, make sure to follow the steps provided in the repository README file to setup Raspberry Pi for SPi communication.
Follow the steps below to execute the project.
I encourage you to try your hands on this setup. Also please share your experiences or any particular challenges that you might have faced in executing this setup. If u have any technical doubts then you can post your comment below and I will get back to you.
Surya is a hardware buff and tinkerer who loves all the stuff around IoT. He is a specialist in building proof-of-concepts around electronic hardware and conceptualizing use cases and solutions for Internet of Things. When not working with hardware, Surya can still be found fiddling with some crazy hardware design, trying to bring out an idea out of a raw circuit.
IoT Testing Tools & Methodologies for Building Resilient IoT Platforms
Kitchen Inventory Management with Smart Jar
IoT Intelligent Transportation Systems with Twilio Sync
An IoT Retrofit Suite For Professional DIYers
This Alexa Powered Dictionary Bot Can Expedite Your Vocabulary Buildup
Please log in again. The login page will open in a new window. After logging in you can close it and return to this page.