RS485 SEN0482 SEN0483 Wind Speed Direction Arduino

Hello,

I am posting this to help past me and others.

Long story short I wanted to build a weather station with the parts listed below but had trouble with a few things:
Arduino RS485 Shield DFR0259
RS485 SEN0482 Wind Direction senor
RS485 SEN0483 Wind Speed Sensor

Put the Arduino RS485 shield in “auto” mode
When uploading a sketch move the other switch to “off” and then back to “on” when the upload is complete

Because both sensors come by default with the same address you will need to change one. You can change either one. I used this code to change it:

byte address_ref_frame[] = {0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0xFA, 0x00};
byte buf[11];

void setup(){   
Serial.begin(9600);   
Serial.println("Serial started");

Serial.println("-----------------------------------------------");    
Serial.println("Send");   
delay(1000);   
Serial.write(address_ref_frame, sizeof(address_ref_frame));   
Serial.flush();   
Serial.readBytes(buf, 11);   
delay(1000);

Serial.println("Buffer");   
Serial.println(buf[0], HEX);   
Serial.println(buf[1], HEX);   
Serial.println(buf[2], HEX);   
Serial.println(buf[3], HEX);   
Serial.println(buf[4], HEX);   
Serial.println(buf[5], HEX);   
Serial.println(buf[6], HEX);   
Serial.println(buf[7], HEX);   
Serial.println(buf[8], HEX);   
Serial.println(buf[9], HEX);   
Serial.println(buf[10], HEX);   
Serial.println(buf[11], HEX);      
Serial.flush();

}

void loop(){
   
}

This will change the address from 02 to 03.

More info below:

This is the code that I used to read the wind speed sensor:

byte wind_speed_ref_frame[] = {0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x39};
byte buf[8];
int speed_dec_value;

void setup()
{
    Serial.begin(9600);
    Serial.println("Start");
}

void loop()
{
    
    Serial.println("-----------------------------------------------");
    Serial.println("Sending read request");
    delay(1000); // waiting for serial data to clear
    Serial.write(wind_speed_ref_frame, sizeof(wind_speed_ref_frame));
    Serial.flush();
    Serial.readBytes(buf, 8);
    delay(10);

    speed_dec_value = buf[4], DEC;
    Serial.println("");
    Serial.print("Wind Speed: ");
    Serial.print(speed_dec_value/10);
    Serial.println(" m/s");

    Serial.println("Buffer");
    Serial.println(buf[0], HEX);
    Serial.println(buf[1], HEX);
    Serial.println(buf[2], HEX);
    Serial.println(buf[3], DEC);
    Serial.print(buf[4], DEC);
    Serial.println(" !");
    Serial.println(buf[5], DEC);
    Serial.println(buf[6], HEX);
    Serial.println(buf[7], HEX);
    
    Serial.flush();
    delay (3000);
}

This is the code that I used to read the wind direction sensor:

byte wind_direction_ref_frame[] = {0x03, 0x03, 0x00, 0x00, 0x00, 0x01, 0x85, 0xE8}; //0x03, 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);
}

Remember that
0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x39 is the default frame to get the sensor values
0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0xFA, 0x00 is the frame to change the address to 03
0x03, 0x03, 0x00, 0x00, 0x00, 0x01, 0x85, 0xE8 is the frame to get the sensor value after changing the address to 03

Shout out to Jenna for helping me out with the request frame after changing the address.

Have fun!

3 Likes

Hi Carson,

Welcome to the forum :slight_smile:

Thanks for sharing your hard-won solution so that others can benefit from your hard yards.
Having both sensors default to the same address is a bit of a gotcha. We’ll look into updating our product pages with some extra information, or a link here so others can get up and running sooner.

2 Likes

I think it would be more convenient if wind direction and speed could be measured with a single module.

Yes! You are right.

We can read two sensors with one Arduino and one RS485 shield.
Just make sure that you change the address of one sensor. Look above in previous posts for details.

Wire them in parallel an use this code:

byte wind_speed_ref_frame[] = {0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x39}; // Request frame for wind speed sensor
byte wind_direction_ref_frame[] = {0x03, 0x03, 0x00, 0x00, 0x00, 0x01, 0x85, 0xE8}; // Request frame for wind direction sensor
// Remember that we changed the address of the wind direction sensor. So we have to use this request frame: 0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x39. This enables use to run both sensors at the same time parallel.

byte buf[8];
int speed_value;
int direction_value;
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("Serial started");
}

void loop()
{
    
    Serial.println("-----------------------------------------------");
    print_wind_speed(); // print wind speed
    delay (3000);

    Serial.println("-----------------------------------------------");
    print_wind_direction(); // print wind direction 
    delay (3000);
}


void print_wind_speed(){
    Serial.println("Sending read request to wind speed sensor");
    delay(1000); // waiting for serial data to clear
    Serial.write(wind_speed_ref_frame, sizeof(wind_speed_ref_frame));
    Serial.flush();
    Serial.readBytes(buf, 8); // read sensor data
    delay(1000);

    speed_value= buf[4], DEC; // convert data form hexadecimal to decimal
    Serial.println("");
    Serial.print("Wind speed: ");
    Serial.print(speed_value/10);
    Serial.println(" m/s");

    Serial.flush();
}

void print_wind_direction(){
    Serial.println("Sending read request to wind direction sensor");
    delay(1000);  // waiting for serial data to clear
    Serial.write(wind_direction_ref_frame, sizeof(wind_direction_ref_frame));
    Serial.flush();
    Serial.readBytes(buf, 8); // read sensor data
    delay(1000);

    direction_value= buf[3], DEC;// convert data form hexadecimal to decimal
    Serial.println(""); 
    Serial.print("Wind direction: ");
    Serial.println(direction_list[direction_value]);

    Serial.flush();
    }

Have fun

3 Likes

Thanks a lot.

1 Like