I followed this tutorial: http://www.instructables.com/id/Arduino-Wireless-SD-Shield-Tutorial/?ALLSTEPS
but it is not working for me.
Setup
Transmitter:
- Mega 2560
- Arduino Wireless Protoshield SD
- XBee 2mW Wire Antenna - Series 2 (ZigBee Mesh)
Code:
void setup() {
// initialize serial communication:
Serial.begin(9600);
}
void loop(){
delay(1000);
Serial.println('h');
delay(1000);
}
I have the switch on the shield on "USB" while uploading and can see "h"'s printed in the serial window after uploading. Switching to "Micro" after that.
Receiver:
- Uno R3
- Arduino Wireless Protoshield SD
- XBee 2mW Wire Antenna - Series 2 (ZigBee Mesh)
Code:
int sentDat;
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
sentDat = Serial.read();
if(sentDat == 'h'){
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
}
}
}
Again, having the switch to USB when uploading and seeing the led blink when sending an "h" over serial. Then switching to "Micro".
And then: Nothing!
How can I troubleshoot this?
How can I troubleshoot this?
Skip the xbee for the time being and do testing between the two using wire between the tx/rx/gnd on the boards. Once that works, then add the xbees. Below is some simple arduino to arduino serial test code.
//zoomkat 3-5-12 simple delimited ',' string tx/rx
//from serial port input (via serial monitor)
//and print result out serial port
//Connect the sending arduino rx pin to the receiving arduino rx pin.
//Connect the arduino grounds together.
//What is sent to the tx arduino is received on the rx arduino.
//Open serial monitor on both arduinos to test
String readString;
void setup() {
Serial.begin(9600);
Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}
void loop() {
//expect a string like wer,qwe rty,123 456,hyre kjhg,
//or like hello world,who are you?,bye!,
if (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
if (c == ',') {
if (readString.length() >1) {
Serial.print(readString); //prints string to serial port out
Serial.println(','); //prints delimiting ","
//do stuff with the captured readString
readString=""; //clears variable for new input
}
}
else {
readString += c; //makes the string readString
}
}
}
@zoomkat thanks for your answer. it made me think...
I yanked the shield from the mega and crossed tx/rx from the Mega to the shield. I also connected the 6 isp connections plus 5v, 3.3v and GND from the mega to the shield.
I then connected mega's rx with uno's rx and tx with tx with wires and my blink sketch worked!
I had the switches on the shields both to USB (http://arduino.cc/en/Main/ArduinoWirelessShield)
but then, when I remove the rx/tx wires the communication is dead. I switched the shield to Micro mode and back to USB, i played around with switching rx / tx... but no luck.
not sure if I need to make more connections from the mega to the shield... unfortunately it's not on shieldlist.org.