Can Serial.print cause mcu hiccups?

Before posting the complete code, i want to ask if its even possible.

Is it possible for Serial.print or Serial.println cause the following problem:

I have a code that works “fine” while the unit is powered by the USB, but has hiccups when powered by a wall adapter. Its a code that receives data from a Tx-sender with an NRF24L01 and posts it to the web. The code runs every 30 minutes but when the Rx-receiver is plugged into my laptop for power, it works “fine” in the sense that it posts almost continuously, with very few if any dropped or missed postings. But when it runs on wall adapter power it seems to skip quite a few posts.

So I guess I was wondering if anyone has run into the issue where the project not having access to the Serial Monitor makes it work differently than on wall power. I have the usual debug lines here and there for debugging different steps of the code, but is it POSSIBLE or COMMON?

Here is the schematic and picture of the setup and code:

#include <avr/sleep.h>
#include <avr/wdt.h>
//ADDED FOR AVR RESET

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//UNO 0 - ESP
//UNO 1 - ESP
//UNO 7 - NRF-CE
//UNO 8 - NRF-CSN
//UNO 9 -
//UNO10 -
//UNO11 - NRF-MOSI
//UNO12 - NRF-MISO
//UNO13 - NRF-SCK
//UNOGND- ESP-GND
//UNO3.3- RAIL - NRF-3.3V - ESP3.3V
//UNO5V - LCD-Vcc
//UNOGND- NRF-GND
//UNOGND- LCD-GND
//UNO A4- LCD-SDA
//UNO A5- LCD-SCL

#include "ThingSpeak.h"
#include "WiFiEsp.h"
#include "secrets.h"

char ssid[] = SECRET_SSID;   // your network SSID (name) 
char pass[] = SECRET_PASS;   // your network password
int keyIndex = 0;            // your network key Index number (needed only for WEP)
WiFiEspClient  client;

#define CE_PIN 7
#define CSN_PIN 8
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
struct package{
  float humedad = 0;
  float temperatura = 0;
  float tempds18b20 = 0;
  float tempbmp180 = 0;
  float humibmp180 = 0;
};
typedef struct package Package;
Package dataReceived;
bool newData = false;

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(2,3); // RX, TX
#define ESP_BAUDRATE  19200
#else
#define ESP_BAUDRATE  115200
#endif

unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;

// Initialize our values
String myStatus = "";

void setup() {
  //Initialize serial and wait for port to open
  Serial.begin(115200);  // Initialize serial
  
  //NRF
  setupRadio();

  // sleep for a total of 240 seconds (8x225=240)
  int i;
  for (i = 0; i <225; i++){  
    myWatchdogEnable (0b100001);  // 8 seconds
  }
}

void setupRadio(){
  pinMode(10,OUTPUT);
  radio.begin();
  radio.setDataRate( RF24_250KBPS );
  radio.openReadingPipe(1, thisSlaveAddress);
  radio.startListening();

  lcd.init();
  lcd.init();
  lcd.backlight();
}

void loop() {
    getData();
    showData();
}

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived.humedad);
        Serial.println(dataReceived.temperatura);
        lcd.setCursor(1,0);
        lcd.print(dataReceived.humedad);
        lcd.setCursor(1,1);
        lcd.print(dataReceived.temperatura);
        newData = false;
        postDataCloud();
    }
}

void postDataCloud(){
  //setup esp wifi stuff
  // initialize serial for ESP module  
  setEspBaudRate(ESP_BAUDRATE);
  
  while (!Serial) {
    ; 
  }

  Serial.print("Searching for ESP8266..."); 
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }
  Serial.println("found it!");
   
  ThingSpeak.begin(client);  // Initialize ThingSpeak



  
 // Connect or reconnect to WiFi
  if(WiFi.status() != WL_CONNECTED){
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(SECRET_SSID);
    while(WiFi.status() != WL_CONNECTED){
      WiFi.begin(ssid, pass);  // Connect to WPA/WPA2 network. Change this line if using open or WEP network
      Serial.print(".");
      delay(5000);     
    } 
    Serial.println("\nConnected.");
  }

  // set the fields with the values
  ThingSpeak.setField(1, dataReceived.humedad);
  ThingSpeak.setField(2, dataReceived.temperatura);
  ThingSpeak.setField(3, dataReceived.tempds18b20);
  ThingSpeak.setField(4, dataReceived.tempbmp180);
  ThingSpeak.setField(5, dataReceived.humibmp180);

  // write to the ThingSpeak channel
  int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  if(x == 200){
    Serial.println("Channel update successful.");
  }
  else{
    Serial.println("Problem updating channel. HTTP error code " + String(x));
  }  
}

void setEspBaudRate(unsigned long baudrate){
  long rates[6] = {115200,74880,57600,38400,19200,9600};

  Serial.print("Setting ESP8266 baudrate to ");
  Serial.print(baudrate);
  Serial.println("...");

  for(int i = 0; i < 6; i++){
    Serial1.begin(rates[i]);
    delay(100);
    Serial1.print("AT+UART_DEF=");
    Serial1.print(baudrate);
    Serial1.print(",8,1,0,0\r\n");
    delay(100);  
  }
  Serial1.begin(baudrate);
}
ISR(WDT_vect) {
  wdt_disable();  // disable watchdog
}
void myWatchdogEnable(const byte interval) {  
  MCUSR = 0;                          // reset various flags
  WDTCSR |= 0b00011000;               // see docs, set WDCE, WDE
  WDTCSR =  0b01000000 | interval;    // set WDIE, and appropriate delay
  wdt_reset();
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_mode();            // now goes to Sleep and waits for the interrupt
}

No, that won't make the code do anything. I don't see how it could.

But different power supplies sometimes cause issues. Especially if there's not a common ground. Post code and wiring.

Don't you think "hiccups" is rather vague for a description of something very technical that your project is doing?

Paul

OK by hiccups I meant it fails to post at its regular 30 minute interval when on Wall power but posts quite well on usb power.

This is usb power:

And here is a snapshot of it on Wall power. As you can see it has a couple of long stretches of time without posts:
44134DED-DCB7-4765-B26C-DF456949B063.png

44134DED-DCB7-4765-B26C-DF456949B063.png