# Arduino with xbee shield + mDot

**URL:** <https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311>\
**Category:** MultiTech Gateways\
**Created:** [February 22, 2016, 7:26am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311 "2016-02-22T07:26:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [February 22, 2016, 7:26am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/1 "2016-02-22T07:26:38Z")

</div>

I want to use an arduino to connect to the conduit LoRa gateway, I have the xbee shield with the mDot,

before I can do anything, I want to make sure the mDot is communicating with arduino, but I dont have enough info to do this,

so, should the mdot just get and put messages using the “serial monitor” on the arduino?

I just have an empty hello script to test this…

```
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
 
}

```

then open the serial monitor and enter “+++” on the textField and then “send”…

will this be enough to test the modem?

are there any instructions on how to proceed with an arduino and xbee shield?

![](https://www.thethingsnetwork.org/forum/uploads/default/original/1X/a139bf2b8b8111d2fd86a4ef42e582d970af47e5.JPG)

Thanks!

---

<div class="post-metadata">

**Author:** ![Maj](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/maj/32/47732_2.png) [@Maj](https://www.thethingsnetwork.org/forum/u/Maj)\
**Post date:** [February 23, 2016, 4:01am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/2 "2016-02-23T04:01:32Z")

</div>

Hey Manuel, I sent you an email about getting it running.

But in summary, here are the commands you’ll need to issue to get onto TTN (without my //comments)

at+pn=1 // Set Public Network to true  
at+njm=0 // Set Network Join Mode to manual  
at+fsb=7 // Set Frequency Sub Band to whatever your Conduit is set to. Mine is 7  
at+ack=0 // Turn off acknowledgements (not supported by TTN yet)  
at+na=12345678 // Pick a number. This is the node address and should be unique for each node.  
at+nk=0,2B7E151628AED2A6ABF7158809CF4F3C // Set Network Key for TTN  
at+nsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Network Session Key for TTN  
at+dsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Data Session Key for TTN.

Then issue:

at+join  
at+send=HelloWorld

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [February 23, 2016, 7:51am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/3 "2016-02-23T07:51:27Z")

</div>

Hi Andrew!, thanks for the response, I will try to join the TTN, after my “hello world” happens,

I got another question please, will the mDot modem respond with any info when connected on serial monitor? like with an empty sketch can I just issue AT commands from serial monitor?

I also tried with just sending “AT” on the arduino “setup”, should I be able to see the response on the serial monitor?

```
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  Serial.print("AT");

}

void loop() {
  // put your main code here, to run repeatedly:

}

```

So far Im not getting any response, how to print the responses?, Im missing the basic setup 😕

Thanks!

---

<div class="post-metadata">

**Author:** ![Maj](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/maj/32/47732_2.png) [@Maj](https://www.thethingsnetwork.org/forum/u/Maj)\
**Post date:** [February 23, 2016, 8:06am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/4 "2016-02-23T08:06:29Z")

</div>

If you’re using an Arduino Uno, then there is only one UART, which is shared between the USB port and the mDot. Easiest way to test functionality is to use a blank sketch (no Serial.begin) and just open the serial monitor (at 115200). If you type “AT”, you should get an “OK” back from the mDot.

Your sketch above should work - almost! Change the Serial.print to Serial.println. Also, the sketch will probably run before your serial monitor gets connected, so maybe put a delay at the start.

If you have an Arduino Leonardo, then it has separate UART for the USB port and the mDot. In which case you’ll need a sketch to pass characters back and forth between the two ports. Like this:

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

void loop()  
{  
if (Serial.available()) Serial1.write(Serial.read());  
if (Serial1.available()) Serial.write(Serial1.read());  
}

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [February 24, 2016, 6:01am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/5 "2016-02-24T06:01:44Z")

</div>

hey Andrew, thanks for the help,  
serial monitor not happy yet to test,  
yes im using arduino uno, I did

> Easiest way to test functionality is to use a blank sketch (no Serial.begin) and just open the serial monitor (at 115200). If you type “AT”, you should get an “OK” back from the mDot

but no response yet from the serial monitor.  
Thanks getting there 😉 I ordered the mDot programmer [devKit], so is easier to user, also 10 mdots to start having fun…

Will continue checking this arduino interface, Thanks!

---

<div class="post-metadata">

**Author:** ![wills](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/w/7ea924/32.png) [@wills](https://www.thethingsnetwork.org/forum/u/wills)\
**Post date:** [February 28, 2016, 1:30am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/6 "2016-02-28T01:30:54Z")

</div>

hey @manuel

what are the model numbers of the devices you got? I’m looking to make a simple node to get started, and I think the mDots are the way to go here in Sydney, for now!

Also where did you get the hardware from? i hear you might be setting up a Things Network gateway in the coming months too?! phenomenal work!

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [March 3, 2016, 10:53am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/7 "2016-03-03T10:53:36Z")

</div>

hi @wills I got the mDot, multitech gateway and the programmer, from @maj email msg

> "  
> The gateways we use are Multitech Conduits: [http://www.multitech.com/models/94557202LFYou’ll](http://www.multitech.com/models/94557202LFYou%E2%80%99ll) also need an mCard: [http://www.multitech.com/models/94557300LFThe](http://www.multitech.com/models/94557300LFThe) nodes are Multitech mDots: [http://www.multitech.com/brands/multiconnect-mdotYou’ll](http://www.multitech.com/brands/multiconnect-mdotYou%E2%80%99ll) also need a LoRa (915Mhz) antenna for the mDot. I think the mCard for the gateway comes with one, but it’s just a small dipole. Good for indoors/testing.  
> You can buy them from [http://www.semiconductorstore.com](http://www.semiconductorstore.com)."

Im waiting now for more mDots and the programmer, let me know how you go.

Yes im setting up a network on Surry Hills, and inner west soon.  
:]

M.

---

<div class="post-metadata">

**Author:** ![wills](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/w/7ea924/32.png) [@wills](https://www.thethingsnetwork.org/forum/u/wills)\
**Post date:** [March 6, 2016, 7:07am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/8 "2016-03-06T07:07:41Z")

</div>

Thanks @manuel - can’t wait until your gateway is up and running! Thanks heaps for providing it.

I’ll grab an mDot to get started, but I’m not sure which is which. Which one did you get?

- MTDOT-915-M1-TRC-1 mDot 915 MHz SMT LoRa RF Pad (Single Pack)
- MTDOT-915-M1-UFL-1 mDot 915 MHz SMT LoRa UFL (Single Pack)
- MTDOT-915-X1-SMA-1 mDot 915 MHz XBee LoRa SMA (Single Pack)
- MTDOT-915-X1-UFL-1 mDot 915 MHz XBee LoRa UFL (Single Pack)
- MTDOT-915-X1P-SMA-1 mDot 915 MHz XBee LoRa SMA w/Programming Header

And is this the antenna you speak of? [http://www.semiconductorstore.com/cart/pc/viewPrd.asp?idproduct=50702](http://www.semiconductorstore.com/cart/pc/viewPrd.asp?idproduct=50702)

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [April 18, 2016, 11:35am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/9 "2016-04-18T11:35:47Z")

</div>

hI Andrew,  
thanks for the response,

Ok back now with the TTN!,  
I have an arduino Uno, and an eleven,  
i put the xbee shield, and load this firmware:

```
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup() {
  // put your setup code here, to run once:

  Serial.begin(115200);
  while (!Serial) {
 
   }

  Serial.println("started");

  mySerial.begin(115200);
  mySerial.println("AT");
}

void loop() {
  if (mySerial.available()) {

      Serial.print(mySerial.read());

  }
  if (Serial.available()) {

      Serial.print(Serial.read());

  }
}

```

but on serial response i get:

> started  
> 16325310610131179751310131310

I also tried leaving blank sketch as suggested, but i get no response at all,

I will by a db9 to usb cable and try with the mDot multitech programmer kit tomorrow,

Any suggestion please to make the AT response “OK” :]  
thanks!

---

<div class="post-metadata">

**Author:** ![Maj](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/maj/32/47732_2.png) [@Maj](https://www.thethingsnetwork.org/forum/u/Maj)\
**Post date:** [April 18, 2016, 11:29pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/10 "2016-04-18T23:29:32Z")

</div>

Hi Manuel. Change the occurrences of Serial.print to Serial.write

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [April 19, 2016, 12:30am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/11 "2016-04-19T00:30:12Z")

</div>

Yay Andrew!  
“OK” showing now!, thanks!

Now will start communication with gateway! … fingers crossed :}

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [April 19, 2016, 12:39pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/12 "2016-04-19T12:39:35Z")

</div>

Hi Andrew, thanks ok so this is the status, OK showing on serial port using arduino, on mac

got DB9 serial to USB cable

only worked so far on windows, so with the UDK, and using terminal program, can send commands AT to the LoRa module,

now other question please,

Thanks for the commands…

```
    at+pn=1 // Set Public Network to true
    at+njm=0 // Set Network Join Mode to manual
    at+fsb=7 // Set Frequency Sub Band to whatever your Conduit is set to. Mine is 7
    at+ack=0 // Turn off acknowledgements (not supported by TTN yet)
    at+na=12345678 // Pick a number. This is the node address and should be unique for each node.
    at+nk=0,2B7E151628AED2A6ABF7158809CF4F3C // Set Network Key for TTN
    at+nsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Network Session Key for TTN
    at+dsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Data Session Key for TTN.
    Then issue:
    at+join
    at+send=HelloWorld

```

here I dont know where i did set sub band,

> ```
> at+fsb=7 // Set Frequency Sub Band to whatever your Conduit is set to. Mine is 7
> 
> ```

where is this network key, session key, data session key?

> at+nk=0,2B7E151628AED2A6ABF7158809CF4F3C // Set Network Key for TTN  
> at+nsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Network Session Key for TTN  
> at+dsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Data Session Key for TTN.

how to get the band and the keys?  
where is this configured on the gateway?

Thanks!

Getting there 😛

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [April 20, 2016, 10:25am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/13 "2016-04-20T10:25:19Z")

</div>

Hey @maj Thanks a lot for the guidance!, I changed some things! now connected using DB9 cable, sending commands that way, next AT ardu and raspi, Chat soon… Thanks! :}

---

<div class="post-metadata">

**Author:** ![Pcandy](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/p/65b543/32.png) [@Pcandy](https://www.thethingsnetwork.org/forum/u/Pcandy)\
**Post date:** [June 18, 2016, 1:26pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/14 "2016-06-18T13:26:40Z")

</div>

hey Manuel, have you got the LoRa gateway and network up and running in Sydney?  
I’m keen to connect to others in Sydney who are interested in this space.  
Cheers  
Paul

---

<div class="post-metadata">

**Author:** ![manuel](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/manuel/32/443_2.png) [@manuel](https://www.thethingsnetwork.org/forum/u/manuel)\
**Post date:** [June 18, 2016, 11:33pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/15 "2016-06-18T23:33:30Z")

</div>

hi @Pcandy, yes! I got one running on Surry hills, @maj have a some more around Sydney [https://thethingsnetwork.org/c/sydney/](https://thethingsnetwork.org/c/sydney/) Chat soon :}

---

<div class="post-metadata">

**Author:** ![Maj](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/maj/32/47732_2.png) [@Maj](https://www.thethingsnetwork.org/forum/u/Maj)\
**Post date:** [August 13, 2016, 6:59am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/16 "2016-08-13T06:59:53Z")

</div>

FYI These commands are no longer valid since we now use the Australian band plan and also since TTN has moved to the new back end.

> [@manuel](#):
>
> ```
> at+pn=1 // Set Public Network to true
> at+njm=0 // Set Network Join Mode to manual
> at+fsb=7 // Set Frequency Sub Band to whatever your Conduit is set to. Mine is 7
> at+ack=0 // Turn off acknowledgements (not supported by TTN yet)
> at+na=12345678 // Pick a number. This is the node address and should be unique for each node.
> at+nk=0,2B7E151628AED2A6ABF7158809CF4F3C // Set Network Key for TTN
> at+nsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Network Session Key for TTN
> at+dsk=2B7E151628AED2A6ABF7158809CF4F3C // Set Data Session Key for TTN.
> Then issue:
> at+join
> at+send=HelloWorld
> 
> ```

> New commands to use on Multitech mDot’s are (for OTAA):  
> at+pn=1  
> at+njm=1  
> at+fsb=2  
> at+ack=0  
> at+ni=0,your\_app\_id  
> at+nk=0,your\_app\_key  
> at+join  
> at+send=HelloWorld

---

<div class="post-metadata">

**Author:** ![ivanrakilovsky](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ivanrakilovsky/32/6072_2.png) [@ivanrakilovsky](https://www.thethingsnetwork.org/forum/u/ivanrakilovsky)\
**Post date:** [July 29, 2017, 6:37am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/18 "2017-07-29T06:37:11Z")

</div>

Hi.

I have an Arduino Uno so I am using SoftwareSerial to talk to mDot.  
mDot flashed with AT Command Firmware v 3.0.0

I can write to the mDot serial, connect to TTN - no problem with that.  
But when I try to read data from the serial port it is scrambled and some parts are missing.

SoftwareSerial xBee(10, 11); // RX, TX

void setup() {  
Serial.begin(115200);  
delay(200);  
xBee.begin(115200);  
xBee.println(“ATI”);  
}

void loop() {  
if (xBee.available() \> 0) {  
Serial.write(xBee.read());  
}  
}

Result (sometimes it is different):  
Q)5)MultiTech mDot  
mFirmware : 3.0.0-mbed144  
Library : 3.0.0-

I have tried changing the baud rate on the mDot to 9600 instead of the default one, in case SoftwareSerial does not support 115200, but it did not help either.

I know it is an old thread, but it seems to be popular.  
What am I doing wrong? Does anyone have similar issues?

Thanks,  
I.R.

---

<div class="post-metadata">

**Author:** ![Maj](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/maj/32/47732_2.png) [@Maj](https://www.thethingsnetwork.org/forum/u/Maj)\
**Post date:** [August 1, 2017, 11:18pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/19 "2017-08-01T23:18:43Z")

</div>

I’ve had limited success with Software Serial. You could try AltSoftSerial ([https://www.pjrc.com/teensy/td\_libs\_AltSoftSerial.html](https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html)) which seems to be much more stable.

---

<div class="post-metadata">

**Author:** ![ivanrakilovsky](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ivanrakilovsky/32/6072_2.png) [@ivanrakilovsky](https://www.thethingsnetwork.org/forum/u/ivanrakilovsky)\
**Post date:** [August 1, 2017, 11:58pm UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/20 "2017-08-01T23:58:31Z")

</div>

Thank you for the suggestion.  
I have tried AltSoftSerial, the result was slightly better, but again not really reliable.  
I ended up using an Arduino Mega and hardware serial instead.

Even with the Mega I had to lower the baud rate of the mDot to 19200.  
But that works for me now.

At some point I might just replace the AT firmware and return just a few bytes (fixed length) for status codes.  
Or, Is there a way to turn off all the messages in the factory AT firmware and just read the statuses e.g. OK, ERROR?

---

<div class="post-metadata">

**Author:** ![Maj](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/maj/32/47732_2.png) [@Maj](https://www.thethingsnetwork.org/forum/u/Maj)\
**Post date:** [August 2, 2017, 1:55am UTC](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311/21 "2017-08-02T01:55:43Z")

</div>

Seems strange that you still have problems, even with Hardware Serial. I run mDots mainly on Arduino Leonardos (so hardware serial) and have no problems at 115200 baud with AT firmware v2.x. I haven’t tried v3 yet.

You could try @shaun’s [mDot Library](https://github.com/ShaunPrice/LoRamDot).

[Next page](https://www.thethingsnetwork.org/forum/t/arduino-with-xbee-shield-mdot/1311.md?page=2)
