I have been using the HB100 to calculate speed of moving objects. The signal from the HB100 is amplified through a LM358 module and then fed into the D7 port of a Elegoo Uno R3. The resulting velocities displayed in the serial monitor appear reasonable and correct when moving my hand in front of the HB100. I then connected an OLED display and added some code to display the velocities and started to get erratic results in both serial monitor and the display with no movement (Schematic, code and results below). It appears as if the OLED is interfering with the HB100. It appears others have used the OLED with HB100 without problem. Any suggestions would be appreciated.
#include "FreqPeriod.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
double lfrq;
long int pp;
void setup() {
Serial.begin(115200);
FreqPeriod::begin();
Serial.println("FreqPeriod Library Test");
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
}
void loop() {
pp = FreqPeriod::getPeriod();
if (pp) {
lfrq = 16000400.0 /pp;
Serial.print(lfrq);
Serial.print(" Hz ");
Serial.print(lfrq/(2*((10525000000/299792458))));
Serial.print( " m/s ");
Serial.print(lfrq/(2*((10525000000/299792458)))*3.2808);
Serial.println( " fps ");
delay(500);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.print(lfrq/(2*((10525000000/299792458)))*3.2808);
display.display();
display.print(" fps");
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(20, 30);
display.display();
display.clearDisplay();
delay(500);
}
}
Before power OLED Display.
HB100 activated with movement
FreqPeriod Library Test
0.16 Hz 0.00 m/s 0.01 fps
8.69 Hz 0.12 m/s 0.41 fps
25.74 Hz 0.37 m/s 1.21 fps
42.48 Hz 0.61 m/s 1.99 fps
2.76 Hz 0.04 m/s 0.13 fps
After power OLED Display
HB100 activated with No movement
6042.45 Hz 86.32 m/s 283.20 fps
5164.75 Hz 73.78 m/s 242.06 fps
5596.50 Hz 79.95 m/s 262.30 fps
5367.46 Hz 76.68 m/s 251.57 fps
5502.20 Hz 78.60 m/s 257.88 fps
5655.85 Hz 80.80 m/s 265.08 fps
5023.67 Hz 71.77 m/s 235.45 fps