Go Down

Topic: MKR NB not working when powered through battery socket (Read 200 times) previous topic - next topic

JohannaB

I have posted regarding the MKR board before but it seems to never stop giving me toubles.

I am trying to run PubSubClient to connect to an MQTT broker with my Arduino MKR NB 1500. When connected to the computer via USB it works completely fine, but as soon as I power it through the battery socket it gets stuck in the "connecting to mqtt-broker" state.

Has anyone else had issues with this? I have tried different voltages on the battery(which is in fact a simulated battery) with no luck. I have also measured so that it stays above the 3.7V limit at all times.

I would be very thankful for any help.

pert

What is the current rating of your simulated battery? The radios can draw a surprising amount of current during communication and if your power supply can't provide enough current then the communication fails.

JohannaB

Hmmm.. I have been running it as a power box with a maximum output on 500mA. It goes to about 400mA when communicating with the network so Im not sure the current would be an íssue.

I actually solved it somehow. On the computer it is enough to run

Code: [Select]

NBClient client;
PubSubClient conn(client);

  boolean connected = false;
  while (!connected) {
    if ((nbAccess.begin(PINNUMBER) == NB_READY) &&
        (gprs.attachGPRS() == GPRS_READY)) {
      connected = true;
    } else {
      delay(1000);
    }
  }



in the setup and then running conn.connect to connect to the broker. But when connected through the battery socket it only works when adding

Code: [Select]



// if the NBclient is not connected, connect it
if(!client.connected()){
    Serial1.println("NBclient not connected");
    connect_modem();
}
connect_modem(){
  boolean connected = false;
  while (!connected) {
    if ((nbAccess.begin(PINNUMBER) == NB_READY) &&
        (gprs.attachGPRS() == GPRS_READY)) {
      connected = true;
    } else {
      delay(1000);
    }
  }
}


before trying to connect to the broker. It then works with no issues. I find this very strange since it seems I am doing the same thing twice but still getting different results.

Do you have any suggestions? Could it be the current or is it more likely to be something else? There is a slight voltage drop when the current goes up to 400mA, but it still stays well over the lower limit. I have also tried many different input voltages and 2 different MKR boards but the problem seems to remain. Could the drop in voltage have an impact on the functionality even though it doesnt go below the limit?

Thanks for your response!

kickouille

Johanna,

I am also a very frustrated MKR NB owner... In summary, I'm now experimenting with the third board shipped by Arduino, as two previous ones were found faulty.

I found out that power management on this board is different than the one on the first board I got.
First board was behaving more like the MKR GSM.

Second board behaves the same way as the third board.

First thing first, do you experience the same?

Interestingly enough, my setup works best when running on battery only... But in certain conditions.

Also, one point if you didn't already do that. In the code, remove
Code: [Select]
while (!Serial);
If any, as it would wait for the Serial connection to the PC to be established.
On battery only this never happens, so you would end up staying in that loop.

May I ask you to try this and tell me if you get the same:

Scenario 1:
1) Connect a charged battery only -> code working, MQTT connection established and stable, keepalives exchanged, green LED slighly ON, very dimmed, but expected
2) Connect a USB power supply to USB port -> green LED goes fully ON, board freezes, not exactly sure where in the code, but my MQTT connection goes of, and I get disconnected from operator's network, and orange LED (charging) stays off.
3) Short press reset button: orange LED comes ON. Connects to my MQTT broker is established, however no subsequent MQTT traffic (I don't publish or subscribe to anything, I only send keepalives), and connection times out on broker side.
4) Disconnect USB power -> orange LED goes off, green LED dimms a bit, but not as much as in point 1. It's on a bit dimmed as it is on the MKR GSM when running on battery only. No MQTT connection coming in.
5) Push reset button again, and we go back to point 1.

Scenario 2:
1) Connect USB power source only -> green LED goes ON, orange LED fast blink, which is expected as no battery is connected, no MQTT connection coming in to my broker.
2) Short press reset button -> green LED stays ON, this time orange LED doesn't fast blink, still no MQTT connection coming in.
3) Connect the battery -> same as point 2
4) Short press reset button -> orange LED comes ON, however no connection to my MQTT broker.
5) Double press to go in bootloader mode -> charging LED goes OFF, built in LED fades up and down.
6) Short press to go out from bootloader mode: orange LED comes ON. Connects to my MQTT broker is established, however no subsequent MQTT traffic, and connection times out on broker side.
7) Disconnect the USB power source: orange and green led are both still on! Yes, you heard me, charging LED is on even though only battery is connected, at least for some time, then it goes off, green led still on (it should not as per documentation when battery only is used). And no connection to my MQTT broker
8) Short press reset button -> back to scenario 1, point 1, stuation which is the only stable one in my case.

