CMD Skipped:20 (BLYNK_CMD_HARDWARE) Sparkfun weather shield

Dear All

Regarding: Sparkfun weather shield on an Arduino Uno sending weather related data to Blynk server via xbee:

Problem Error Returned:Cmd skipped:20

I have a Sparkfun weather shield (https://www.sparkfun.com/products/13956) which is piggy-backed onto an Arduino Uno with an xbee S2 radio (transmitter). This is transmitting 10 weather data variables (wind speed direction etc) to the receiver which is an Arduino Uno also with an xbee s2 radio. This unit is connected to the internet either by a Ethernet-2 shield or a wifi shield. I have used both the Ethernet-2 and the wifi shield and get the same CMD skipping issue. So I do not think it is the connection"to the internet" problem.

The xbee transmitter on the Sparkfun shield sends 10 weather data variables every 30 seconds at a baud of 9600 to the xbee receiver. The receiver then sends (for now during development and error detecting stage) only the pressure variable to the Blynk server to make a history graph.

On the Blynk app I initially had 6 virtual pins for 6 weather data variable however the server flooded so I removed 5 of the variables and added a timer for (29.5 seconds) and reduced the virtual pins to one to try to identify and resolve the problem (Cmd skipped:20). I have tried many different timer periods. 5 10 20 28 30 seconds. The shorter the timer period the quicker the error occurs.

I have made some progress. Using a timer period of 29.5 seconds the code works (for one variable i.e. pressure) for about 15 minutes before I get the dreaded Cmd skipped:20 error message. Until I resolve the issue for one variable I will not added back in desired data variables. Ultimately I want about 6 to 8 variables on the app . The blynk timer in the code is set at 29.5 seconds in order to not allow the server to be flooded by multiple hits.

In other blynk projects that I have worked on recently , e.g. I have 4 esp8266’s sending temp/humidity data to the blink app with great success. They have been working well for months without issue.

The main difference between the esp’s project and the sparkfun board is the fact that the Sparkfun unit is not connected to the internet directly. The xbee receiver unit is connected to the internet and the variables are received from the sparkfun board every 30 seconds by xbee from the transmitter.This is because the transmitter is outside with the wind speed /direction equipment i.e. the weather data is not generated on the receiver board which is connected to the internet

I have read the docs and researched the community quit hard and still I am not sure how to fix this.I have done what is required to fix the normal Cmd skipped:20 errors.

If I can get some guidance on the cmd skipping issue and how to add say 6 data values via 6 virtual pins I would be grateful

I am including my code

and parts of the debug file

*****************************************************************************
START OF ARDUINO CODE FOR RECEIVER

//Max Birley May 2017 max@birley.com

//Weather data collection

// The shetch receives data transmitted via xbee from a Sparkfun weather shield.
//  The data is received by a xbee and wifi connected to the internet
// Selected data is then sent to to the blynk server

//Notes for uploading the sketch
// uploading sketch;move xbee shield button to Dline position
// for data transmision/receive move button to Uart position on the sparkfun Xbee shield
// 



#define BLYNK_DEBUG // Enable this for debugginghis enables lots of prints
#define BLYNK_PRINT Serial    // and this
#include <SPI.h>

// Can either use wifi shield or the Ethernet-2 shield as required Comment out the code that is not used
//#include <WiFi.h>
//#include <BlynkSimpleWifi.h>
//char ssid[] = "Devolo";
//char pass[] = "Thefrenchdog";

//comment out the ethernet code as we are using wifi connection
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>


char auth[] = "469axxxxxxxxxxxxedbb1df3";

// This timer is required to stop the Run() server crashing 
SimpleTimer timer;

// These are the values/strings transmitted by the weather station xbee to the xbee receiver
String postData = "";
String data = "";
String first = "";
String postWord = "";
String winddir = "";
String windspeedmph = "";
String windgustmph = "";
String windgustdir = "";
String windspdmph_avg2m = "";
String winddir_avg2m = "";
String windgustmph_10m = "";
String windgustdir_10m = "";
String humidity = "";
String tempf = "";
String rainin = "";
String dailyrainin = "";
String pressure = "";
String batt_lvl = "";
String light_lvl = "";



//*****************************************************************
void setup()
{
  Serial.begin(9600);

//Choose one statement
   //Blynk.begin(auth, ssid, pass);
  Blynk.begin(auth);// use this for Ethernet

    
   // Setup a function to be called every x seconds
  timer.setInterval(29500L, PostBlynkData);// 30000l is for 30 seconds delay

  
  // You can also specify server.
  // For more options, see BoardsAndShields/Arduino_Ethernet_Manual example
  //Blynk.begin(auth, "your_server.com", 8442);
 // Blynk.begin(auth, IPAddress(192,168,1,17), 8442);
}


//*****************************************************************
// needs to be kept very simple
void loop()
{
  Blynk.run();
   
  timer.run(); // Initiates BlynkTimer
}
//**********************************************************************************

void PostBlynkData()
{

//
do 
{ 
 //Serial.println("Waiting on data"); 
}
 while (!Serial.available());
 
 //receives the weather data into a number of strings
 if (Serial.available() > 0) 
  { 
    first = Serial.readStringUntil('$$$$$');

    data = Serial.readStringUntil('&');
 //  Serial.println("..........Receiving Data from WS...................");
    
    winddir = Serial.readStringUntil('&');
    Serial.println(winddir);
 
    windspeedmph = Serial.readStringUntil('&');
   Serial.println(windspeedmph);
    
    windgustmph = Serial.readStringUntil('&');
 //  Serial.println(windgustmph);
     
    windgustdir = Serial.readStringUntil('&');
//   Serial.println(windgustdir);
  
    windspdmph_avg2m = Serial.readStringUntil('&');
//   Serial.println(windspdmph_avg2m);

    winddir_avg2m = Serial.readStringUntil('&');
  //  Serial.println(winddir_avg2m);

  
    windgustmph_10m = Serial.readStringUntil('&');
  // Serial.println(windgustmph_10m);


    windgustdir_10m = Serial.readStringUntil('&');
 //  Serial.println(windgustdir_10m);

    humidity = Serial.readStringUntil('&');
//    Serial.println(humidity);

    tempf = Serial.readStringUntil('&');
//    Serial.println(tempf);


    rainin = Serial.readStringUntil('&');
 //  Serial.println(rainin);

    dailyrainin = Serial.readStringUntil('&');
  //  Serial.println(dailyrainin);

    pressure = Serial.readStringUntil('&');
 //   Serial.println(pressure);

    batt_lvl = Serial.readStringUntil('&');
 //   Serial.println(batt_lvl);

    light_lvl = Serial.readStringUntil('&');
  //  Serial.println(light_lvl); 

   //data = Serial.readStringUntil('#####');
   //Serial.println(data);
   
   data = Serial.readStringUntil('&');
   data = "";
  // Serial.println(data);
  // Serial.println("...............Data Received............");

//do not use delays. only use when not using blynk
  // delay(100); 
  }
    
  // Blynk.virtualWrite(V1, winddir);
  // Blynk.virtualWrite(V2, windspeedmph);
  // Blynk.virtualWrite(V3, windspdmph_avg2m);
  // Blynk.virtualWrite(V4, windgustmph_10m);
  // Blynk.virtualWrite(V5, humidity);
  // Blynk.virtualWrite(V6, tempf);
   Blynk.virtualWrite(V7, pressure);
 
}

****************************
END OF CODE

I had to edit your topic to properly format your posted code:

Based on other topics CMD Skipped:20 means a hardware command that should be forwarded to app.

I haven’t dug through you code… but based on skimming your issue description, I suspect some of your hardware is not in constant communication with the Blynk Server… and it needs to be at all times.

Dear Gunner
Thanks for taking the time to reply. On this issue I appreciate all the help I can get. I have been working on this error for days now. I think the fix will be simple for someone with a detailed understanding of the server.That person is not me!

Regarding the hardware I have two separate spark fun boards and have tested them with both Ethernet and wifi shields. In all cases I have the same issue. Also all my esp8622 projects are working perfectly based on this thinking I do not see it being a hardware issue. Lastly when the receiver is disconnected the receiver can not reconnect to the server again unless I cancel the serial monitor window and reopen the monitor window again.
One other point, when I change the length of the timer it seems to effect when the error is triggered. i.e. short the timer period the quicker the error occurs.

Can I provide you with debug logs or other information?

best regards

This is not a server or hardware issue (as in “faulty hardware”, however the type of communications link may be a factor)… but more likely how your code is written. That explains why shorter intervals make for more errors… something in that loop is causing problems. You need to break your code down to locate the issue before anyone can suggest a way of making it function with Blynk.

Thanks again for the reply. That’s good advice and I will work on the code. In the meantime can you offer some advice on the following.

  1. The transmitter sends 10 values to the receiver every 30 seconds. Should I reduce or increase the time between transmissions

  2. How should the code timer be configured re the transmission period timer.

  3. Should I also reduce the number of variables being transmitted. I am not referring to the variable being written to the blynk app. Currently I am only sending one variable to blynk.

4 can the debug include be causing an issue re timing.

5 I assume do not have any delay(); in the code

6 Can you see anything in my code that may be causing a problem

Regards
Max