Posts with «grove base shield» label

Universal Remote a Grove Infrared project


 
 

Description

This project will convert an ordinary Keyes infra-red (IR) remote
into a programmable universal remote.

 
A single button press on the Keyes remote will be converted into precise Sony IR signal combinations using an Arduino UNO and an assortment of Seeedstudio Grove modules.
You can assign signal combinations from more than one remote if desired.
An example combination could be to:
  • Turn on the TV and then switch channels.
  • Turn on the TV, sound system, and air-conditioner.
  • Turn up the volume x 3.
With only one button press of the Keyes remote, the entire cascade of Sony signals ensues. This project can be customised for other IR methodologies, however, you may have to modify the Arduino code to accommodate them.

 
 

Parts Required

  1. Arduino Uno (or compatible board)
  2. Grove Base Shield (v2)
  3. Grove Infrared Receiver
  4. Grove Infrared Emitter
  5. Grove Button
  6. Grove 16x2 LCD (White on Blue)
  7. Grove Universal 4 pin buckled cable: one supplied with each module.
  8. KEYES IR Remote Control
  9. SONY IR remote control
  10. USB cable - to power and program the Arduino
  11. Battery pack / Power bank

 
 

More information about the Grove modules can be found here:

**Please Note: The Grove Base shield has 14 pins on the Analog side, and 18 pins on the digital side. Check the number of pins on your Arduino UNO (or compatible board) to ensure the shield will sit nicely on top. NOT compatible with Arduino boards that have the Arduino Duemilanove pin header layout.

 
 

Arduino IDE

While there are many Arduino IDE alternatives out there, I would recommend that you use the official Arduino IDE for this project. I used the official Arduino IDE app (v1.8.5) for Windows 10.
Make sure to get the most up-to-date version for your operating system here.


 
 

Libraries required

The following libraries will be used in the Arduino code:

  1. Wire Library
  2. IRLib2 Library
  3. rgb_lcd Library

Wire Library

The Wire library is used for I2C communication for the Grove LCD screen and is built into the Arduino IDE - no additional download required for this library.
 

IRLib2 Library

The IRLib2 Library is actually a "set" of IR libraries, which can be downloaded from GitHub - here. In this project, I will be transmitting and receiving NEC and Sony IR remote signals.
The required libraries (within the set) will be:
  • IRLibRecv.h
  • IRLibDecodeBase.h
  • IRLibSendBase.h
  • IRLib_P01_NEC.h
  • IRLib_P02_Sony.h
  • IRLibCombo.h
Please see the IRLib2 GitHub Page for installation instructions.
 

rgb_lcd Library

The rgb_lcd.h library simplifies the operation of the LCD screen.
Download the rgb_lcd.h library from GitHub. Install the rgb_lcd.h library ZIP file into the Arduino IDE:
  1. Load the Arduino IDE
  2. Navigate to Sketch >Include library > Add .ZIP library...
  3. Select the downloaded zip file from GitHub, and press the "Open" button
  4. Check that it installed correctly by navigating to File > Examples > Grove-LCD RGB Backlight

 
 
 
 

Arduino Code

It is always best to upload the Arduino code to the board before you make any of the connections. This way you prevent the Arduino from sending current to a component accidentally. The code is available on my GitHub repository. Or you can have a look below. This code was written for an Arduino UNO, and may need to be modified if you are using a different board.

 
 
 
 

Connection instructions

If you are using the Grove Base Shield (v2). The connections are extremely simple. Use the following table as a guide. Please note that the code above assumes the following connections.
 

 

As per the table above, you would use a Grove universal 4-pin buckled cable and connect one side to D2 on the Grove base shield, and the other side would connect to the Grove Infrared Emitter.
D3 on the base shield would connect to the Grove Infrared Receiver, and so on.
You can connect the 16x2 LCD module to ANY of the four I2C connectors on the Grove base shield.

If you do not have a Grove Base shield, you have the option to use female-to-male jumper wires (together with a breadboard). But it is easier just to get the base shield and use the universal connectors.

 
 
 
 
 
 