It took me ages to figure ths out, because of having to visibility on what is happening. With the MQTT connection, I can clearly see when that work or not.

No be noted that all of this seems to behave differently when USB connection is make to a PC instead of a bear power source...

So that make very difficult to understand where all of this stucks...

Regards

JohannaB

Hi!

Thank you for your long reply. "nice" to know someone is as frustrated as me..

I did remove the !Serial part. But thanks anyways :)

Interesting that yours only works on battery. Is it connected to the battery socket? Because I am experiencing the opposite: the connection is only stable when connected to the USB.

So to answer your questions;
Scenario 1:
1) Not working unless I add the code
Code: [Select]

// if the NBclient is not connected, connect it
if(!client.connected()){
    Serial1.println("NBclient not connected");
    connect_modem();
}
connect_modem(){
  boolean connected = false;
  while (!connected) {
    if ((nbAccess.begin(PINNUMBER) == NB_READY) &&
        (gprs.attachGPRS() == GPRS_READY)) {
      connected = true;
    } else {
      delay(1000);
    }
  }


before trying to connect to the broker. Very strange, since thats already done once in the setup. Green light is slightly on.
2) Green led goes on, connection working fine without the above code in the reconnect method or setup.
3) Works as expected, resets the program if connected to USB port
4 & 5 I am not having the same strange behavior as you do. But im not sure you should have the battery and usb connected at the same time since it should then charge the battery? That might interfere with the code, but Im not sure.


Scenario 2:
1) Same as yours but it connects to the broker.
2) As expected, green led on and no blinking. But the MQTT connection comes in.
3) 4) if we connect the battery here I suppose it will just charge the battery
5) 6) I dont have the same behavior.. hmmmm. Is there something missing in your code? Or did you get a faulty one again? Are you using the RTC library? I have found that it doesnt work properly with the MKR NB board.

I agree that troubleshooting this is a mess. There are inconsistent behaviors and no obvious mistakes. It seems to me to be a hardware issue which makes me wonder if its even worth continuing troubleshooting.

I love arduino but I dont know if releasing a "low power consuming" IoT arduino that cant handle power consumption stuff was the best idea.. ;)

pert

[quote author=JohannaB link=msg=4243502 date=1563267567There is a slight voltage drop when the current goes up to 400mA, but it still stays well over the lower limit. I have also tried many different input voltages and 2 different MKR boards but the problem seems to remain. Could the drop in voltage have an impact on the functionality even though it doesnt go below the limit?
[/quote]
How are you measuring this?

I dont know if releasing a "low power consuming" IoT arduino that cant handle power consumption stuff was the best idea.. ;)
Low power is about average power consumption. A device that sleeps at a few microamps 98% of the time, runs at a few milliamps 1.9% of the time, and draws 400 milliamps .1% of the time is pretty low power consuming, but it still needs a power supply that can provide those bursts of current when needed.


JohannaB

I am measuring it with an Otii device, made for IoT energy optimization. (https://www.qoitech.com/)

I am aware that this is about average consumption. If it would sleep at a few microamps I would be very happy, but it draws at least 10mA in regular sleep mode. When trying to put the modem to sleep with AT commands and PSM settings the power consumption actually goes up. This is an issue that I have addressed in a previous post on the forum. Thanks for the input though!


pert

If it would sleep at a few microamps I would be very happy, but it draws at least 10mA in regular sleep mode. When trying to put the modem to sleep with AT commands and PSM settings the power consumption actually goes up. This is an issue that I have addressed in a previous post on the forum.
The numbers I mentioned were just a hypothetical example, but I understand what you're saying. 10 mA sleep current is not much fun. I'm following that thread and it's quite unfortunate. Sadly, I don't have any experience in that area to help you out with the issue, but I'm interested to learn of the solution when you find it.

Go Up