NB-IoT examples

Is it possible to receive example code for the NB-IoT board so it will be able to send data without being connected to my laptop by USB?

Hi,

http://support.sodaq.com/sodaq-one/nb-iot/
Is currently under development.

I have some examples published on my personal git
https://github.com/janvl1234/Sodaq_NBIoT_examples

In the examples is a line “while (!DEBUG_STREAM);// Wait for serial monitor”
Comment this line out to let it work withouth the monitor open.

Regards,
Jan

Hi Jan,
just received my NB_IoT device. I possess some Arduino Uno’s, not a Leonardo.
Could you advice how to change your code to add the possiblitiy to communicate with an Uno instead of a Leonardo?

> #if defined(ARDUINO_AVR_LEONARDO)
> #define SerialOut Serial 
> #define UBLOX Serial1

Thanks in advance.

Regards,

Franz

1 Like

Hi @Jan Just like @Franz: different board (Genuino Uno) how to go about this?
eager to start playing the board I got today

I found the right constant but Serial1 is not declared in this scope
Adding:

#elif defined(ARDUINO_AVR_UNO)
#define SerialOut Serial
#define UBLOX Serial1

ends in error messages

the problem is that the Uno only has 1 serial port, so you cant connect to the modem and your PC at the same time.

The Arduino / Genuino Uno only has one hardware serial bus.
You can NOT use the usb debug !!

In the example below I have added SoftwareSerial.
With software serial you can, with the use of a 2nd Arduino board, see the debug information.

To program the Arduino Uno you have to take off the Sodaq NB-IoT shield.
Upload your sketch
Disconnect the usb cable.
Put the shield back on the Uno
Connect the usb cable.

In a ~30 seconds it will send the first message

Settings for the Uno below here:

Add the library

#include <SoftwareSerial.h>

Defines for the Arduino Uno

#elif defined(ARDUINO_AVR_UNO)
SoftwareSerial softSerial(10, 11); // RX, TX
// You can connect an uartsbee or other board (e.g. 2nd Uno) to connect the softserial.
#define DEBUG_STREAM softSerial 
#define MODEM_STREAM Serial

Also remove the following blocking line, this line waits forever if you don’t open a debug stream.

while ((!DEBUG_STREAM));// Wait for serial monitor

Happy programming!!

Regards,
Jan

Hi,

I’ve tried this and it works fine. I used a TTL-to-Serial-to-USB cable on port 10,11 and GND.

Regards

Erik
NB-IoT tester
Orange Belgium

1 Like

I adapted the code for the Arduino UNO in use according the advice above.
I added an USB Serial adapter using pins 10, 11, GND to another USB port on the same PC, opened another Serial Monitor from a second IDE instance on the new serial port to watch the SoftwareSerial DEBUG_STREAM messages.

Testprogramma:
Download van: https://github.com/janvl1234/Sodaq_NBIoT_examples

HTS221_HumidityTemperature_nbiot.ino
uit: Sensors_NB-IoT

Added code:

#include <SoftwareSerial.h>

#elif defined(ARDUINO_AVR_UNO)
SoftwareSerial softSerial(10, 11);  /// RX, TX
#define DEBUG_STREAM softSerial
#define MODEM_STREAM Serial

//  while (!DEBUG_STREAM);// Wait for serial monitor

I cannot upload a new program to the Arduino Uno without first removing the Sodaq NB_IoT shield. Is that normal? Is that also true for other Arduino types?
I doubt my Sodaq will last long when I have to remove the shield before any software update. Is that really what I have to do all the time?

Error shown:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xba

2 The DEBUG_STREAM shows:

SODAQ HTS221 Arduino Example

AT+CFUN=0

AT+CGDCONT=1,“IP”,“oceanconnect.t-mobile.nl”
rdResp: OK

AT+NCDP=172.16.14.20
rdResp: OK

AT+NSMI=0
rdResp: OK

AT+NNMI=0
rdResp: OK

AT+CFUN=1
rdResp: OK

AT+COPS=1,2,“20416”
rdResp: OK

AT+CSQ
rdResp: +CSQ:99,99
rdResp: OK

AT+CSQ
rdResp: +CSQ:99,99
rdResp: OK

************* 14 keer in totaal ***************

Failed to connect!

Serial Monitor of MODEM_STREAM (after each other not on separate lines):

AT
AT
AT
AT+CFUN=0
AT+CGDCONT=1,“IP”,“oceanconnect.t-mobile.nl”
AT+NCDP=172.16.14.20
AT+NSMI=0
AT+NNMI=0
AT+CFUN=1
AT+COPS=1,2,“20416”
AT+CSQ
********** 14 keer ************
AT+CSQ
AT+CSQ

So looking at the meaning of the AT commands: the Sodaq NB_IoT board does not get a connection to the network. Signal strength stays on 99,99.

3 Should I be able to enter AT commands from the Command line box at the top of the Serial Monitor?

What is wrong:

  1. on my setup using the Arduino Uno?
  2. on the standard software installation?
  3. on the hardware of the NB_IoT?

What is it I could try further?

Thanks in advance for your help. I know I am asking several questions in one message …

Franz

1 Like

Hi Franz

Normal for every board what had the same serial bus on the USB and 0/1.
Use a Sodaq ExploRer or Arduino Leonardo for example, these boards have a 2nd hardware serial.

https://shop.sodaq.com/en/explorer.html

The example you use is for the T-Mobile Network.
Where in Holland are you trying to connect?

Regards,
Jan

I had similar problem. Venray did not work, Venlo was ok. Wil test with different outdoor antenna on other location. Maybe I had a wrong AT command on other location.

No response from T-mobile on this issue… Reported by mail to theorie nb-iot mail address.

In near future i van create a map when driving through netherlands reporting where i do have reception. Maybelline someone else already has the shield in huis car :wink:

1 Like

Keep in mind when you drive around that you need to keep reconnecting to the network.
You are connected to one cell and there is no handover from cell to cell.

ok will do!

Now also working in Venray :wink: And successfully subscribed via MQTT to receive the messages. Looking good.
the AT+CGATT=1 to attach GPRS takes quite some time and usually gives some errors before a succesful attach.

Now testing the gps sample, but no luck yet. Maybe indoor bad reception. Will check further…

hm,

I got the same problem here.
Signal seem to be oke:

[rdResp]: +CSQ:99,99
[rdResp]: OK
>> AT+CSQ

[rdResp]: +CSQ:99,99
[rdResp]: OK
>> AT+CSQ

[rdResp]: +CSQ:99,99
[rdResp]: OK
Failed to connect!!!

but the modem can’t connect.

Inside or outsite the buiding the same issue.
Location is veenendaal netherlands.

Will check further.

Signal is not oke!

CSQ:99,99 means not available or not detectable!

After some testing from other locations it works.
I have manualy send some commands to the modem to reset.
I don’t know what hte issue was but it works now.

Hi Aart,

I’m happy to hear the board is working now.
The first time you try to connect to the network always takes more time, maybe on your board longer than usual.

Let me know if you have this problem also in the future.

Regards,
Jan

In Utrecht I had the same problem. First I saw +CSQ:99,99 all the time, then I baked a cake, drank coffee and tried again from the roof and then it worked. Not sure what made it work.