Project Explained

When you apply power to the Arduino, the first thing that appears on the LCD screen is:
 


 
After pressing the Grove button (connected to D5), it displays the following message:
 

 
This is the cue to press and send a signal from the Keyes remote to the Infrared receiver (which is connected to D2). The Arduino will decode the Keyes remote signal, store the value in an array, and display the signal briefly on the LCD. The LCD should now show a message:
 

 
This message is a cue to press and send the FIRST signal from the Sony remote to the Infrared receiver. The Arduino will decode and store the Sony remote signal in a different array, and display it briefly on the LCD. You have the option to send a maximum of THREE Sony signal combinations to the Infrared receiver at this step in the process. The minimum number of Sony signals you can send is zero. The way to tell the Arduino that you do not want to send any further Sony signals to the receiver in this step, is by pressing the Grove Button (connected to D5).
 
The Arduino is programmed to receive a total of 5 Keyes signals, and each signal can be paired with a maximum of 3 Sony signal combinations. Once you have recorded all of the signal combinations, you will get a message:
 

 
The Arduino will now enter the final "Universal remote mode". In this mode, it will listen out for ANY of the 5 Keyes IR remote signals recorded previously, and will send the associated Sony signal combination in return. For example, if you press the number 1 on the Keyes remote, you could potentially have it so that the Arduino will transmit a Sony signal combination to turn on the TV and jump to a specific channnel.
 
The LCD will display each of the signals being transmitted. You will know you are in "Universal remote" mode because the LCD will display:
 

 
While you may be tempted to throw your Sony remote away at this stage (because you no longer have a use for it)... I would hold on to it just in case. The signals are not stored permanently. They disappear when the Arduino is powered off. But it doesn't have to be that way. You can easily modify the code to store it in eeprom memory or something.
 
That is not the only thing you can change.Technically, you could record the signal for any remote, however, you may need to include additional libraries or code to accommodate the alternate remote symbology. You can also modify the text messages on the LCD screen to make more sense to you. The LCD can only display 16 characters per row. So keep that it mind, when you come up with creative captions.
 
I would also like to mention the reason I chose not to use Seeedstudio's IR library, was because it took up too much memory. Their library probably accommodates for a wide range of symbologies. I chose the IRLib2 Library because I could select only the symbologies that I used (Sony and NEC). Thereby reducing the total amount of memory necessary to run the project. In fact, I have been finding that many of Seeedstudio's libraries to be very memory hungry. I originally wanted to create a gesture controlled remote. But the library combinations eliminated that possibility due to the cumulative memory requirements.
 
 
 
 

Conclusion

The IRLib2 library is the key to the success of this project. Without that library, this project would have been ten times harder. I was quite amazed by the effectiveness of this record / playback technique. It felt very weird to be operating my SONY TV with a cheap and nasty Keyes remote. It was quite surreal. While I chose to control my TV in this way, I could have just as easily recorded signals from one of my other remotes that use infrared signals. As more and more devices become controllable by remotes, the more I will consider turning this project into a permanent fixture in my house. A gesture controlled remote would have been nice, however, it looks like I will have to find some other use for that module now.

If you found this tutorial helpful, please consider supporting me by buying me a virtual coffee/beer.

$3.00 AUD only
 

Social Media

You can find me on various social networks:

Follow me on Twitter: ScottC @ArduinoBasics.
I can also be found on Instagram, Pinterest, and YouTube.
And if all else fails, I have a server on Discord.



             

Alcohol Detection Project

Please visit:
https://arduinobasics.blogspot.com
for original tutorial.

 
 

Description

'Tis the season to be jolly, but sometimes you would like to tone down the jolliness. Or perhaps you are the designated driver and need to know how festive that punch is !
I have the perfect solution for you:

The grove alcohol sensor.


Most people look to buy this sensor to make their own DIY breathalyser. Don't bother. You won't get the accuracy you are looking for, or you probably won't have all the necessary equipment/materials required to calibrate it. While you can get a rough idea, I would NOT recommend using this sensor to make any decisions based on quantitative measurements.

