Skip to content

Instantly share code, notes, and snippets.

@tprynn
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tprynn/3ee9cd7f748cbdff8926 to your computer and use it in GitHub Desktop.
Save tprynn/3ee9cd7f748cbdff8926 to your computer and use it in GitHub Desktop.
/**********
* SmartThings Arduino Shield Passthrough
* For use on Arduino Mega
* author: github.com/tprynn
* Attach Shield normally with switch on 2/3.
* Jumper pins:
* - 18 (Tx1) to Shield 3 (Rx)
* - 19 (Rx1) to Shield 2 (Tx)
**********/
#define BUF_SIZE 512
void setup() {
delay(1500);
Serial.begin(115200);
Serial1.begin(2400);
}
byte buffer[BUF_SIZE];
int bytes;
void loop() {
if(Serial.available()) {
memset(buffer, 0, BUF_SIZE);
bytes = Serial.readBytes((char *)buffer, BUF_SIZE);
// local echo:
Serial.write(buffer, bytes);
Serial1.write(buffer, bytes);
}
if(Serial1.available()) {
memset(buffer, 0, BUF_SIZE);
bytes = Serial1.readBytes((char *)buffer, BUF_SIZE);
Serial.write(buffer, bytes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment