Go Down

Topic: Analog VU Meter - I2C OLED SH1106 - OLEDMeter Animation (Read 61022 times) previous topic - next topic

MicroControllerFan

#45
Apr 27, 2018, 04:15 am Last Edit: Apr 27, 2018, 04:19 am by MicroControllerFan Reason: Video link was not active.
Yet another POC video of the meter in operation. Thanks stievenart.
Arduino OLED VU Meter

stievenart

#46
May 10, 2018, 04:05 am Last Edit: May 10, 2018, 10:24 pm by stievenart
MicroControllerFan,

I took a look at your STL files. I took screenshots and posted them here. Along with a link to the STL case files.

~stievenart





arduino_vumeter_oled.zip

TAG67

Hi Stievenart,

Thanks for a great little project. I have it working fine here but I'd really like to modify it for my own use and I just can't get it to work.. I hope you can help.

All I wanna do is create a simple volt meter. The OLED display is running off the 3.3V and I have the 5V connected to a potentiometer, the pot wiper is connected to A0 and the other side to ground.

So, I simply want to read the voltage from the pot. I have made my own bitmap and it's displaying fine. I really can't get the needle to stay at a given voltage and the math to get the needle to animate correctly.

Here's a link to something like I want to do.. https://www.youtube.com/watch?v=NNGxx4Hvl-Q

Hoping you can offer advice.

Terry

stievenart

#48
Jun 20, 2018, 02:40 pm Last Edit: Jun 22, 2018, 04:18 pm by stievenart
I really can't get the needle to stay at a given voltage and the math to get the needle to animate correctly.

Hoping you can offer advice.

Terry
TAG67 (Terry),

It sounds like you are trying to calibrate your device. I used the 2-point process on another project with good results.

I followed the instructions at: https://learn.adafruit.com/calibrating-sensors/two-point-calibration

I added the equations directly to my code and had the Arduino to do the work.

~stievenart

konog

Hello. Share the file Adafruit_SH1106.cpp on which it will work?

stievenart

Hello. Share the file Adafruit_SH1106.cpp on which it will work?
It's written in the original .ino file...

Code: [Select]
*  IMPORTANT: Sound source must be grounded to the Arduino or other MCU's to work. Usually the
 *  base sleeve contact on TRS or TRRS connector is the ground.
 */

#include <Wire.h>                     // requried to run I2C SH1106
#include <SPI.h>                      // requried to run I2C SH1106
#include <Adafruit_GFX.h>             // https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_SH1106.h>          // https://github.com/wonho-maker/Adafruit_SH1106

#define OLED_RESET 4                  // reset required for SH1106

Adafruit_SH1106 display(OLED_RESET);  // reset required for SH1106

navjotsdhanoa

There is slight noise, a constant hiss. Anyone heard that too?

stievenart

There is slight noise, a constant hiss. Anyone heard that too?
Yes, you need to make sure the base ground sleeve on the TRRS connector is making contact. That warning is embedding in the code.

~stievenart

warior

Hi, very nice project.

Wanted final touch to my sound visualization system - so i put stereo VU meter on a single oled display - left arrow is normal clockwise from left and right arrow (with center line inside) is inverted - from right counter clockwise. Changed bitmap a little and adjusted audio input to my pc's - final result become quite satisfactory.



Thx:)

jimLee

For smoothing out the needle movement would a running average object help?

runningAvg smoother(numDatapointsAveraged);   // Create object..


dataForMeter = smoother.addData(rawValue);    // Pass the data through it before the meter.

Easy Peasy.

Code: [Select]


#ifndef runningAvg_h
#define runningAvg_h

class runningAvg {
 
  public:
    runningAvg(int inNumData);
    ~runningAvg(void);
   
    float addData(float inData);
    float getAve(void);
    float getMax(void);
    float getMin(void);
    float getDelta(void);
 
  protected:
    int    maxData;     // Total amount allowed.
    int    numValues;   // The amount we have.
    int    index;       // Write the next value, here.
    float  *theValues;  // The array of values.
    float  result;      // Just in case they ask, we'll keep a copy.
};

#endif



And te c++ file..

Code: [Select]

#include "runningAvg.h"
#include <stdlib.h>

runningAvg::runningAvg(int inNumData) {
 
  theValues = (float*) malloc(sizeof(float)*inNumData);
  maxData = inNumData;
  numValues = 0;
  index = 0;
  result = 0;
}

 
runningAvg::~runningAvg(void) {
 
  free(theValues);
  theValues = NULL;
}



float runningAvg::addData(float inData) {
 
  float sum;
 
  if (numValues<maxData) {          // Early stages while filling.
    theValues[index++] = inData;    // Never been full so index must be ok.
    numValues++;
  } else {
    if (index==maxData) {           // Meaning its pointing past the array.
      index = 0;                    // Cycle around.
    }
    theValues[index++] = inData;    // And stuff the value in.
  }
  sum = 0;
  for (int i=0;i<numValues;i++) {   // We loop up to numValues but not including numValues.
    sum = sum + theValues[i];
  }
  result = sum/numValues;
  return result;
}


float runningAvg::getAve(void) { return result; }


float runningAvg::getMax(void) {
 
  float result = theValues[0];
 
  for (int i=1;i<maxData;i++) {
    if (theValues[i]>result) {
      result = theValues[i];
    }
  }
  return result;
}


float runningAvg::getMin(void) {
 
  float result = theValues[0];
 
  for (int i=1;i<maxData;i++) {
    if (theValues[i]<result) {
      result = theValues[i];
    }
  }
  return result;
}


float runningAvg::getDelta(void) { return getMax()-getMin(); }



Hope this helps!

-jim lee
PNW Ardiuno & Maker club
1012 9Th Street, Anacortes, WA 98221 (Around the back of building)

jerrylong_km

stievenart,Very impressive project!
I want to follow the instruction of your project, and I want to use bigger Screen like 2.2" TFT drived by ILI9341, is that possible? I am just worried about its refresh speed. Any other screen will be good choice?

ChrisTenone

@stievenart, I love your code man!

I adapted it to use as a display for an analog looking 'geiger' counter (actually a scintillation counter from Radiation Watch in Japan). The dial face is drawn dynamically so the scale can adapt to the reading on the fly.

Thank you so much for doing the hard part!


Atmosphere carries combustion vapors to places where they will do good instead of harm - Mike Faraday's 'History of a Candle': https://www.youtube.com/watch?v=6W0MHZ4jb4A

Whoops ::)

Go Up