Need some help - will pay of course

I am attempting to build a vibration data logger that is stand alone or ethernet powered. I'd like it to log that data (sd card or ethernet back to a laptop) and be able to view the data in a graph as well as save the data for deeper analysis.

I have multiples of:
Arduino Uno R4
Ethernet Shield
Data Logger Shield
Adxl345 accelerometer
Piezo sensor
Vibration sensor
WT61 accelerometer+

I've spent the last few days studying, making lights flash, going through tutorials and watching hours of YouTube videos.

I am able to get the data I want into Arduino IDE and see the graphs like I need but am unable to make it stand alone (200' away from a laptop) or able to save the data. From what I've read, there is a huge gap between where I'm at and where I want to be. Time is my most valuable asset and I'd like to get this done sooner rather than later.

If you are able to 1: design this and walk me through the process (I do find this interesting) or 2: build it and ship it, we can make a deal. Please let me know if you can help.

For the one guy that always asks - Budget is to be determined after consulting with someone about the proper outcome. There's no way for me to put a dollar amount on something until I know what the other person can do, ya know?

There is a code difference in recording on an SD and sending the data back to the PC (which would need something to receive and record the data).

So may be first thing you need to decide is how the data is saved.

Another point is how do you plan to power the unit if not wall power is available.

Either some type of battery pack, or worst case I can probably use some type of extension cord and adapter. I'm open to either way to save the data.

It's pretty straightforward to write code to save data from the Arduino to a data logger SD card. If you power the Arduino + data logger with a USB battery pack, then it will run untethered from a computer and you can save and get the data off the SD card when you need it. What data logger shield do you have?
If your data logger is compatible with the SD Library, you will find example code in that library. Here's a good tutorial:

What aspect of this are you not able to do?

Ha! That was my line! :rofl:

1 Like

If you are going to use Ethernet, consider using POE. That solves the power issue at the remote device.

:rofl: I knew you'd show up! I saw you post on a few other threads.

I bought the "HiLetgo Data Logger Module Logging Shield Data Recorder Shield for Arduino UNO w/SD Card". I didnt see that Adafruit had one. I'm not sure how to program the arduino nano to record a timestamp, x, y, z value and store on the SD card in a csv format so I can easily plot it and search through it on a laptop. I'm only at the "hello, world" stage of this adventure.

if by timestamp you really mean the date and time, you'll need an RTC (real time clock) as well in your contraption. The HiLetgo Data Logger (which is basically a clone copy of the Adafruit's design) you bought does have this already on board so you are all set. The form factor makes it ideal for an Arduino UNO. If you have a Nano it's a large shield for such a small arduino and you might be better off (in terms of building something integrated) buying individual components likes an DS3231 RTC and a 5V compatible SD module.

Adafruit provided some documentation

that you should read and practice with their Code Walkthrough

You'll see it's not very much different than printing Hello World to the Serial monitor (see the Log sensor data example)

1 Like

Woah. Back up a bit. Vibration analysis emails frequency analysis, no? What are you looking to do - record the output of on board analytical routines, or recored raw data for offline post-event analysis? Makes a huge difference.

Thank you very much! I will read over this today.

Record raw data for offline post-event analysis.

So then, what frequency of data sampling? 10 Hz, 100 Hz, 1000 Hz? For how long? Because recording at high rates for long periods implies a lot of data space, and usually results in a need for efficiency.
Just trying to get a handle on the real requirements.

25-50 hz would probably be enough to see what I'd like to see.

The code to record a time stamp from the real time clock (RTC), to create a logfile (on the SD card) and to write comma-delimited data out to the log file are all provided in the Adafruit Data Logger Tutorial posted above (post 4). Your data logger looks to be essentially the same as the Adafruit one, so you don't necessarily need to be using the Adafuit data logger to be using the code provided in the Adafruit tutorial. After making sure you have included the appropriate libraries, it becomes largely a copy and paste exercise to get this working.

Here is the code (copied from the link above) for getting a time stamp and writing it to the logfile, all of which is happening inside of the loop() function:

  DateTime now;

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
  
  digitalWrite(greenLEDpin, HIGH);

  // log milliseconds since starting
  uint32_t m = millis();
  logfile.print(m);           // milliseconds since start
  logfile.print(", ");    

  // fetch the time
  now = RTC.now();
  // log time
  logfile.print(now.get()); // seconds since 2000
  logfile.print(", ");
  logfile.print(now.year(), DEC);
  logfile.print("/");
  logfile.print(now.month(), DEC);
  logfile.print("/");
  logfile.print(now.day(), DEC);
  logfile.print(" ");
  logfile.print(now.hour(), DEC);
  logfile.print(":");
  logfile.print(now.minute(), DEC);
  logfile.print(":");
  logfile.print(now.second(), DEC);

...and here is the code (also copied from the link provided above) for writing comma-delimited data to the logfile:

