Introduction: Piezo Element Multimeter

Picture of Piezo Element Multimeter

Hello! This project will show you how to make a multimeter meter like project that will read the voltage from the piezo element and display it on an LCD! This project serves as a means of inspiration and a means of introduction to the piezo element that has the ability to do WAY more than what it does in this specific project. Because the piezo element is a vibration sensor and almost everything in the world vibrates, the piezo element could be used even in the most complex projects.

This project also contains an IoT part where, through IFTTT, sends and logs the data into a Google SpreadSheet.

Step 1: Materials

Picture of Materials

1. Piezo Element

2. 1. 1M ohm resistor

3. Particle Photon for IoT/ any other Arduino if no IoT

4. Breadboard

5. 16x2 LCD

6. Potentiometer

7. Any LEDs will do

8. Solid core wire to make it appealing

Step 2: Wiring Up

Piezo Element

1. Wire up the red positive wire to an Analog pin on the Arduino

2. Wire up the black negative wire to a GND pin on the Arduino

3. Wire up the 1M Ohm resistor in parallel with the Analog and GND pin.

LCD

If you choose to work with a Particle Photon and a choose to implement the 16x2 LCD, you will run into some trouble with getting it to work. If you do not want to work with the Particle Photon, the LCD hookup will not change.

So the thing with the Photon implementation is that the potentiometer will need power from the 3V3 Pin and the LCD will need power from the VIN pin. The easiest way to do this is to connect a GND pin and the 3V3 pin into the respective power rail on the breadboard and plug the potentiometer to the rails.

1. Pin 1 for LCD - GND

2. Pin 2 for LCD - VIN

3. Pin 3 for LCD - Potentiometer

4. Pin 4 for LCD - D0

5. Pin 5 for LCD - GND

6. Pin 6 for LCD - D1

7. Pin 11 for LCD - D2

8. Pin 12 for LCD - D3

9. Pin 13 for LCD - D4

10. Pin 14 for LCD - D5

11. Pin 15 for LCD - VIN

12. Pin 16 for LCD - GND

Once the potentiometer and the LCD are hooked up, a library has to be downloaded in order for the LCD to work on the Particle Photon. On the Particle IDE, it is called "Spark-HelloSparky.cpp” under LiquidCrystal Library. Simply fork this library and change '#include "LiquidCrystal"' to '#include "LiquidCrystal/LiquidCrystal.h"'

If confusion arises or a picture for reference is needed, feel free to visit Jon Gallant's blog on how he solved the problem for a Particle Photon. It helped me clear up any confusion and complete my project so I highly recommend his blog.

Step 3: Code

The code here is fairly simple and easy to understand. It will also include an IoT feature where it publishes the variable into a spreadsheet through IFTTT.

#include "application.h"
#include "LiquidCrystal/LiquidCrystal.h"

// Make sure to update these to match how you've wired your pins.

// pinout on LCD [RS, EN, D4, D5, D6, D7];

// pin nums LCD [ 4, 6, 11, 12, 13, 14];

LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);

// these constants won't change: const int ledPin = 7;

// led connected to digital pin 13 const

int knockSensor = A0;

// the piezo is connected to analog pin 0 const int threshold = 100;

// threshold value to decide when the detected sound is a knock or not

float base;

float analog;

double analogV;

int sensorReading = 0;

int ledState = LOW;

void setup() {

lcd.begin(16,2);

lcd.print("Current Voltage:");

pinMode(ledPin, OUTPUT);

Serial.begin(9600);

Particle.variable("analogV", analogV); }

void loop() {

sensorReading = analogRead(knockSensor);

if (sensorReading >= threshold) {

ledState = !ledState;

digitalWrite(ledPin, ledState);

lcd.setCursor(0,1);

base = (sensorReading/3.999);

delay(50);

analog = (base/1024);

delay(50);

analogV = (analog*5);

lcd.print(analogV);

Serial.println(sensorReading);

Serial.println(analogV);

delay(300); // delay to avoid overloading the serial port buffer }

}

Step 4: IFTTT

Picture of IFTTT

If implementing IFTTT, first create an account. Then make sure a variable can be pulled from the code(in this case it is "Particle.variable("analogV", analogV);") Now its time to make a recipe on IFTTT; connect it to Google Spreadsheets and follow the on screen instructions. It should not be very difficult and very few settings and names should be changed at all. However, I have included what the recipe should look like. Something to note however, because my Photon is offline, the IFTTT recipe says the variable name is unavailable. When the photon is plugged in, the according variable name will display.

Step 5: Conclusion

Picture of Conclusion

To wrap up, everything should be connected and working. The photon should connect to IFTTT and Google Sheets and should be creating new rows at the instance of a new trigger of the piezo element. This project is a very quick project to replicate and serves as a building block for the many other features a piezo element can be used for. Some ideas I came up with while building this project was a door opener in reaction to a knock and a foot step detector among the many other possible projects.

Thank you for reviewing my project.

Comments

Swansong (author)2017-02-22

Thanks for sharing :)

About This Instructable

1,954views

27favorites

License:

More by jpnieroda:Piezo Element Multimeter
Add instructable to: