CHRG LED blinks and data updating stops

Hello, after sometime (about 30minutes) my MKRWWIFI1010 stops to send data from temperature sensor DHT22 and charge orange led starts to blink. The board has no battery and is powered by micro usb plug. If I reset board with button It restarts to send temperature. I need to soft restart every 20 minutes the board but I dont't know what commands to use in the sketch.
Can you help me please?
Thank you so much.

Welcome to the forum

Please read the General Guidance and How to use the forum

Please post your code (use code tags) and schematics (hand drawn is OK, No Fritzing).

If you have any non-Arduino components or modules please provide links to the datasheets. Also provide links to 3rd party libraries e.g. on Github. This will help people answer your question instead of searching for information you already have.

A general issue with WiFi examples is the initialization of the connection in the setup() function. WiFi networks are inherently unreliable and your code needs to check the connection on a regular basis and restart the connection when necessary.

This is my sketch:

// DHT sensor library - Version: Latest 
#include <DHT.h>
#include <DHT_U.h>

#define DHT_PIN 7
#define DHT_TYPE DHT22


// DHT sensor library for ESPx - Version: Latest 

  Sketch generated by the Arduino IoT Cloud Thing "Untitled" 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudTemperatureSensor temp;
  CloudRelativeHumidity umidita;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found

  // Defined in thingProperties.h

  // Connect to Arduino IoT Cloud
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4


void loop() {
  // Your code here 
  temp = dht.readTemperature();
  umidita = dht.readHumidity();

Before we get to your code, please try to use code tags. Your code should look like this.

Your example code

I have not used the Arduino cloud thing but looking at the documentation I am surprised it works as it is.

Your loop function is updating without any timing restriction. The following page suggests you can do one API request per second.

How often does loop run in your case? Maybe the server stops the connection and because your software does not try to stop and restart automatically, you need to push the reset button.

Thank you for your answer. In fact, if I add delay (10000) to the bottom of the sketch, the program works and doesn't stop. But at this point I would like to know why after 30 minutes the orange LED starts flashing even if I have not attached any battery.

But at this point I would like to know why after 30 minutes the orange LED starts flashing even if I have not attached any battery.

I do not know. The schematic shows a yellow LED. I guess that is the one. It is connected to a pin. So, there must be some software that blinks the LED. Maybe some library that is linked automatically is using the LED.

Regarding using delay(). This is generally not a good idea. It will prevent you from extending your sketch without breaking the timing you have so far.

Have a look at the following example

File → Examples → 02.Digital → BlinkWithoutDelay

This will teach you how to start parts of your code on a regular basis. The goal should be to execute the loop() function as often as possible and then call all kinds of function (reading buttons, sensors, sending data …) as often as needed.
If you do this right, you can add code as long as you have enough processing power and everything you have written so far should continue to work as before.

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