Introduction: Plotting-real-time-sound-sensor-data-from-Arduino-using-Python

Picture of Plotting-real-time-sound-sensor-data-from-Arduino-using-Python

Introduction to Project:

In this Project we are going to interface sound sensor to Arduino. and then we are going to plot the graph of those analog values using python. For that purpose we have connected our Arduino to Raspberry pi. So here Arduino is throwing data to raspberry pi through it's serial port and we are using one python script in raspberry pi to plot the graph of those analog values.

Step 1: Installation of All Software

Picture of Installation of All Software

1) Raspbian OS:

This is the recommended os for raspberry pi. You can also installed other OS from third party. Raspbian OS is debian based OS. We can install it from noobs installer. you can Download here

2) Python idle:

This is the software we get in raspbian os. For this project we have used python script.

3) Arduino IDE:

You can download the latest Arduino IDE from this link: https://www.arduino.cc/en/Main/Software

Step 2: Component Used

Picture of Component Used

1) Raspberry pi 3

2) Arduino UNO

3) Sound Sensor

4) Jumper Wire

1) Raspberry pi 3:

This is the latest version of raspberry pi. In this we have inbuilt Bluetooth and wi-fi, unlike previously we have to use Wi-Fi dongle in one of its usb port. There are total 40 pins in RPI3. Of the 40 pins, 26 are GPIO pins and the others are power or ground pins (plus two ID EEPROM pins.)There are 4 USB Port and 1 Ethernet slot, one HDMI port, 1 audio output port and 1 micro usb port and also many other things you can see the diagram on right side. And also we have one micro sd card slot wherein we have to installed the recommended Operating system on micro sd card. There are two ways to interact with your raspberry pi. Either you can interact directly through HDMI port by connecting HDMI to VGA cable, and keyboard and mouse or else you can interact from any system through SSH(Secure Shell). (For example in windows you can interact from putty ssh.) Figure is given above.

2) Arduino UNO:

Arduino/Genuino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.

3) Sound Sensor:

Sound Sensor can detect the sound intensity of the environment. The main component of the module is a simple microphone, which is based on electret microphone. This module’s output is analog and can be easily sampled and tested.

Step 3: Circuit Diagram

Picture of Circuit Diagram

Circuit Diagram of this project is given above.

Here are the connections of our First figure

Arduino Sound Sensor

GND----------GND

3.5 v-----------Vcc

AO-------------OUT

In second figure Arduino directly connected with Raspberry Pi

Step 4: Working of Plot

Picture of Working of Plot

Here are the command to install graph plot on raspberry pi:

sudo apt-get install python-matplotlib
sudo apt-get install python-pip

sudo pip install drawnow

sudo pip install pyserial

After installation you can run python script i.e plotArduino.py

you run that file and get the output like above figure

Step 5: Code for Project

We already posted our source code of this project in github

we've given our level of best to make you understand this project. Still if you have any doubt feel free comment us below
So finally if all things will go well. Definitely you will enjoy this project.you also mail us on info@deligence.com.

Thanks & Regards,

Deligence Technologies

Comments

JuanO93 (author)2017-07-21

Hi friends,

Help please. It doesn´t work for me.

pi@raspberrypi:~ $ sudo pip install drawnow
Collecting drawnow
Downloading drawnow-0.71.3.tar.gz
Collecting matplotlib>=1.5 (from drawnow)
Downloading matplotlib-2.0.2.tar.gz (53.9MB)
99% |████████████████████████████████| 53.9MB 464kB/s eta 0:00:01Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 821, in unpack_url
hashes=hashes
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 659, in unpack_http_url
hashes)
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "/usr/local/lib/python2.7/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks
for chunk in chunks:
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 571, in written_chunks
for chunk in chunks:
File "/usr/local/lib/python2.7/dist-packages/pip/utils/ui.py", line 139, in iter
for x in it:
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 560, in resp_read
decode_content=False):
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 314, in read
data = self._fp.read(amt)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 63, in read
self._close()
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 50, in _close
self.__callback(self.__buf.getvalue())
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/controller.py", line 275, in cache_response
self.serializer.dumps(request, response, body=body),
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py", line 87, in dumps
).encode("utf8"),
MemoryError

the_3d6 (author)2017-06-29

Nice! In your code on github, sample rate is one reading per second. How fast this approach can actually work? What is its speed limit?

About This Instructable

713views

17favorites

License:

Bio: We are a team of IoT & Embedded Systems developers. We are working in Raspberry Pi and Arduino.
More by deligence:Over the Air(OTA) Update of Nodemcu(esp8266) Using MQTT)Raspberry Pi Web GPIO With Live Streaming Creating a Virtual World  Using Arduino and Python
Add instructable to: