Pages: [1]   Go Down
Author Topic: Arduino Due with USB Weatherboard  (Read 836 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone done this project yet, using the Due with the sparkfun USB weatherboard. I have been trying to get them to work together but there is no code that is designed for the Due with the weatherboard. I must be hooking into the wrong input on the Due. Any help would be great.


Code:
String weatherSentence = "";  // string to read data from the weather board
int ready = 0;                // used to mark when we have a complete string to process
char data;                    // use to read a byte from the serial
char charArray[100];          // create a char 100 position char array por parsing the data

unsigned long humidity=0, fahrenheit=0, celcius=0, SCPfahrenheit=0, presure=0;

void setup() {
  Serial1.begin(9600);        // starts the second hardware serial port at 9600 to communicate with the weather board
  Serial.begin(9600);         // starts the serial at 9600
  pinMode(48, OUTPUT);        // turn ON the board LED for diagnostics
  digitalWrite(48, HIGH);    
}

void loop() {
  while(Serial1.available() > 0) {  // if data vailable from the weather board
    data = Serial1.read();          // read it
    if((data != '\n')) {            // if no end of line
      weatherSentence += data;      // add it to the string
    }
    else {  // if end of line reached, readu to parse the buffer
      ready = 1;
      break;
    }  
  }
  if(ready == 1) {                         // parse the buffer
    if(weatherSentence.startsWith("#")) {  // verify if it is a good reading
      // Serial.println(buffer);           // uncomment just to see what we got
      weatherSentence.toCharArray(charArray, 100);  // get the characters copied into charArray of size 100
      processReading(charArray);           // parse the char array extracting the data
    }
    weatherSentence = "";                  // clean up the string for next reading
    ready = 0;
  }
}

// function that parses information received in a char array
void processReading(const char packet[]) {
  byte i;
  char* endptr;

  // start parsing
  i = 0;
  i++;
  humidity = strtod(&packet[i], &endptr);       // next field: humidity

  while(packet[i++] != ','); // next field: fahrenheit
  fahrenheit = strtod(&packet[i], &endptr);

  while(packet[i++] != ','); // next field: celcius
  celcius = strtod(&packet[i], &endptr);

  while(packet[i++] != ','); // next field: SCPfahrenheit
  SCPfahrenheit = strtod(&packet[i], &endptr);

  while(packet[i++] != ','); // next field: presure
  presure = strtod(&packet[i], &endptr);

  while(packet[i++] != ','); // next field: counter

  while(packet[i++] != '$'); // next field: checksum

  Serial.print("humidity: ");
  Serial.print(humidity, DEC);
  Serial.print(" fahrenheit: ");
  Serial.print(fahrenheit, DEC);
  Serial.print(" celcius: ");
  Serial.print(celcius, DEC);
  Serial.print(" SCPfahrenheit: ");
  Serial.print(SCPfahrenheit, DEC);
  Serial.print(" presure: ");
  Serial.println(presure, DEC);
}
« Last Edit: April 16, 2013, 07:46:31 pm by awest5 » Logged

US
Offline Offline
Full Member
***
Karma: 4
Posts: 183
Electronics are the new Legos
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what are your symptoms - hangup, no data, garbled data?  Is the board compatible with 3.3 volt logic on Due?. Are you connected to rx1 and tx1 and you have rx of board to tx of due and visa versa?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Powering the Arduino by USB connection right now. I'm sending 5V from the Arduino to the Weatherboard, and I have the RX-1 from the Weatherboard to the TX1 on Arduino and TX-0 on Weatherboard to RX1 on Arduino. No data being received to the arduino from the Weatherboard.
Logged

US
Offline Offline
Full Member
***
Karma: 4
Posts: 183
Electronics are the new Legos
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can the weatherboard communicate at 3.3 volt?  if it is using 5v signals it could fry the Due input rx
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Weatherboard is suppose to be operated between 3.7-12V
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a 3.3V regulator within the board to limit voltage
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Please do not cross-post.
Logged

Pages: [1]   Go Up
Jump to: