Reading RS485 Vibration Sensor SN-3001-WZ-N01 with Arduino
Reading RS485 Vibration Sensor SN-3001-WZ-N01 with Arduino
This guide walks you through wiring the SN-3001-WZ-N01 RS485 vibration sensor to an Arduino UNO R3 using a MAX485 breakout module, and writing code to read and display vibration data on both the Serial Monitor and an OLED screen.
Required Components
- Arduino UNO R3 with USB cable
- SN-3001-WZ-N01 RS485 vibration sensor (10-1600Hz, magnetic mount)
- MAX485 TTL-to-RS485 breakout module
- OLED 128×64 I2C display, 0.96 inch
- MB-102 Breadboard
- Jumper wires (M-M, M-F, F-F)
- 12V 5A DC adapter with 5.5×2.5mm jack
- (Optional) 9V 2A adapter for Arduino power
Wiring the Circuit
1. Connect MAX485 to Arduino UNO
| Arduino UNO | MAX485 |
|---|---|
| 5V | VCC |
| GND | GND |
| 2 (RX) | RO |
| 3 (TX) | DI |
| 7 | DE |
| 8 | RE |
2. Connect Sensor to MAX485
| SN-3001-WZ-N01 | MAX485 |
|---|---|
| B (Blue wire) | B |
| A (Yellow wire) | A |
3. Power the Sensor with 12V DC
| SN-3001-WZ-N01 | 12V Supply |
|---|---|
| Brown wire (V+) | 12V+ |
| Black wire (V-) | GND |
4. Connect OLED Display to Arduino
| Arduino UNO | OLED (I2C) |
|---|---|
| 5V | VCC |
| GND | GND |
| A4 (SDA) | SDA |
| A5 (SCL) | SCL |
Critical: All GND points (Arduino, MAX485, and the 12V supply) must be tied together at a common ground. Without a shared ground reference, the RS485 communication will fail to read data correctly.
Installing the Required Libraries
- Download the library package (OLED and SoftwareSerial) from MediaFire
- Extract the files using WinRAR or WinZIP
- Move the extracted folders to
Documents/Arduino/libraries/ - Restart the Arduino IDE
Arduino Code
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// RS485 communication pins
#define RS485_RX 2
#define RS485_TX 3
#define RS485_DE 7 // Driver Enable pin
#define RS485_RE 8 // Receiver Enable pin
// OLED display settings
#define OLED_SCREEN_WIDTH 128
#define OLED_SCREEN_HEIGHT 64
#define OLED_RESET -1
// Create SoftwareSerial instance for RS485
SoftwareSerial rs485(RS485_RX, RS485_TX);
// Create OLED display instance
Adafruit_SSD1306 display(OLED_SCREEN_WIDTH, OLED_SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// Configure DE/RE pins as outputs
pinMode(RS485_DE, OUTPUT);
pinMode(RS485_RE, OUTPUT);
// Start in receive mode: DE=LOW, RE=LOW
digitalWrite(RS485_DE, LOW);
digitalWrite(RS485_RE, LOW);
// Start hardware serial for debugging
Serial.begin(9600);
// Start software serial for RS485 at 9600 baud
rs485.begin(9600);
// Initialize OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("OLED init failed"));
for (;;);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.display();
Serial.println("RS485 Vibration Sensor Ready");
}
void loop() {
// --- Send read command to sensor via Modbus RTU ---
// Note: adjust the command below to match your sensor's datasheet
digitalWrite(RS485_DE, HIGH); // Enable transmitter
digitalWrite(RS485_RE, HIGH);
// Example: Read 10 Holding Registers starting at 0x0000
byte request[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x0A, 0xC5, 0xCD};
rs485.write(request, sizeof(request));
delay(10);
digitalWrite(RS485_DE, LOW); // Return to receive mode
digitalWrite(RS485_RE, LOW);
// --- Wait for and read response ---
delay(500); // Allow sensor to process
if (rs485.available()) {
byte response[64];
int len = 0;
while (rs485.available() && len < 64) {
response[len++] = rs485.read();
}
// Print raw data to Serial Monitor for debugging
Serial.print("Raw Data: ");
for (int i = 0; i < len; i++) {
Serial.print(response[i], HEX);
Serial.print(" ");
}
Serial.println();
// --- Decode data according to sensor protocol ---
// Note: adjust register offsets and data types per actual sensor manual
if (len >= 23) {
// Example: extract vibration and temperature values from response
// Actual register positions depend on sensor datasheet
int16_t vibration = (response[9] << 8) | response[10];
int16_t temperature = (response[11] << 8) | response[12];
// Display on Serial Monitor
Serial.print("Vibration: ");
Serial.print(vibration);
Serial.print(" | Temp: ");
Serial.print(temperature / 10.0);
Serial.println(" C");
// Display on OLED
display.clearDisplay();
display.setCursor(0, 0);
display.println("Vibration Sensor");
display.print("Freq: ");
display.print(vibration);
display.println(" Hz");
display.print("Temp: ");
display.print(temperature / 10.0);
display.println(" C");
display.display();
}
}
delay(1000); // Wait before next read cycle
}
Note: This is a skeleton sketch designed for reading Modbus RTU data from generic RS485 sensors. The register addresses, data offsets, and scaling factors must be adjusted according to the actual datasheet of the SN-3001-WZ-N01. If the values look incorrect, check the raw hex data in the Serial Monitor and verify against your sensor’s documentation.
Upload and Test Procedure
- Open Arduino IDE and paste the code above
- Select Board: Tools → Board → Arduino UNO
- Select Port: Tools → Port → COM (check in Device Manager)
- Click Upload
- Wait for “Done Uploading”
- Open Serial Monitor and set baud rate to 9600
- Connect the 12V power supply to the sensor
- Watch for vibration and temperature values on both the Serial Monitor and OLED screen
[image: Serial Monitor displaying vibration sensor readings with raw hex data visible]
Practical Test with a Hair Dryer
After uploading the sketch, try using a hair dryer to blow warm air near the sensor. You should observe:
- Temperature readings increase as warm air reaches the sensor
- Vibration values fluctuate as the motor’s vibrations propagate through the air
This quick test confirms the circuit is wired correctly and the sensor is functioning as expected.
Reference Video
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย