MKR1310 CHRG led blinking and the device stops working properly

Hi,

I'm having some issues with MKR1310. I have two devices, one connected to 5v battery through VIN and the other connected to a Raspberry on USB. The device with the battery sends peridiocally data to the other one which then sends it via serial port to a script I'm running on Pi. Everything works perfectly until about one hour when both devices have their CHRG light blinking. Both then send gibberish via their respective methods (LoRa and serial) and require a reset to work again.

I have read this might be related to some kind of battery timeout feature. Anyone can comment on this?

Hi, @nevis_naattori
Welcome to the forum.

Can you please post schematic diagrams of your project?
What are you using as power supplies?
Do you have a DMM to measure your powewr supply voltage?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi Tom. Thanks for the quick reply.

Apologies for the rough schematics but I've attached them here

I have verified the input voltage going into the Arduino is 5V with a multimeter. The voltage is regulated via a DC-DC regulator that raises the 4.5V outputted by the battery pack to 5V.

The other device is just connected to a Raspberry Pi 4 running a Python script that listens to serial input via USB2.0.

To be more specific to my problem: both devices face the exactly same problem of essential stop running properly after an hour after which they stay powered, have their CHRG led blinking in orange, and output what I assume corrupted messages. Battery powered one for example still sends LoRa packets but they are not in a format that it sent during the previous hour. The other device on the other hand fails to properly connect via the serial port to Pi and the script it's running.

EDIT: Fixed the link for schematics.

Hi,
Thanks for the diagram.
Youi have 5V from the DC-DC converter going to the Vin pin.
Double check that, as usually that is the input for the on board 5V regulator, and it will need more than 7V to function properly.
You can connect the DC-DC 5V to the 5V of the controller, that way bypass the regulator which is possibly causing your problem.

Tom.. :smiley: :+1: :coffee: :australia:

Hi,

I used these instructions as a reference when I first setup the board. There it states that the VIN pin is the only way to supply 5V to the board.

I also think that the power might not be the problem as the board powered from the USB has the exact same problem as the battery powered one in an almost exactly the same time frame.

About the blinking CHRG led; the blinking is not very fast (way slower than when uploading a sketch, for example). In here the official documentation implies the problem is with Li-Po battery connection but I don't have one connected to either board.

Hi,

Yes, you are correct the schematic just shows the protection and switching FETs before the 3V3 DC-DC converter.

Can you please post your code?
To add code please click this link;

Tom... :smiley: :+1: :coffee: :australia:

Hi,

Thanks for keeping up with the topic.
Here is the script of the battery connected board. It detects objects/people passing by reading values from the ultrasonic sensor (which you should also see in the schematics I put earlier). Apologies for poor C++ (not my strongest suite).

#include <SPI.h>
#include <LoRa.h>
#include <millisDelay.h> 

const int trigPin = 6; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 7; // Echo Pin of Ultrasonic Sensor
const int led = LED_BUILTIN; // Builtin led constant for debugging.

millisDelay patchDelay; // Delay class for asynchronous delays.

unsigned long PATCHLIFETIME = 900000; // The lifetime or time span between sending the patches.


int patch = 0;  // Variable to store the latest "patch" size of 
                // measurements. This way we can send one big pack
                // of data rather than smaller "patches" which would
                // exceed the 1%/Day usage limit of the LoRa network.

char packetIdentifier[] = "someidentifier "; // Send this first to distinguish our LoRa packet data
                                       	    // from the random, occasional noise.

void setup() {

   pinMode(led, OUTPUT); // Initialize the builtin LED.

   Serial.begin(9600); // Starting Serial
   if (!LoRa.begin(868E6)) {
      Serial.println("Starting LoRa failed!");
      digitalWrite(led, HIGH); // Keep the LED on to indicate something is wrong.
      while (1);
   }

   patchDelay.start(PATCHLIFETIME); // Start the first delay timer for the patch.
}

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
   distance in cm & inches of the nearest object by bouncing soundwaves off of it. */ 

   //USBDevice.detach(); I tried to add this but it didn't fix the problem.

   ///// Ultrasonic sensor related stuff //////
   long duration, cm;   // Variables to make the calculation for measured distance.

   pinMode(trigPin, OUTPUT);
   digitalWrite(trigPin, LOW);
   delayMicroseconds(2);
   digitalWrite(trigPin, HIGH);
   delayMicroseconds(10);
   digitalWrite(trigPin, LOW);

   pinMode(echoPin, INPUT);
   duration = pulseIn(echoPin, HIGH);
   cm = microsecondsToCentimeters(duration);

   // If a passerby is detected in the range,
   // add a count to the next patch.
   if (cm >= 10 && cm <= 50) {
      digitalWrite(led, HIGH);
      delay(250);
      patch ++;
   } else {
      digitalWrite(led, LOW);
      delay(250);
   }

  // If the timer is up.
   if (patchDelay.justFinished()) {
      // Send the patch and reset the values.
      sendPatch();
      patch = 0;

      patchDelay.repeat(); // Restart the timer.
   }
}

void sendPatch() {
   Serial.println("Preparing and sending a patch...");
   Serial.print("Patch count: ");
   Serial.println(patch);

   LoRa.beginPacket();
   LoRa.print(packetIdentifier);
   LoRa.print(patch);
   LoRa.endPacket();

   Serial.println("Patch sent!");
}

long microsecondsToCentimeters(long microseconds)
{
   return microseconds / 29 / 2;
}

And here is the one connected to the Pi. Much simpler.

#include <SPI.h>
#include <LoRa.h>
#include <millisDelay.h>

void setup() {
  
  Serial.begin(9600);
  while (!Serial);

  if (!LoRa.begin(868E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }

}

void loop() {
  // try to parse the packet
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    // read the packet
    while (LoRa.available()) {
      Serial.print((char)LoRa.read());
    }
    Serial.println(""); // End the print line with empty string.
                        // This is so that python serial notices
                        // that the data being sent has ended.
  }
}

The Python script on Raspberry handles all the rest, such as encoding the messages.

I've been experimenting with resetting the boards programmitically but that is not ideal.

Hi,
Have you tried using NewPing library for the ultrasonic unit?
Very easy to use and good examples.

Tom... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.