I will also point out that this sensor is not specific for Alcohol. It will react to some other chemicals too. In other words, you cannot assume that a positive result equates to the presence of alcohol (ethanol) in the air. It could be butane, LPG, Isopropanol etc etc.

This project will attempt to show how much alcohol is in the air, for the sole purpose of identifying the presence, as well as getting a rough estimate of the strength of alcohol, in a variety of festive drinks.

PLEASE NOTE:
Do not submerge the sensor in liquid, and avoid splashing the sensor. Also do not expose the sensor to strong chemicals (including alcohol) for extended periods. There is a 48 hour burn-in time for this sensor. Which means that it actually performs better once it has been used for over 48 hours. The sensor also needs to warm up, which often takes more than 15 minutes long. Once exposed to a strong concentration of alcohol in the air, the sensor takes what seems like an eternal amount of time to recover. Take this into consideration when planning your future project.

 


Parts Required

  1. Arduino Uno (or compatible board)
  2. Grove Base Shield (v2)
  3. Grove Alcohol Sensor
  4. Grove 16x2 LCD (White on Blue)
  5. Grove Universal 4 pin buckled cable: one supplied with each module.
  6. USB cable - to power and program the Arduino
  7. Battery pack / Power bank

More information about the Grove Modules can be found here:

The Grove Base shield has 14 pins on the Analog side, and 18 pins on the digital side. Check the number of pins on your Arduino UNO (or compatible board) to ensure the shield will sit nicely on top. NOT compatible with Arduino boards that have the Arduino Duemilanove pin header layout.



Arduino IDE

While there are many Arduino IDE alternatives out there, I would recommend that you use the official Arduino IDE for this project. I used the official Arduino IDE app (v1.8.5) for Windows 10.
Make sure to get the most up-to-date version for your operating system here.


 
 

Libraries required

The following libraries will be used in the Arduino code:

  1. Wire.h
  2. math.h
  3. rgb_lcd.h
The Wire.h library is used for I2C communication, for the Grove LCD screen.
The math.h library is used for the pow() function, to calculate the concentration of alcohol in the air.
The rgb_lcd.h library simplifies the operation of the LCD screen.
 
The Wire.h and math.h library are already within the Arduino IDE, no further download or installation required. However, you will need to install the rgb_lcd.h library - which can be downloaded from GitHub. Once you download the zip file, install it into the Arduino IDE:
  1. Load the Arduino IDE
  2. Navigate to Sketch >Include library > Add .ZIP library...
  3. Select the downloaded zip file from GitHub, and press the "Open" button
  4. Check that it installed correctly by navigating to File > Examples > Grove-LCD RGB Backlight


 

Arduino Code

If the Grove-LCD RGB Backlight option is available in the examples folder, then you are good to go.
 
Select File > New
 
Paste the following code into the Arduino IDE, and upload it to the Arduino UNO (or compatible board).
 
PLEASE NOTE: Make sure the Alcohol Sensor is NOT connected to the Arduino while uploading your code to the Arduino. It seems to interfere with Serial communication for some reason, and the renders the COM port unusable until you reset the board, reboot the IDE and/or your computer. The best way to avoid this issue, is to unplug the Alcohol sensor from the Grove Base shield, ANY time you upload code to the Arduino.


 
 
 

Connection instructions


Now that the code has been uploaded, it is now time to make the necessary connections from the Arduino to the Grove 16x2 LCD module, and also to the Grove Alcohol sensor.

  1. Disconnect the USB cable from the Arduino to remove power.
  2. Install the Grove Base Shield (v2) onto the Arduino UNO. The header pins on the Base shield should line up exactly with female headers of the Arduino. Please make sure that there are no stray or misaligned pins that are unaccounted for by the Arduino board.
  3. Set the Base Shield Switch to 5V. The switch is in the corner near the LED on the Base Shield.
  4. Connect one end of the 4-pin cable to A0 connector on the Grove Base Shield, and the other end of the cable to the Grove Alcohol Sensor module.
  5. Connect one end of a 4-pin cable to an I2C connector on the Grove Base Shield, and the other end of the cable to the Grove 16x2 LCD module.
  6. You can now apply power to the Arduino Board via the power jack or the USB cable.


 

 

