Measuring Wind Direction With the RS485 Sensor (SEN0482) and Arduino

by FuzzyPotato in Circuits > Arduino

3652 Views, 0 Favorites, 0 Comments

Measuring Wind Direction With the RS485 Sensor (SEN0482) and Arduino

PXL_20230212_004630374.jpg

This project demonstrates how to measure wind direction using an RS485 wind direction sensor (SEN0482) and an Arduino board. The RS485 sensor sends wind direction data to the Arduino, which reads the data and converts it into a readable format. The wind direction readings are displayed on the Serial Monitor for easy observation. The project includes wiring instructions and code for the Arduino board to perform the necessary operations.

Supplies

PXL_20230212_004630374.jpg
PXL_20230212_003727153.jpg
PXL_20230212_003734749.jpg
  • RS485 wind direction sensor (SEN0482)
  • Arduino board
  • UART to RS485 shield. I like this one (DFR0259)
  • USB cable

Wiring

PXL_20230212_003742420.jpg
PXL_20230212_003759526_exported_666_1676162648849.jpg
PXL_20230212_003827776.jpg
  1. Connect the RS485 to UART converter to the Arduino board.
  2. Connect the RS485 wind speed sensor to the RS485 to UART converter.
  3. Green wire to B-
  4. Yellow wire to A+
  5. Red wire to a 12v
  6. Black wire to ground
  7. Put the Arduino RS485 shield in “auto” mode. Auto mode takes care of some communication for us and makes our code simpler.


Arduino IDE.PNG
  1. Open the Arduino IDE and create a new sketch.
  2. Copy and paste the code provided into the sketch.
  3. Before uploading the code make sure to move the other switch to “off” and then back to “on” once the upload is complete. If you do not do this your Arduino and PC will not be able to communicate properly.
  4. Upload the code to the Arduino board.


byte wind_direction_ref_frame[] = {0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x39};


byte buf[8];

int wind_direction;

static const char *direction_list[] = {"North", "Northeast by North", "Northeast", "Northeast by East", "East", "Southeast by East", "Southeast", "Southeast by South", "South",

"Southwest by South", "Southwest", "Southwest by West", "West", "Northwest by West", "Northwest", "Northwest by North", "Invalid reading"};


void setup()

{

Serial.begin(9600);

Serial.println("Start");

}


void loop()

{

Serial.println("-----------------------------------------------");

Serial.println("Sending read request");

delay(1000);

Serial.write(wind_direction_ref_frame, sizeof(wind_direction_ref_frame));

Serial.flush();

Serial.readBytes(buf, 8);

delay(1000);


wind_direction = buf[3], DEC;

Serial.println("");

Serial.print("Wind Direction: ");

Serial.println(direction_list[wind_direction]);


Serial.println("Buffer");

Serial.println(buf[0], HEX);

Serial.println(buf[1], HEX);

Serial.println(buf[2], HEX);

Serial.print(buf[3], HEX);

Serial.println(" !");

Serial.println(buf[4], HEX);

Serial.println(buf[5], HEX);

Serial.println(buf[6], HEX);


Serial.flush();

delay (3000);

}

Testing

Serial Monitor.PNG
  1. Open the Serial Monitor in the Arduino IDE.
  2. Set the baud rate to 9600.
  3. Observe the readings from the wind direction sensor displayed in the Serial Monitor.


Conclusion

With this setup, you can read the wind speed values from the RS485 wind speed sensor and display it on the Serial Monitor. The code provided performs the necessary operations to read the wind speed values and convert it into a readable format. You can now use the wind speed readings for your own projects and applications. Happy tinkering!