15-R183275-SN-3003-CFSFX-N01.pdf (3.6 MB)
Please help me to get data from sensor module. Data sheet attached
15-R183275-SN-3003-CFSFX-N01.pdf (3.6 MB)
What Arduino hardware are you using and what have you tried so far?
Post your code if you would like further assistance.
ds
Okay, let me try to work through this problem. The user wants to get data from their sensor module, which is an all-in-one weather station using Modbus-RTU over RS485. The datasheet they provided has a lot of information, so I need to parse it step by step.
First, I'll start by identifying the key sections mentioned. The communication protocol is Modbus-RTU, which I'm somewhat familiar with. The device uses RS485, so wiring will involve connecting the A and B lines correctly. The default address is 0x01, and the baud rate is 4800, but it can be changed. The data frame format follows standard Modbus-RTU with CRC checking.
Looking at the register addresses, each parameter (wind speed, temperature, humidity, etc.) has a specific register. For example, wind speed is at address 500 (which is 0x01F4 in hex). The user will need to send a Modbus command to read these registers. Since the data is scaled (e.g., wind speed is 100 times the actual value), I need to make sure to mention that scaling in the example code.
The user is likely using a microcontroller like Arduino or Raspberry Pi. I should provide examples for both. For Arduino, they'll need an RS485 to TTL converter, like the MAX485 module. The code will involve setting up the serial port, sending the correct query frames, and processing the responses. For Raspberry Pi, using Python with libraries like pymodbus or minimalmodbus would work, but sometimes direct serial communication with struct and crcmod is easier.
I should also note the wiring: brown and black for power (10-30V DC), yellow/green for 485-A, blue for 485-B. It's important to mention that the A and B lines shouldn't be reversed and that the device address must be unique on the bus.
Potential issues could be incorrect baud rate, wrong COM port, or CRC errors. The troubleshooting section in the datasheet lists common problems, so I should summarize those, like checking connections, ensuring correct driver installation for USB to RS485 converters, and adjusting the polling interval.
I'll structure the answer by first outlining the protocol details, then wiring instructions, followed by example code for Arduino and Python. Finally, I'll include troubleshooting tips. I need to make sure the code examples are clear, showing how to construct the Modbus query, send it, read the response, and convert the data using the scaling factors provided in the datasheet.
Wait, the user might not be familiar with Modbus function codes. The datasheet mentions using function code 0x03 (read holding registers). So each query will be a read request starting at a specific register address for a certain number of registers. For example, reading wind speed is one register at 500, temperature and humidity might be two registers starting at 504 (humidity) and 505 (temperature).
Also, the response frame's data needs to be parsed correctly. For instance, the wind speed example in the datasheet shows a response with two bytes, which is combined into a 16-bit integer, then divided by 100. Temperature might be a 16-bit signed integer (since it can be negative) which is handled by checking if the value exceeds 32767 and subtracting 65536 if so, then dividing by 10.
In the Arduino code, using the SoftwareSerial library for the MAX485 module, setting the RE and DE pins to control transmission and reception modes. The code should send the query, wait for the response, read the bytes, compute the CRC to verify, then extract and scale the data.
For Python, using the pymodbus library's ModbusRTUClient would simplify things, but if that's not available, using serial directly with struct.pack and crc calculation would work. The user needs to install necessary libraries like crcmod for CRC calculations.
I should also mention calibration registers, like zeroing the wind speed or rainfall, but maybe that's advanced. Focus first on reading data.
Check if the user has the configuration software mentioned in the datasheet. If they can connect with that, it's a good first step to test communication before coding. But since they want to get data programmatically, the code examples are essential.
Make sure to highlight important details like the default address and baud rate, scaling factors, and the need for correct power supply. Also, note that multiple sensors can be on the same bus with unique addresses, but the configuration software only works with one at a time.
Here's a concise guide to interface with your SN-*-FSXCS-N01 weather station using Modbus-RTU over RS485:
1. Key Protocol Details
- Modbus Address: 0x01 (default)
- Baud Rate: 4800 (default, configurable to 2400/9600)
- Registers (all values 16-bit):
| Parameter | Register Address | Scaling |
|---|---|---|
| Wind Speed | 500 (0x01F4) | ÷100 → m/s |
| Wind Direction | 503 (0x01F7) | Degrees (0-360°) |
| Humidity | 504 (0x01F8) | ÷10 → %RH |
| Temperature | 505 (0x01F9) | ÷10 → °C |
| PM2.5 | 507 (0x01FB) | Actual value |
| Rainfall | 513 (0x0201) | ÷10 → mm |
2. Wiring
| Sensor Wire | Connection |
|---|---|
| Brown | +10-30V DC |
| Black | GND |
| Yellow/Green | RS485-A (A+/TX+) |
| Blue | RS485-B (B-/TX-) |
3. Arduino Example Code
#include <SoftwareSerial.h>
#define RE 7
#define DE 6
SoftwareSerial modbus(2, 3); // RX, TX
// Modbus query for Wind Speed (Register 500)
const byte query[] = {0x01, 0x03, 0x01, 0xF4, 0x00, 0x01, 0xC4, 0x04};
void setup() {
Serial.begin(9600);
modbus.begin(4800);
pinMode(RE, OUTPUT);
pinMode(DE, OUTPUT);
}
void loop() {
digitalWrite(RE, HIGH);
digitalWrite(DE, HIGH);
modbus.write(query, sizeof(query));
delay(10);
digitalWrite(RE, LOW);
digitalWrite(DE, LOW);
if (modbus.available() >= 7) {
byte response[7];
modbus.readBytes(response, 7);
// Verify CRC here (omitted for brevity)
int windSpeed = (response[3] << 8) | response[4];
float windSpeed_mps = windSpeed / 100.0;
Serial.print("Wind Speed: ");
Serial.println(windSpeed_mps);
}
delay(1000);
}
4. Python Example (Raspberry Pi)
import serial
import crcmod
crc16 = crcmod.mkCrcFun(0x18005, rev=True, initCrc=0xFFFF)
def read_register(ser, address, reg):
cmd = bytes([address, 0x03, (reg >> 8), (reg & 0xFF), 0x00, 0x01])
crc = crc16(cmd).to_bytes(2, 'little')
ser.write(cmd + crc)
response = ser.read(7)
if len(response) == 7:
value = (response[3] << 8) | response[4]
return value / 100.0 # Wind speed scaling
return None
ser = serial.Serial('/dev/ttyUSB0', baudrate=4800, timeout=1)
wind_speed = read_register(ser, 0x01, 500)
print(f"Wind Speed: {wind_speed} m/s")
5. Troubleshooting
- No Response:
- Check A/B line polarity
- Verify power (10-30V DC)
- Test with the manufacturer's configuration software first
- CRC Errors:
- Use proper CRC calculation (polynomial 0x8005, little-endian)
- Negative Temperatures:
- Handle as 16-bit signed integers:
python
Copy
temp = (response[3] << 8) | response[4] if temp > 32767: temp -= 65536
4. Multiple Sensors:
- Change addresses using configuration software
- Ensure unique addresses on the bus
If this code does not work you will have to specify more precisely what hardware you use and what you want the code to do.
Post an annotated schematic of how you have connected everything. Be sure to include all connections, power, ground, power sources and any other external hardware.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.