HI-TECH NEPAL
Search This Blog
Friday, June 21, 2019
Retro Games with Raspberry Pi Retro Pie
Raspberry pi Projects
1,Play Retro Games with Raspberry Pi Retro Pie
In this Raspberry Pi Retro Pie tutorial, we will show you how to install the popular Retro Pie distribution to your Raspberry Pi and turn it into a retro gaming machine.
Using RetroPie, you can quickly turn your Raspberry Pi into a highly versatile retro gaming rig that is more than capable of running games for several systems such as the SNES, GBA, PS1, DOS and many more.
We will be showing you the process of installing and configuring RetroPie on your Raspberry Pi as well as how to copy roms to your Pi or connect it to a network drive.For those who do not know what RetroPie is, it is a software package that is built on top of the Raspbian operating system. The package contains a range of different software that will enable the ability to emulate and play classic games.
RetroPie makes use of EmulationStation as its visual front end and uses the RetroArch project and various other emulator projects to emulate your games.
There are other emulator software packages that you can use instead of RetroPie. Be sure to check them out if you’re feeling adventurous.
Equipment
Below is all the equipment that you will need for setting up RetroPie on your Raspberry Pi.Recommended
Raspberry Pi (I recommend the latest for the best experience)Micro SD Card
USB Keyboard
USB Mouse
HDMI Cable
Optional
Retro USB Controllers or JoysticksEthernet Cord or Wifi dongle
Video
In this video guide, we walk you through the process of installing, setting up, and running a retro game using the RetroPie emulator package.Below we have included a more in-depth guide on setting up RetroPie step by step.
Can’t see the video? Support us by disabling your adblocker.
Installing RetroPie from Image
1. The first thing we need to do is obtain a copy of the RetroPie image for the Raspberry Pi.You can find the available pre-built RetroPie images from the official RetroPie GitHub repository.
On this page, you should see the latest available release with a few download links near the bottom of the page. You will need to select the right image for your Raspberry Pi.
If you are using a Raspberry Pi 1 or a Raspberry Pi Zero, then download the “rpi1_zero.img.gz” file.
If you are using a Raspberry Pi 3 or newer, then download the “rpi2_rpi3.img.gz” file.
This image is a pre-built version of Raspbian Stretch that has RetroPie already set up on it and is one of the easiest ways to get the emulators running on your Raspberry Pi quickly.
If you would prefer you can setup RetroPie on your current installation, but we will go into those steps in another section.
2. Now that we have the RetroPie image, we will need to write the image to an SD Card that we are going to use with the Raspberry Pi.
To do this, we will be making use of a tool called “Etcher“. This tool will format the SD card and write the RetroPie image to it.
You can download Etcher by going to Etcher’s official website.
Once downloaded, install, and open the Etcher software.
3. With the Etcher software open, and the SD card connected to your computer, you can now start the process of writing the RetroPie image to it.
To begin this process click the “Select Image” button as shown below. In the dialog box that appears, find and select the RetroPie image that you previously downloaded.
![Etcher Select RetroPie Image](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-Etcher-01-Select-Image.png)
4. With the RetroPie image selected, now go ahead and click the “Select drive” button.
This button will bring up a dialog asking you to select the drive that you would like to write the RetroPie image.
Make sure the one you choose is, in fact, your SD card as it will erase all data on that drive.
![Etcher Select Drive](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-Etcher-02-Select-Drive.png)
5. Now with the right image selected and the correct drive selected, you can now proceed to flash the SD Card by clicking the “Flash!” button.
![Etcher Flash Drive](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-Etcher-03-Flash-Drive.png)
Installing RetroPie from Scratch
If you decide that you would like to install RetroPie from scratch and not use the prebuilt image provided by the RetroPie team, then you can follow the instructions below.Please note that it is recommended to use the prebuilt image as it comes with several things already setup and configured. You are also less likely to run into configuration issues from the beginning.
1. Before you begin, we will need to ensure that we have at least 2GB free on the Raspberry Pi’s SD Card for the RetroPie software to be able to install everything it needs.
If you are unsure if you have enough free space available on your Raspberry Pi’s SD Card, you can go ahead and use the following command.
df -h
Below is an example of the output provided by the df -h command.Filesystem Size Used Avail Use% Mounted on
/dev/root 59G 1.6G 55G 3% /
You need to pay attention to the “/dev/root” filesystem, and the amount of space available under the “avail” column. As long as this is greater than “2G” you are free to proceed with installing RetroPie.2. Now before we go ahead and install the RetroPie software package, we should first ensure that our Raspberry Pi is running up to date software.
We can achieve this by running the following two commands on the Raspberry Pi.
sudo apt-get update
sudo apt-get dist-upgrade
We use the “dist-upgrade” command instead of the usual “upgrade” command as it ensures packages are updated to their latest version and will install new packages required by an upgrade.3. With the Raspberry Pi’s operating system now up to date, we can now install the packages that the RetroPie setup script requires to operate.
One of the packages we need is the “dialog” package which is used by the RetroPie software script to build shell script dialog boxes.
The other package we need is the “git” package. We use this package to clone the setup script repository to our Raspberry Pi.
Install both of these packages by running the command below.
sudo apt-get install -y git dialog
4. Now that we have installed all the packages that we need, we now go ahead and use the git software to clone the RetroPie setup script.Enter the following two commands to clone the RetroPie setup script to your Raspberry Pi users home directory.
cd
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
5. We can now change directory to the “RetroPie-setup” folder. This folder was created when we cloned the RetroPie setup script repository in the previous step.After we change into the directory, we can go ahead and run the actual RetroPie setup script.
This script will run through the process of installing all packages required for the EmulationStation software as well as a few basic emulators.
You can do all of this by running the following two commands on your Raspberry Pi.
cd RetroPie-Setup
sudo ./retropie_setup.sh
6. You should now be seeing the RetroPie setup dialog on your display.This dialog has a variety of different options, but the one we want to pay attention to is the “Basic Install” option. This option will be used to install all the “core” and “main” packages of RetroPie.
Select this option by using the arrow keys to navigate to it and using the enter button to select it.
![Raspberry Pi RetroPie Basic Install](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Basic-Install.png)
7. Next, you will be presented with a screen asking you to confirm whether you want to install the “Core” and “Main” branches of RetroPie.
Select “Yes” to this option to begin the RetroPie installation process. Please note that this process can take some time as your Raspberry Pi we need to download and install numerous packages.
![RetroPie Basic Install Confirm Screen](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Basic-install-confirm-screen.png)
8. Once the installation process has completed, you will be taken back to the main menu of the Retropie setup script.
The next step of setting up our Raspberry Pi with RetroPie is to allow it to autostart the emulation station software. Lucky for us this is a relatively simple process as the Retropie setup script handles it.
To proceed with enabling autostart, go into the “Configuration / Tools” menu.
![Raspberry Pi RetroPie - RetroPie Setup - Configuration Tools](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Configuration-Tools.png)
9. Within the “Configuration / Tools” menu you will need to find and select the “autostart” option
![RetroPie Setup Autostart](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Autostart.png)
10. Within this menu, you will want to select the first option labeled “Start Emulation Station at boot“.
This option will make the EmulationStation frontend for RetroPie boot up when the Raspberry Pi powers on. This option saves you from needing to start the software manually.
![RetroPie Start Emulation at Boot](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-start-emulation-at-boot.png)
11. Once selected, we can now restart our Raspberry Pi to make sure everything is working as it should be.
Start by pressing “ESC” until you get back to the main menu.
Once on the main menu, select the “Perform reboot” option to reboot the Raspberry Pi.
![RetroPie Restart](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Perform-Restart.png)
Upon rebooting the Raspberry Pi should end up showing the EmulationStation startup screen. This screen indicates that you have successfully setup the RetroPie software on your Raspberry Pi.
Adding ROMS for the Raspberry Pi RetroPie Emulators
ROM is short for read-only memory and is the format in which you will find pretty much all the classic games.![Raspberry Pi RetroPie Emulator](https://cdn.pimylifeup.com/wp-content/uploads/2014/11/Raspberry-Pi-Emulator-1024x682-e1559900456231.jpg)
ROMs can be easily found on the internet and since there many different sources it’s best just to google the game you wish to download followed by ROM, e.g. (“Doom ROM”).
There are three different primary methods for transferring ROMS over to your RetroPie, this being USB, SFTP, and SAMBA. We will explore all three different methods below.
Copying ROMs from a USB Drive
1. Before we get started, we need to make sure that the USB service is enabled on RetroPie. If it’s not, then this guide will fail to work as it relies on it to scan and create folders on our USB drive.Let’s get started by going to the configuration screen within RetroPie. Within this screen, select the “RETROPIE SETUP” option to get into the RetroPie setup tool.
2. We should first ensure that we are running the latest version of the RetroPie setup script by selecting the “Update RetroPie-Setup script“.
3. Within the RetroPie setup tool, go to the “Manage Packages” submenu.
Within here, you will need to go into the “Manage optional packages” menu.
In this menu, search for the “usbromservice” and select it.
Finally, select the “Install from binary” option to install the USB rom service to your Raspberry Pi.
4. With the “usbromservice” now installed and the menu still up, go ahead and select the “Configuration / Options” menu.
Within this menu, select the “Enable USB ROM Service scripts“. This option will setup all the scripts that will monitor the USB devices plugged into the Raspberry Pi.
5. Once done, head back to the main menu of the RetroPie setup tool and select the “Perform Restart” option.
6. With everything set up on the Raspberry Pi, we need to ensure now that the USB drive that you want to use is formatted to the FAT32 format.
You can check this on Windows by right-clicking on the drive, clicking “Properties” and looking at the text next to “File System:“.
![Raspberry Pi RetroPie - Windows - FIlesystem Type](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-Windows-FIlesystem-Type.png)
7. On the USB, create a directory called “retropie“.
The RetroPie USB Rom service software will detect this folder when the USB is plugged in and will prepare the directory for copying over ROMS by creating several folders within it.
![Raspberry Pi RetroPie - Windows - Create retropie Folder](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-Windows-Create-retropie-Folder.png)
8. Now plug the USB into the Raspberry Pi, give this a few minutes as the Raspberry Pi RetroPie software will be setting it up in preparation for copying over ROMS.
If your USB has a flashing light, wait until it has stopped flashing before you pull it out.
If it doesn’t have a light, then wait a few minutes for the job to complete.
9. Now take out the USB from the Raspberry Pi and plug it back into the computer.
10. Add the ROMS to their respective folders on the USB.
These folders will be in the retropie/roms folder. (Eg. retropie/roms/snes)
Below we have included a screenshot of what the folder layout should look like after the RetroPie software has created all the needed folders.
![Raspberry Pi RetroPie - Windows - RetropPie folder with generated folders](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-Windows-RetropPie-folder-with-generated-folders.png)
11. Once you have finished copying your ROMs to the USB, plug it back into the Raspberry Pi.
The RetroPie software will immediately start copying these files off of the USB drive. Don’t take out your USB for some time as this process can take considerable time.
12. Refresh EmulationStation by pressing F4, or choosing “quit” from the start menu.
Copying ROMS over SFTP
1. Before you can utilize SFTP to transfer files between your computer and the Raspberry Pi, you will need first to enable SSH.You can do this by going to the RetroPie “Configuration” menu within the Emulation Station UI. Within this menu, select “RASPI-CONFIG“.
2. Within the Raspberry configuration tool go to “5 Interfacing Options“, then within that menu select “P2 SSH“.
When asked if you would like to enable the SSH server, select “<Yes>“.
You can now select “<Finish>” on the main menu to return to the RetroPie interface.
3. For copying files over SFTP, you will need to utilize a program such as WinSCP to connect to the Raspberry Pi if you are running Mac use something like Cyberduck.
On Windows, go to WinSCP’s download page and download the latest version of WinSCP.
WinSCP is the tool that will interact with the Raspberry Pi and allow us to copy files directly to the Raspberry Pi.
For those who are running a Mac OS X device, you can find the Cyberduck software within the Mac App Store or by downloading it from Cyberducks website.
For this guide, we will be just be focusing on utilizing the WinSCP software, but the connection details will all remain the same.
4. Once downloaded, launch the WinSCP software. It will immediately ask you for new login details.
You will need to enter the following details into the correct fields.
File Protocol: SFTP
IP address: To find the IP address of your RetroPie, go into RetroPie options from the main menu, and select the last option “Show IP address“.
Port Number: 22 (default)
Username: pi (default)
Password: raspberry (default)
![WinSCP Connect to Raspberry Pi RetroPi](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-WinSCP-Connect-to-Pi.png)
5. Once successfully connected to your Raspberry Pi Retropie, you should pay attention to the right-hand side screen.
Locate the folder named “RetroPie“, double-click on that, once within that folder locate the folder named “Roms” and double-click again to enter that folder.
You should now be sitting in the directory where all your roms will be stored.
The file directory displayed at the top should be something like /home/pi/RetroPie/roms.
![WinSCP ROM folder list](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-WinSCP-folder-list.png)
6. Once in the correct folder, all you need to do is drop the files into the appropriate folder for your console.
For example, for a SNES game, you would drag and drop the file onto the folder named “snes“.
The WinSCP software will immediately begin to copy the files you dropped over into the folder. This process can take some time depending on both your hard drive and network speeds.
7. Back on your Raspberry Pi, you can refresh the Emulation Station software by pressing F4, or choosing “quit” from the start menu and relaunching the software.
Your new roms may not show up without refreshing the EmulationStation software.
Copying ROMs over Samba Network shares
A clean installation of RetroPie from their precompiled images has “Samba” pre-installed and enabled by default.However, if you installed this on Raspbian separately and not from the RetroPie image, you will need to enable it manually.
Samba is the interface that allows Linux and Mac-based devices to connect with Microsoft’s shared network devices interface.
The Samba interface allows you to access the files on your Raspberry Pi over the network without needing to connect with something like WinSCP.
1. If you are running a clean install from the RetroPie image, then you can skip to step 6 of this tutorial.
Otherwise, if you have installed RetroPie to a pre-existing Raspbian installation, you will need to go through a few extra steps to set up this.
To get to the RetroPie setup tool, go to the “Configuration” menu, and select the “RETROPIE SETUP” option.
2. Once the setup script is loaded on your Raspberry Pi, you will be greeted by numerous different options.
Within this menu, find and select the “Configuration / tools” option by using the arrow keys.
Once you have found the correct option and have it selected, you can press “ENTER” to load it.
![RetroPie Configuration Tools](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Configuration-Tools.png)
3. Within this menu, you need to search for the option labeled “samba“.
Once you have selected the “samba” option, press ENTER to prepare the Raspberry Pi for use with SAMBA.
![RetroPie SAMBA Install](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-SAMBA-Install.png)
4. Selecting this option will install all the packages required to set up and run Samba on your Raspberry Pi.
Once the Raspberry Pi has completed installing all the required packages, you will be met with another screen.
On this screen, you will need to select the “Install RetroPie Samba shares” option.
This option will automatically set up Samba on your Raspberry Pi to share the RetroPie related folders and allow network access to them.
![Raspberry Pi RetroPie - RetroPie Setup - Enable Samba Shares](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-RetroPie-Setup-Enable-Samba-Shares.png)
5. Once the Samba installation process has completed, you can now safely quit out of the RetroPie software.
There are two ways you can do this, one is to press the CTRL + C combo, and the other is to press ESC and select the “exit” option.
6. Now, back on your computer.
On Windows, open a file explorer window, and in the address bar type in the following.
Note: Make sure you swap out the IP address with your own Raspberry Pi’s IP address.
\\192.168.1.106
![Raspberry Pi RetroPie - SAMBA Network drive connected-](https://cdn.pimylifeup.com/wp-content/uploads/2019/06/Raspberry-Pi-RetroPie-SAMBA-Network-drive-connected-.png)
7. There is a chance it will ask for your login details for your Raspberry Pi.
Just enter your password and username. If you are still using the default user, that will be the following.
Username: pi
Password: raspberry
8. Once in, you can now copy any file you want to your Raspberry Pi.
For copying roms, you will want to go into “roms” and copy the file into the folder of the console it belongs with.
For instance, a SNES game will go in the folder called snes.
Connecting a Network Share to Load ROMs
1. Before you connect up a network share, you must first make sure you have your ROMs are sorted into the structure that the RetroPie software expects.You can find this folder structure on your Raspberry Pi by using SSH and running the following command.
ls ~/RetroPie/roms
Once
you have your ROMs sorted into folders of the same name, we can proceed
with connecting the file share with the RetroPie installation.2. The next thing we need to do is ensure that the Raspberry Pi is set to wait on the network before booting. This wait will ensure that the operating system can perform network connections when it starts up.
To do this, launch up the Raspberry Pi configuration tool by running the command below.
sudo raspi-config
3. Within this menu go to “3 Boot Options“, then select “B2 Wait for Network at Boot“.When prompted if you would like the boot to wait until a network connection is established, select “<Yes>“.
You can now safely back out of the Raspberry configuration tool.
4. Now with network boot enabled and your drive setup we can proceed to modify RetroPie’s autostart script so that it will automatically mount the drive upon booting.
To do this, we can start modifying the autostart script by running the command below.
sudo nano /opt/retropie/configs/all/autostart.sh
5. To the top of this file, add the following line.You will need to replace several bits of information in this line. We will explain each important bit.
<username> – This text is the username for a user that has access to your shared folder.
<password> – This text is the password to the user you specified.
//REMOTEHOST/roms – This is the network path to where you keep your roms, an example of a valid path is something like “//192.168.0.175/e/ROMs”
sudo mount -t cifs -o username="<username>",password="<password>",nounix,noserverino //REMOTEHOST/roms /home/pi/RetroPie/roms
Once done, go ahead and save the file by pressing CTRL + X followed by Y and then ENTER.6. Now that we have added the mounting line to the autostart file, we need to go ahead and restart the Raspberry Pi so that it will load in the data from stored on the shared drive.
We can restart the Raspberry Pi by running the command below.
sudo reboot
I
hope by the end of this Raspberry Pi RetroPie tutorial you are able to
load and play the classics you want. If you want to leave some feedback,
then please don’t hesitate to leave a comment below.
arduino projects..
Arduino Projects..
Arduino Projects with detailed step by step guide
1, Arduino Radar (Sonar)
This is one of my most popular project and it’s really fun to build. The radar can detect objects in front of it and map them on PC screen using the Processing IDE. processing codeFor this project you just need two components along with an Arduino board, and that’s an ultrasonic sensor and small servo motor. The range of the radar can be adjusted to up to 4 meters with 180 degrees rotation. arduino code
circuit diagram
Download Arduino Ide
Download Processing org
2, How to Flash the Firmware on Clone HM-10 BLE Module using Arduino Uno
How to Flash the Firmware on Clone HM-10 BLE Module using Arduino Uno
While using the BLE HM-10 module,
you must encounter some really frustrating problems like you cannot
send or receive AT commands, or you cannot pair HM-10 with Smart Phone.
If you encounter these problems, then your BLE HM-10 module is surely a
Cloned HM-10 Module. Yes, you heard it right, the Cloned HM-10 module.
However after flashing it with genuine firmware it acts like a genuine
BLE HM10 module and can be used as original Bluetooth module. Here we
have interfaced HM10 BLE module with Arduino Uno to control an LED.
What is a Cloned HM-10 Module?
Cloned HM-10 modules are similar to the Genuine
HM-10 module. But to save the extra cost while manufacturing, the
manufacturers removed the external oscillator and leaves the space for
the External Oscillator. The manufacture used the internal oscialltor of
HM-10 module for saving the cost. Also, the firmware is different than
the genuine HM-10 module.
BLE HM-10 module is a Bluetooth Low Energy (BLE) module built on Texas Instrument’s CC2540 or CC2541.
Chinese manufacturer Jinan Huamao Technology is developer of the board
and the firmware. The Manufacturer has stated on the official
documentation that there are several clones available in the market.
How to distinguish between Genuine and Clone HM10 BLE Modules
There are two types of BLE HM-10 modules available, the genuine and Chinese cloned. To identify the difference the between the genuine and Chinese Cloned HM-10 module, there are some points to do that.
1. The first point is by looking at the HM-10 module. If the Crystal Oscillator of 32KHz is available on the HM-10 board then it is Genuine one else it is the Chinese Cloned HM10.
2. The second way to find is by connecting the
HM10 with any Serial Module and sending AT commands. If the HM-10
doesn’t reply to AT commands, then it is a Cloned HM-10 module.
How to change or Flash the firmware of Clone HM-10 BLE Module
In order to change the firmware, we really need a
good hand on soldering. Once you change the firmware of the HM10 module.
You will be able to access all its functions. There are two methods to
flash the cloned HM10 module:
1. The first method includes the SmartRF Flash Programmer from Texas Instruments.
2. And the second method includes the Arduino as programmer for HM-10.
In this tutorial, we will use the second method of flashing the HM-10 module i.e. Arduino as Programmer for HM-10.
So lets start the steps in Flashing the HM-10 module using Arduino UNO
as Programmer. As said earlier, the soldering will be required to
connect HM-10 with Arduino. We need to solder the wires to the
DEBUG_CLOCK, DEBUG_DATA, RESET_N pins of HM-10. Then complete procedure
is explained in next sections.
Components Required
Hardware
- Arduino (UNO, Pro Mini)
- USB to TTL converter for connect Arduino to the PC (in case of arduino pro mini or similar)
- CC2541 board: HM-10, CC41
- Some Jumper Wires
- Soldering Iron (To solder the wire to HM-10 Board)
Software:
- Arduino IDE
- CCLoader Arduino Sketch
- CCloader Windows Program
- HM-10 Firmware (Extract the Zip file)
HM-10 Pin Out
Circuit Diagram
Firstly, solder the small jumper wires with HM-10 Board pins then proceed with the circuit connections with Arduino to flash the firmware inside HM10 BLE Module.
3, Build your own gas and smoke detector that can read and display smoke levels using the MQ-2 and an Arduino.
Hardware | |||
---|---|---|---|
1 | Arduino Uno | ||
2 | MQ2 Sensor | ||
3 | I2C Character LCD |
This
tutorial walks you through building a smoke detector that not only
senses smoke and other harmful gases in the air but also reads and
displays smoke levels in PPM (parts per million).
When the smoke concentration is above 1000 ppm, the circuit triggers a buzzer that can be changed in the code as required. This project uses the MQ-2 sensor and an Arduino to determine and detect different smoke intensities.
This smoke detector can be easily built onto a breadboard or a polka dot plate. The MQ-2 sensor is used to detect the levels of gas around the area, so you can utilize this sensor as a gas leak monitoring system for homes, businesses, or factories, and is suitable for monitoring devices such as gas, butane, propane, methane, alcohol, hydrogen, and smoke.
When the smoke concentration is above 1000 ppm, the circuit triggers a buzzer that can be changed in the code as required. This project uses the MQ-2 sensor and an Arduino to determine and detect different smoke intensities.
This smoke detector can be easily built onto a breadboard or a polka dot plate. The MQ-2 sensor is used to detect the levels of gas around the area, so you can utilize this sensor as a gas leak monitoring system for homes, businesses, or factories, and is suitable for monitoring devices such as gas, butane, propane, methane, alcohol, hydrogen, and smoke.
What is the MQ-2 Smoke Sensor?
The MQ-2 smoke sensor is sensitive to smoke and also responsive to the following flammable gases:- LPG
- Butane
- Propane
- Methane
- Alcohol
- Hydrogen
![image](https://maker.pro/storage/8MvFnVA/8MvFnVAEXNK2PopURJv4GtDnuZNGplXaKyGDL71t.png)
The
resistance of MQ2 varies depending on the type of gas. The smoke sensor
has a built-in potentiometer that adjusts the sensitivity of the sensor
based on the accuracy of the gas you are testing.
How Does the MQ-2 Work?
The sensor’s voltage output varies proportionately with the measured smoke/gas in the atmosphere. In other words, the relationship between voltage and gas concentration is as follows:- The higher the gas concentration, the higher the output voltage.
- The lower the gas concentration, the lower the output voltage.
MQ-2 Specifications
- Dimensions: 35 mm x 22 mm x 23 mm (length x width x height)
- Main chip: LM393, ZYMQ-2 gas sensor
- Working voltage: DC 5V
MQ-2 Features
- With signal output command.
- Dual signal output (analog output and high/low digital output).
- 0~4.2V analog output voltage, the higher the concentration, the higher the voltage.
- It has higher sensitivity to natural gas, natural gas and city gas.
- Long service life, stable and reliable.
- Fast response and recovery features.
![image](https://maker.pro/storage/wt0QynB/wt0QynBLBkCFtwhP0qlO1XKosQdFQapcSByAWVDO.png)
![image](https://maker.pro/storage/bqeuAqb/bqeuAqb89wosCAQeW0VVZZ22TR6t4OOko5QDhCRC.png)
Wiring Up the Project
Wire up everything as described below:
Arduino
|
MQ2
|
---|---|
A0
|
A0
|
5V
|
VCC
|
GND
|
GND
|
Arduino
|
I2C LCD
|
---|---|
VCC
|
5V
|
GND
|
GND
|
SDA
|
A4
|
SCL
|
A5
|
![image](https://maker.pro/storage/TzJ4x1O/TzJ4x1OYGouaaxWK1wwevifFlJNIbmames7YiYUa.png)
![image](https://maker.pro/storage/WzxHpkl/WzxHpkl4POSsXvTEOLIBOWRAlcpRLjcxRH3W3Hul.png)
Project Source Code
After you are done with the connections, connect the Arduino to your computer and upload the source code below:arduino
#include <MQ2.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//I2C pins declaration
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int Analog_Input = A0;
int lpg, co, smoke;
MQ2 mq2(Analog_Input);
void setup(){
Serial.begin(9600);
lcd.begin(16,2);//Defining 16 columns and 2 rows of lcd display
lcd.backlight();
mq2.begin();
}
void loop(){
float* values= mq2.read(true); //set it false if you don't want to print the values in the Serial
//lpg = values[0];
lpg = mq2.readLPG();
//co = values[1];
co = mq2.readCO();
//smoke = values[2];
smoke = mq2.readSmoke();
lcd.setCursor(0,0);
lcd.print("LPG:");
lcd.print(lpg);
lcd.print(" CO:");
lcd.print(co);
lcd.setCursor(0,1);
lcd.print("SMOKE:");
lcd.print(smoke);
lcd.print(" PPM");
delay(1000);
}
![image](https://maker.pro/storage/7wD6wXG/7wD6wXGd9yLQ3vrldsvC4rxOKiok1Ukt8sOHwsQX.png)
After
uploading the code, you can start testing the sensor out using a small
lighter to see how it responds to the flame and gas. Start slowly and,
as always, be careful around flames.
4, Sound Detector.
Hardware | |||
---|---|---|---|
1. | Sound Detector | ||
2. | Particle Photon | ||
3. | Jumper wires | ||
4. | Breadboard |
This
project is for Lane of Things; a smaller version of Array of Things
which is described as, "an urban sensing project, a network of
interactive, modular sensor boxes that will be installed around Chicago
to collect real-time data on the city’s environment, infrastructure, and
activity for research and public use."
We
are studying the relationship between sound levels and time during the
day. Does sound increase as the time gets closer to the school day
ending? And if not what makes certain periods louder than others?
This
is interesting because the week that we collected data had a different
schedule everyday. The first day was shorter classes, the second skipped
periods 4, 5, and 6, then another day of shorter classes, and finally
the next day was all testing with no periods.
Prototyping the Project
First, we prototyped using cardboard and paper. Our prototype used hot glue and tape to secure the sides and the cone together.For the final product, we used a wood box as our enclosure. The box uses T-slots so that we can open and close the box when necessary. The box has 2 openings, one for the microphone of the sound sensor to stick out of, and the other for the power cord.
Attached on the box is a cone that we added to help direct the sound towards the microphone. We also engraved our contact information onto the box for anybody who had questions about what data we were collecting.
We had an issue with our breadboard fitting into the box because of a mistake with the size of the inside of the box compared to the size of the breadboard with the sensors attached. We fixed this problem by angling our breadboard inside of the box.
![image](https://maker.pro/storage/0LEhqs2/0LEhqs2MgnSXbig5ezK0XGJuYC40SXLVWS3wmglm.jpeg)
Laser cutting the sides of our box from Baltic Birch Plywood
We
went through several variations of code throughout this project. The
sound detector we used is relatively new and our main issue was that the
average values were not always logical, and the minimum value sometimes
surpassed the maximum. We also had to edit our Google Script Editor
code so that we could pull our values from the photon to our
spreadsheet. We did this by adding Particle variables that would be able
to be accessed by a unique URL by the Script Editor.
We
deployed our sensor in the front of a math class room. The classroom is
on the 3rd floor of Lane tech and is used for the majority of the day
including periods 1, 2, 3, 5, 7, and 8. The classroom is set up so that
all of the desks are facing towards our sensor with the teacher
lecturing at the front of the room adjacent to our sensor.
![image](https://maker.pro/storage/t0tZSgL/t0tZSgLAX8b5rRyCfgOJRIzXkqsKzQfPer9i1sCE.jpeg)
Our sensor under the whiteboard, attached by command strips and powered through an outlet.
We
had originally wanted to determine if our peers are more likely to talk
in the back of the room, or in the front of the room. We had to change
our idea because the week that we collecting data was also the week of
SAT testing which caused all the class schedules to be different. We
felt that the combination of scheduling and moving the sensor would
cause our data to be inaccurate.
We
learned a lot about coding and the difference between pulling and
pushing data. Each member of our group had coding experience but had not
used the Particle platform before.
![image](https://maker.pro/storage/4zrRI1o/4zrRI1oPU2uc5exbDazT5Wgvjg2cb2WVrZDTzzow.jpeg)
The final product.
Data Collection Results
When we stopped collecting data we had over 150, 000 data points. We found that the average sound levels did increase throughout the day with spikes during the beginning and end of a class period. These same spikes are also seen in our minimum and maximum data, minimum barely changes while maximum has a spike for the start and end of each period.There are also low points in our "Avg Sound Levels" graph during the middle of the class periods, especially from 10:45-1:25 which we believe is because many students leave the school for lunch.
We
also noticed that each day had a higher average than the one before it.
This shows that not only does the sound increase as the school day
comes to an end, but also as the week comes to an end. When comparing
data collected before and after school, we noticed that the graphs
mirrored each other. The major spike in both graphs represents students
rushing to class, and rushing to leave school. We were surprised that
after school did not show a slower decline because we assumed that kids
would stay longer to go to clubs or sports.
![image](https://maker.pro/storage/OIMfLCj/OIMfLCjSiV7GWNlg87LQDO0TdYVSIIswSlhHMUbg.jpeg)
5, build a bicycle horn with variable tone and volume.
The
LM555 generates an electronic horn signal which is amplified by an
LM386. The tone and gain of the horn can be easily varied. The horn can
be used in a car, scooter, cycle, and motorbike.
Step 1: Parts and Tools
Electronic Components
- 1x IC 555
- 1x IC LM386
- 2x IC Holder
- 1x 10Ω Resistor
- 1x 1KΩ Resistor
- 1x 2KΩ Resistor
- 3x 10KΩ Potentiometer
- 1x Tactile Momentary Push Buttons
- 1x 5mm LED
- 1x 0.1uF Capacitor
- 1x 10uF Capacitor
- 1x 100uF Capacitor
- 1x 220uF Capacitor
- 1x 10nF Capacitor
- 1x 47nF Capacitor
- 1x 100nF Capacitor
- 1x Speaker
- 1x 9V Battery Holder
- 1x 9V Battery
- 1x PCB
Tools
- Soldering Iron
- Soldering Wire
- Mini PCB Hand Drill + Bits
- You can also Buy the PCB
Step 2: LM555 Explained
The
555 is a highly stable device for generating accurate time delays or
oscillation. Additional terminals are provided for triggering or
resetting if desired. For stable operation as an oscillator, the free
running frequency and duty cycle are accurately controlled with two
external resistors and one capacitor. The circuit may be triggered and
reset on falling waveforms, and the output circuit can source or sink up
to 200mA or drive TTL circuits.
Step 3: LM386 Explained
The
LM386 is a power amplifier designed for use in low voltage consumer
applications. The gain is internally set to 20 to keep external part
count low, but the addition of an external resistor and capacitor
between pins 1 and 8 will increase the gain to any value from 20 to 200.
The inputs are ground referenced while the output automatically biases to one-half the supply voltage.
The inputs are ground referenced while the output automatically biases to one-half the supply voltage.
Step 4: Working & Calculations
![image](https://maker.pro/storage/OCbuvGr/OCbuvGrSOfMEjUvzcCxz1vohVs0eECEbyzyZgNGl.png)
An
LM555 is used to generate the horn signal. The LM555 is connected such
that it will trigger itself and free run as an astable multivibrator.
The external capacitor charges through Ra+Rb and discharges through Rb.
Thus the duty cycle may be precisely set by the ratio of these two
resistors.
In this mode of operation, the capacitor charges and discharges between 1/3 VCC and 2/3 VCC. Hence the charge and discharge times, and therefore the frequency is independent of the supply voltage.
A momentary switch acts as an input trigger that enables the astable multivibrator to generate a signal of variable frequency. This signal is then sent to an amplification unit before it is played through a speaker. The frequency and volume of the horn sound can be varied as shown.
In this mode of operation, the capacitor charges and discharges between 1/3 VCC and 2/3 VCC. Hence the charge and discharge times, and therefore the frequency is independent of the supply voltage.
A momentary switch acts as an input trigger that enables the astable multivibrator to generate a signal of variable frequency. This signal is then sent to an amplification unit before it is played through a speaker. The frequency and volume of the horn sound can be varied as shown.
Step 5: Circuit Schematic
![image](https://maker.pro/storage/FZNB9CS/FZNB9CS1Ui5HftKQSml2B3sR2mqjhbGdcx95fvwZ.png)
A
potentiometer R3 (Rb) is varied in order to change the frequency of the
signal generated by the LM555. The signal is then passed to the LM386
for amplification.
The input signal is passed through another potentiometer R4 before it reaches the LM386. This pot is used to change the amplitude (volume) of the input signal before amplification.
The LM386 has a 10uF capacitor and 10K potentiometer R5 connected between pins 1 and 8. By varying this pot, we can change the gain of the amplifier and thus the volume of the amplified signal.
A push button/ momentary switch is used to turn on the circuit thereby producing a loud horn sound.
Capacitors connected across the supply terminals are used to minimize any noise signals.
Eagle Schematic: GitHub
The input signal is passed through another potentiometer R4 before it reaches the LM386. This pot is used to change the amplitude (volume) of the input signal before amplification.
The LM386 has a 10uF capacitor and 10K potentiometer R5 connected between pins 1 and 8. By varying this pot, we can change the gain of the amplifier and thus the volume of the amplified signal.
A push button/ momentary switch is used to turn on the circuit thereby producing a loud horn sound.
Capacitors connected across the supply terminals are used to minimize any noise signals.
Eagle Schematic: GitHub
Step 6: PCB Fabrication
Step 7: Circuit Assembly
Place
and solder all the components onto the PCB. Double check components
with polarities. Lastly, solder the Power adapter and speaker to the
PCB.
Step 8: Adjust the Tone and Volume
You can vary the tone and volume of the horn by changing the position of the potentiometers using a screwdriver.
Potentiometer R3 is varied to change the tone(frequency) of the horn. Potentiometer R4 is used to change the volume(amplifier gain) of the horn.
Potentiometer R3 is varied to change the tone(frequency) of the horn. Potentiometer R4 is used to change the volume(amplifier gain) of the horn.
Share Your Experience!
Are
you an engineer or hobbyist who has a great idea for a new feature in
this project? Maybe you have a good idea for a bug fix? Feel free to
grab the schematics from GitHub and tinker with it.
If you have any questions/doubts related to this project, leave them in the comments section and I will try my best to answer them.
Subscribe to:
Posts (Atom)