If you’ve ever wanted to build your own weather station, measuring wind speed is a great place to start. In this guide, I’ll show you how to connect an RS485 wind sensor to an Arduino. The trick is using a TTL-to-RS485 converter, which lets the Arduino talk to sensors that normally need higher voltages. I’ll walk you through the wiring and code so you can start reading wind speed data in no time.
This video is sponsored by Altium 365. Get your free workspace today and start transforming your design process today!
What You’ll Need
The links below are affiliate links. When you click on affiliate links in my articles or videos, it means I may earn a small commission if you make a purchase. These links are a way to support my work without costing you anything extra—the price you pay stays the same, whether you use the link or not. The commissions I earn help cover the costs of creating free content, so I can keep sharing knowledge and helping you with your DIY projects. It’s a win-win: you get the tools or products you need, and I get to keep creating helpful resources for everyone. Thank you for your support!
- Arduino Nano - https://s.click.aliexpress.com/e/_oFY8agX
- Modbus Wind Speed Sensor - https://s.click.aliexpress.com/e/_onZZHHd
- TTL to RS485 MAX485 Module - https://s.click.aliexpress.com/e/_on79JDz
- USB To RS485 Communication Module - https://s.click.aliexpress.com/e/_oEmSJaB
- Mini Breadboards - https://s.click.aliexpress.com/e/_oo6UGDh
Other items:
- Soil Temperature Humidity Sensor - https://s.click.aliexpress.com/e/_opZdCqj
- Soldering Station - https://s.click.aliexpress.com/e/_opSCltl
- Bench Power Supply - https://s.click.aliexpress.com/e/_opDtIkX
- Multimeter - https://s.click.aliexpress.com/e/_op4kptN
Wiring the Sensor
First, let's connect power to the sensor. Connect the red wire to your 12V power supply's positive and the black wire to negative. Now grab the TTL-to-RS485 converter module. The sensor's yellow wire (RS485 A) goes to the A terminal on the module, and the green wire (RS485 B) connects to B.
For the Arduino connection, hook up the module's DI pin to Arduino's D9 (for sending data), and RO to D8 (for receiving). The module's DE and RE pins need to be controlled too so I connected them to D2 (DE) and D3 (RE). You also need to connect the two grounds together. The module's GND goes to Arduino's GND, and this should also connect to your power supply's ground if you're using a separate one for the sensor.
The TTL to RS485 module needs to be powered from 5V so I connected its VCC pin to the Arduino Vin pin.
Setting Up the Code
The wind sensor uses Modbus protocol, which means we need to send it specific command packets to get data back. Each packet contains the sensor's address (usually 1 by default), a function code (like 03 for reading data), and a checksum. When the sensor replies, it sends back the wind speed value in a predefined format that we need to decode.
Since I wanted to still use the UART port on the Arduino to output debugging data to the serial monitor, I opted for using software serial for the communication with the sensor.
Below is the full code from the demo. For an in depth explanation of it, check out the video on the top of the article.
#include <SoftwareSerial.h>
#define DE_PIN 3
#define RE_PIN 2
#define RS485_RX 8
#define RS485_TX 9
SoftwareSerial modbusSerial(RS485_RX, RS485_TX); // RX, TX
uint8_t request[] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0xC4, 0x0B}; // Read 2 registers from address 0
void preTransmission() {
digitalWrite(DE_PIN, HIGH);
digitalWrite(RE_PIN, HIGH);
}
void postTransmission() {
digitalWrite(DE_PIN, LOW);
digitalWrite(RE_PIN, LOW);
}
void sendRequest() {
preTransmission();
for (int i = 0; i < sizeof(request); i++) {
modbusSerial.write(request[i]);
}
modbusSerial.flush(); // Wait for transmission to finish
postTransmission();
}
uint16_t crc16(uint8_t *buf, uint8_t len) {
uint16_t crc = 0xFFFF;
for (int pos = 0; pos < len; pos++) {
crc ^= (uint16_t)buf[pos];
for (int i = 0; i < 8; i++) {
if (crc & 1) {
crc = (crc >> 1) ^ 0xA001;
} else {
crc = crc >> 1;
}
}
}
return crc;
}
void writeToModule(String content) {
char* bufc = (char*) malloc(sizeof(char) * content.length() + 1);
content.toCharArray(bufc, content.length() + 1);
netSerial.write(bufc);
free(bufc);
delay(100);
}
void setup() {
pinMode(DE_PIN, OUTPUT);
pinMode(RE_PIN, OUTPUT);
postTransmission();
Serial.begin(9600);
delay(1000);
while (!Serial);
Serial.println("Started");
modbusSerial.begin(9600);
delay(50);
}
void loop() {
sendRequest();
delay(100); // Wait for sensor response
uint8_t response[9];
int bytesRead = 0;
unsigned long startTime = millis();
while (bytesRead < 9 && millis() - startTime < 200) {
if (modbusSerial.available()) {
response[bytesRead++] = modbusSerial.read();
}
}
if (bytesRead == 9) {
uint16_t crc_calc = crc16(response, 7);
uint16_t crc_recv = response[7] | (response[8] << 8);
if (crc_calc == crc_recv) {
uint16_t reg0 = (response[3] << 8) | response[4];
uint16_t reg1 = (response[5] << 8) | response[6];
float windSpeed_mps = reg0 * 0.1;
Serial.print("Wind speed raw: ");
Serial.print(reg0);
Serial.print(" | Wind speed mps: ");
Serial.print(windSpeed_mps);
Serial.print(" | Wind level: ");
Serial.println(reg1);
delay(100);
} else {
Serial.println("CRC mismatch");
}
} else {
Serial.println("No response or incomplete frame");
}
delay(20000); // Wait before next request
}
Expanding the System
Now that you've got one sensor working, the real fun begins. RS485's party trick is that you can daisy-chain multiple sensors on the same two wires (A and B). To add more sensors, you just connected them in parallel to the same A/B lines running from the converter. Each sensor needs its own unique Modbus address, which you'll usually set with dip switches or configuration software.
The wiring stays surprisingly clean - just run one twisted pair cable between all your sensors (twisting the wires helps reduce noise). Power becomes the main challenge though. While RS485 can handle long distances, voltage drop over extended cable runs means you might need to inject power at multiple points or use heavier gauge wires.
What's really cool is how little the Arduino code needs to change. You're already doing the hard part with the Modbus communication - adding more sensors just means sending to different addresses in your requests. Just watch your timing - if you query too fast, responses might overlap. I found 200-300ms between requests works perfectly.
Conclusion
Communicating with this RS485 wind sensor has been one of those projects that starts simple but really shows you the power of Arduino when working with industrial-grade components. That same RS485 bus can grow with your weather station, adding rain gauges, solar sensors, or anything else that speaks Modbus.
If you're thinking about trying this, don't let the Modbus protocol intimidate you. Yes, there's a learning curve with those byte commands and CRC checks, but once you get the pattern down (and maybe steal a few code snippets), you'll find it's actually quite logical. I've left my complete code example available for download so you can tweak it for your own sensors based on their datasheets.
The real magic happens when you start logging this data or connecting it to home automation.
What will you build? Share your projects in the comments - I'd love to see how you're using these sensors.