Arduino with xbee shield + mDot


(Yurbaggio) #22

I’m doing the same thing with the same devices. I can’t receive the ‘OK’ on the Serial monitor, when sending ‘AT’. I want to know where is the problem and how did you success. I’m looking for your reply.


(Yurbaggio) #23

I use an Arduino Uno with XBee and mdot. I connect them together, but I can’t receive the ‘OK’ on the Serial monitor, when sending ‘AT’. What should I do first? I wonder whether I miss some step.


(Yurbaggio) #24

Here I see you help everyone. I use the same devices as theirs, and I have the same problem. As you told them did, I did. But it didn’t work. I hope I can get help from them. How can I get his email as you did on the second floor. My email is yu.han2@jcu.edu.au. Thanks.


(Ivanrakilovsky) #25

@yurbaggio
Hi, my experience with Arduino Uno was not great.
Basically you have to use Software Serial to talk to the mdot, because Uno has only on serial.
I had much better experience with Arduino Leonardo as it has additional HW Serial.

In your case make sure you have set the correct baud rate - the default is 115200 on the mdot.
I would suggest - reduce the baud rate on the mdot - connect it via the mtech dev board and change it to something lower as the Software Serail library does not support 115200 or at least not reliably.

Then you have to use the Software Serial Port to talk to the mdot board and you can listen with the Monitor on the default HW Serial port for some output.


(Andy14) #27

I’ve got a mDot connected to TTN with an Arduino Uno, however I need the addition resources available from the Arduino Mega. When I tried porting the Uno code over and removing the software serial library, I no longer see any serial data in the serial monitor. Any thoughts?


#28

a code error ?


(Andy14) #29

My code for the mDot using an xBee shield and an Arduino Mega is the following:
//
void setup()
{
Serial.begin(9600); //configure serial port
Delay(1000); // 1 second delay to allow mDot to boot
Serial.send(AT+JOIN); //OTA to join TTN
Delay(500);
Serial.read(); //read response message from mDot
}

void loop()
{
if (Serial.available())
{
Serial.send(AT+SEND = Hello World); // Command data send to mDot
Delay(500);
Serial.read(); // read response message from mDot
Delay(500);
}
else
{
Serial.println(“error”);
}
}
//

Note that I have already configured the mDot previously to have a baud rate of 9600 along with the App EUI and App Key.


(Andy14) #30

Would you be able to share your Mega code for the mDot? I had it working on the Uno but and struggling getting it on the Mega for some reason.


(Ivanrakilovsky) #31

Hi Andy.

It is probably too late now - I’ve been very busy last two weeks and wasn’t looking at the forums.
Anyway - you could try this library:

Have in mind the default baud rate for the mDot is 115200 and unless you have changed it you should use that.

The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). So be sure you have connected your xbee shield to the correct serial - e.g. Serial1.

Without the library you could do something like that:
Assuming you have connected to Serial1 and you have kept the default baud rate:
void join() {
Serial.println(“join”);
// wake up
Serial1.println(“AT”);
// use factory defaults
Serial1.println(“AT&F”);
// public network mode
Serial1.println(“AT+PN=1”);
// network join OTAA
Serial1.println(“AT+NJM=1”);
// set AppEUI
Serial1.println(“AT+NI=0,” + appEui);
// set AppKey
Serial1.println(“AT+NK=0,” + appKey);
// application data port
Serial1.println(“AT+AP=2”);
// join
Serial1.println(“AT+JOIN”);
}

void send(String msg) {
Serial.println(“send”);
// send data
Serial1.println(“AT+SEND=” + msg);
}

void setup() {
Serial1.begin(115200);
join();
}

Sorry for the late answer.
Cheers,
Ivan


(Ivanrakilovsky) #32

Also check if you have properly connected TX from the xbee shield to RX on the mega and RX to TX respectively.