Connection Table

Arduino to Grove Alcohol Sensor module

The Grove Alcohol sensor operates off 5V.
If you are using the Grove Base Shield, place the switch to 5V.
Disconnect the Alcohol sensor from the base shield when uploading code to the Arduino.



Arduino to Grove 16x2 LCD module

The Grove 16x2 LCD module can operate off 5V or 3.3V.
I used 5V from the Arduino UNO.


 
 

Project Explained

When the Arduino is powered up, you will be presented with a message, "Alcohol Project by ArduinoBasics". This is a splash screen to introduce the project.
 
The heater pin on the Alcohol sensor is then activated, which can cause the program to hang. If you do not see the message "Heater Activated", and only see a blank LCD screen - reset the Arduino board. There is a reset pin on the Base shield next to the LED. This message will only display for about 3 seconds before it starts to take readings from the Alcohol sensor.
 
I am guessing that each sensor is different, however, I found that the sensor worked best, once it had been in use for over 48 hours. I normally wait for the sensor reading to get above 5 or 6 before exposing it to alcohol fumes. You will notice the readings slowly increase over time. Wait until the readings stabalise, which can take anywhere between 15-20 minutes, or longer if the sensor has not been used for a while.
 


 
In the presence of alcohol fumes/vapour, the sensor readings will drop, and will trigger the Arduino to change the display to show the rough concentration of alcohol in the Air. Do not expose the sensor to strong concentrations of alcohol for extended periods, as this may permanently affect the sensor performance thereafter. I cannot tell you what readings are NORMAL, because I only have one sensor, and have nothing to compare it to. I have seen my sensor reading get to 11.96, but have noticed that the maximum reading changes each time I test it (sometimes higher, sometimes lower). I am guessing that the surrounding environmental conditions will affect this maximum (i.e. temperature / humidity / air quality), and also the length of time the sensor has had to "burn in" for.
 
Once you reach the maximum value (or as long as you are willing to wait), go ahead and test it out. Hover the sensor over the suspiciously alcoholic festive punch, and catch out your sneaky grandmother.


 
 

Conclusion

The biggest learning points for me about using the Grove Alcohol sensor, was how surprisingly long it took for the sensor to stabalise, and I guess how impatient I am. These types of sensors are often advertised as being a way to create your own breathalyser. But I quickly found out just how hard that was, and after my experience with the sensor, I would never contemplate using it for that purpose, because I cannot verify the accuracy of the results.
 
Can it detect alcohol in the air? Yes it can. The Grove Alcohol sensor can give a rough estimate of the concentration of alcohol vapour in the air, and at best, I would say that it gives you a semi-quantitative result. The same sensor will detect butane, LPG, petrol, isopropanol fumes - which is good or bad, depending on what you plan to use it for.
 


 
One of the most common ways of reading the Alcohol results is through the Serial monitor. However, the Alcohol sensor would for some reason lock up or freeze the Serial communication. I found the best way to observe readings from the Alcohol sensor was to use a Grove LCD module.
 
The Grove LCD module was very easy to use and enabled a more portable project. Grove modules are generally very easy to connect to the Grove Base shield, and are very much "plug and play". The Universal 4pin cables, reduce the "rats-nest" of wires - endemic to Arduino projects.
 
I hope this tutorial has helped you somewhat. If you use this project, please let me know your experience with it in the comments below, and even better, tell me who you caught out.

 
 

If you found this tutorial helpful, please consider supporting me by buying me a virtual coffee.

 
 

Social Media

You can find me on various social networks:

Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
I can also be found on Pinterest and Instagram.
Have a look at my videos on my YouTube channel.