int photocellReading = analogRead(photocellPin);  
  delay(10);
  int tempReading = analogRead(tempPin);    
  
  // converting that reading to voltage, for 3.3v arduino use 3.3
  float voltage = (tempReading * 5.0) / 1024.0;  
  float temperatureC = (voltage - 0.5) * 100.0 ;
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
  
  logfile.print(", ");    
  logfile.print(photocellReading);
  logfile.print(", ");    
  logfile.println(temperatureF);

... of course, this code is reading values from a photocell and the temperature reading and writing those to the logfile. You just need to read and write whatever data you need for the vibration data. As it stands, this code would read and write as fast as it is able to (as there is no delay). If you want data recorded only at less frequent intervals, then include a:

delay(1000); // a very crude way to slow down the data frequency to ~once per second
// for a more appropriate and more accurate method, look up and use a 'no-delay delay'
1 Like

Thank you for that reply, jb222. I'll get to working on that and see what I can do with it!

hello, simpler with an esp32
...

[PROJECT] ESP32 + ADXL345 + SD Card + Web Server (Live Vibration Logger)

Hi everyone,

I’m working on an autonomous vibration data logger using an ESP32. This example shows how to:

  • Connect an ADXL345 accelerometer (I²C)
  • Log vibration data to an SD card in CSV format
  • Host a web interface over Wi-Fi
  • Show live data and download the recorded file

This works great for testing a remote sensor over Wi-Fi (e.g., up to 60 meters away). Please feel free to comment or suggest improvements!

#include <Wire.h>
#include <Adafruit_ADXL345_U.h>
#include <SPI.h>
#include <SD.h>
#include <WiFi.h>
#include <WebServer.h>

// Wi-Fi credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

// ADXL345 accelerometer
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);

// Web server on port 80
WebServer server(80);

// File object for SD card
File dataFile;

// SD card CS pin (can vary depending on module)
#define SD_CS 5

void setup() {
  Serial.begin(115200);
  delay(1000);

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500); Serial.print(".");
  }
  Serial.println("\nWi-Fi connected. IP address: " + WiFi.localIP().toString());

  // Initialize the ADXL345 sensor
  if (!accel.begin()) {
    Serial.println("No ADXL345 found. Check wiring!");
    while (1);
  }
  accel.setRange(ADXL345_RANGE_16_G); // Optional: max sensitivity range

  // Initialize SD card
  if (!SD.begin(SD_CS)) {
    Serial.println("SD card initialization failed!");
    while (1);
  }
  Serial.println("SD card ready.");

  // Create a new CSV file or append to existing one
  dataFile = SD.open("/vibration.csv", FILE_WRITE);
  if (dataFile) {
    dataFile.println("Time(ms),X,Y,Z");
    dataFile.close();
  }

  // Web routes
  server.on("/", handleRoot);
  server.on("/vibration.csv", handleDownload);
  server.begin();
}

void loop() {
  // Read acceleration data
  sensors_event_t event;
  accel.getEvent(&event);

  // Append to SD card
  dataFile = SD.open("/vibration.csv", FILE_APPEND);
  if (dataFile) {
    dataFile.printf("%lu,%.2f,%.2f,%.2f\n", millis(), event.acceleration.x, event.acceleration.y, event.acceleration.z);
    dataFile.close();
  }

  // Serve web requests
  server.handleClient();

  delay(500); // Adjust sample rate as needed
}

// HTML page with live sensor values and download link
void handleRoot() {
  sensors_event_t event;
  accel.getEvent(&event);

  String html = "<!DOCTYPE html><html><head><title>Vibration Data</title></head><body>";
  html += "<h1>Live ADXL345 Data</h1>";
  html += "<p><strong>X:</strong> " + String(event.acceleration.x) + " m/s²</p>";
  html += "<p><strong>Y:</strong> " + String(event.acceleration.y) + " m/s²</p>";
  html += "<p><strong>Z:</strong> " + String(event.acceleration.z) + " m/s²</p>";
  html += "<p><a href=\"/vibration.csv\">Download CSV</a></p>";
  html += "</body></html>";

  server.send(200, "text/html", html);
}

// Handles CSV file download
void handleDownload() {
  File file = SD.open("/vibration.csv");
  if (file) {
    server.streamFile(file, "text/csv");
    file.close();
  } else {
    server.send(404, "text/plain", "File not found");
  }
}

:pushpin: Notes:

  • Replace "YOUR_SSID" and "YOUR_PASSWORD" with your actual Wi-Fi.
  • Connect to the ESP32’s IP address from any device on your network.
  • You can increase the sampling rate by lowering the delay(500) value.
  • CSV file will be saved to the SD card as /vibration.csv.
    ...

Any Arduino could perform that level of frequency analysis on site, and, for example, send the compressed results or trip an alarm if certain conditions are reached.

No need to send or store raw vibration data.