'L' LED Constantly Blinking Error

Hi All,

I am having an issue with my Arduino UNO WiFi Rev2 board whereby the 'L' LED is constantly blinking when I upload my code (sample below). The code was working fine, until I added in a couple of extra feeds to my Adafruit IO Dashboard. It seems every time I use more than 5 feeds within the code, the 'L' LED begins to blink and nothing happens.

Is there any obvious errors within my code, or any advice that anyone could share as I am going to need possibly up to 10 feeds in total.

Many thanks,

George

// Defines
#define AIO_USERNAME    "*******"
#define AIO_KEY         "*******"
#define AIO_DMOSA_FEED    "dmosatransducer"
#define AIO_TARE_FEED     "tare"
#define AIO_CONFIRM_FEED    "confirm"
#define AIO_DATASTREAM_FEED    "datafeed"
#define AIO_DMOSAHEALTH_FEED    "dmosa-healthy"
#define AIO_PTOSLHEALTH_FEED    "ptosl-healthy"
#define WIFI_SSID       "*******"
#define WIFI_PASS       "*******"
#define USE_AIRLIFT     // required for Arduino Uno WiFi R2 board compatability


// Libraries
#include <AdafruitIO_WiFi.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>
#include <TimeLib.h>

// Constructors
AdafruitIO_WiFi aio(AIO_USERNAME, AIO_KEY, WIFI_SSID, WIFI_PASS, SPIWIFI_SS, SPIWIFI_ACK, SPIWIFI_RESET, NINA_GPIO0, &SPI);
AdafruitIO_Feed *DMOSAHealth = aio.feed(AIO_DMOSAHEALTH_FEED);
AdafruitIO_Feed *PTOSLHealth = aio.feed(AIO_PTOSLHEALTH_FEED);
AdafruitIO_Feed *DMOSAFeed = aio.feed(AIO_DMOSA_FEED);
AdafruitIO_Feed *TareFeed = aio.feed(AIO_TARE_FEED);
AdafruitIO_Feed *ConfirmFeed = aio.feed(AIO_CONFIRM_FEED);
AdafruitIO_Feed *DataStreamFeed = aio.feed(AIO_DATASTREAM_FEED);

int SENSORVALUE = A0;
int P0 = 0;
float pressure_pascal;
float pressure_bar;
float pressure_psi;
float Brake_Step_1;
float Brake_Step_2;
float Brake_Step_3;
float Brake_Step_E;
float EmergencyLow;
float EmergencyHigh;
float Voltage;
float error = 0;
bool value = 0;
bool value_confirm = 0;
int status = WL_IDLE_STATUS;
char ssid[] = WIFI_SSID;        // your network SSID (name)
char pass[] = WIFI_PASS;    // your network password (use for WPA)
unsigned int localPort = 2390;      // local port to listen for UDP packets
unsigned long offset_days = 3;    // 3 days
unsigned long t_unix_date1, t_unix_date2, unixdt;
const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message
byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets

IPAddress timeServer(79, 135, 97, 79); // ntp.exnet.com NTP server

// A UDP instance to let us send and receive packets over UDP
WiFiUDP Udp;

void setup()
{
  pinMode(SENSORVALUE, INPUT);
  Serial.begin(9600);
  while(!Serial);  // wait for serial connection

   // Adafruit IO connection and configuration
   Serial.print("Connecting to Adafruit IO");
   aio.connect();  // connect to Adafruit IO service
   while(aio.status() < AIO_CONNECTED) {
      Serial.print(".");
      delay(1000);  // wait 1 second between checks
   }
   Serial.println();
   Serial.println(aio.statusText());  // print AIO connection status
   DMOSAHealth = 1;
   while(PTOSLHealth = 0); //Wait for PTOSL Healthy Signal     
   
   Serial.println("\nStarting connection to Time server...");
   Udp.begin(localPort);

   // Set up message handler that calls function when messages are received
   TareFeed->onMessage(TareMessageHandler);
   TareFeed = 0;  // set initial value as 0 (DO I NEED THIS ANYMORE??)
   ConfirmFeed->onMessage(ConfirmMessageHandler);
   
}

void loop() 
{
    Date_Time_NTP(); // Set up connection to Date / Time server
  aio.run();
  PressureCalc();
  DataStreamFeed->save("Please Release the Brakes");
  Serial.println("Please release the Brakes");
  delay(50);
  BrakeRelease();
  DataStreamFeed->save("Ready to Begin?");
  Serial.println("Ready to Begin?");
  while(value_confirm != 1){aio.run();PressureCalc();} // Wait for the Confirm button to be pressed, keep pressure calculations updated
  value_confirm = 0; // set value back to 0 after Confirm has been pressed
  BrakeStep1();
  BrakeStep2();
  BrakeStep3();
  BrakeStepE();
  BrakeTimings();
}

// Handles Tare feed message received from AIO
void TareMessageHandler(AdafruitIO_Data *data) {
   value = data;  // capture feed value from AIO
   Serial.print("Tare feed received -> ");  Serial.println(value);
   if (value = 1) {
      float pressure_bar_error = (((3*(Voltage-0.4937))*1000000.0)/10e5);
      error = 0 + pressure_bar_error;}
}

// Handles Confirm feed message received from AIO
void ConfirmMessageHandler(AdafruitIO_Data *confirm) {
   value_confirm = confirm;  // capture feed value from AIO
   Serial.print("Confirm feed received -> ");  Serial.println(value_confirm);
}

This pinout shows the Uno Wifi "L" LED is attached to PD06, which is the Rx pin on the ATMEGA32U4 (lower-right)

Appear to have got to the bottom of it with help from another Arduino user. It seems as though there is some limit of 5 to the number of active TCP connections when using the Arduino board WiFi module.

This effectively seems to block the code from working until you reduce the number of connections back to 5 or less.

Unfortunately, have been unable to find a workaround thus far.

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