Arduino Uno Suddenly stopped sending data to Serial when using external powe supply

Good the microcontrollers are working fine this last 2 weeks and being powered by power supply. It was still working last night, but now the Arduino uno won't send into serial when being powered by a power supply I used which is a 12V 0.8A, but when I used the usb cable to power the Arduino uno sends data to serial just fine.

Do you have external peripheral devices or modules connected to the Arduino, that consume power?

Please post your code and schematic using the methods recommended by the forum.

I only have 2 which is the sensor that requires 12V and the arduino uno. This setup was running smoothly for the last 2-3 weeks now and is working just fine last night.

Apparently you have not fully read reply #3. Obviously, we don't know what "the sensor" or "this setup" is.

Im using a Modbus MAX485 which powered by the arduino uno, and ESP8266 which also powered by the arduino.

Apparently you have not fully read reply #5.


Do you think this is code related?
Edit:

#include <LowPower.h>
#include <AltSoftSerial.h>
#include <SoftwareSerial.h>
// RO to pin 8 & DI to pin 9 when using AltSoftSerial
#define RE 6
#define DE 7

const byte nitro[] =          {0x01, 0x03, 0x00, 0x1e, 0x00, 0x01, 0xe4, 0x0c};
const byte phos[] =           {0x01, 0x03, 0x00, 0x1f, 0x00, 0x01, 0xb5, 0xcc};
const byte pota[] =           {0x01, 0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xc0};
const byte soil_ph[] =        {0x01, 0x03, 0x00, 0x06, 0x00, 0x01, 0x64, 0x0b};
const byte soil_moist[] =     {0x01, 0x03, 0x00, 0x12, 0x00, 0x01, 0x24, 0x0f};
const byte temp_humid[] =     {0x01, 0x03, 0x00, 0x12, 0x00, 0x02, 0x64, 0x0e};

byte values[11];
AltSoftSerial mod;

void setup() {
  Serial.begin(115200);
  mod.begin(9600);
  pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);

  // put RS-485 into receive mode
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  delay(4000);
}
void loop() {
  unsigned long pH, moisture, humidity, nitrogen, phosphorus, potassium;

  for(int i = 0; i < 3; i++) {
    nitrogen = getNitrogen();
    delay(250);
  
    phosphorus = getPhosphorous();
    delay(250);
  
    potassium = getPotassium();
    delay(250);
  
    pH = getpH();
    delay(250);
    
    moisture = getMoisture();
    delay(250);
  
    humidity = getHumidity();
    delay(250);

    Serial.println(String(pH) + "," + String(moisture) + "," + String(humidity) + "," + String(nitrogen) + "," + String(phosphorus) + "," + String(potassium));

    delay(3000);
  }
  // Timer delays about 5 minutes between readings
  for (int i = 0; i <35 ; i++) {   
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
  }
}

unsigned long getHumidity(){
   // clear the receive buffer
  mod.flushInput();

  // switch RS-485 to transmit mode
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);

  // write out the message
  for (uint8_t i = 0; i < sizeof(temp_humid); i++ ) mod.write( temp_humid[i] );

  // wait for the transmission to complete
  mod.flush();
  
  // switch RS-485 to receive mode
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  // crude delay to allow response bytes to be received!
  delay(100);

  // read in the received bytes
  for (byte i = 0; i < 7; i++) {
    values[i] = mod.read();
  }
   unsigned long combined = 0;
   combined = values[3];
   combined = (combined << 8) | values[4];
   return combined;
}

unsigned long getMoisture() {

  // clear the receive buffer
  mod.flushInput();

  // switch RS-485 to transmit mode
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);

  // write out the message
  for (uint8_t i = 0; i < sizeof(soil_moist); i++ ) mod.write( soil_moist[i] );

  // wait for the transmission to complete
  mod.flush();
  
  // switch RS-485 to receive mode
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  // crude delay to allow response bytes to be received!
  delay(100);

  // read in the received bytes
  for (byte i = 0; i < 7; i++) {
    values[i] = mod.read();
  }
   unsigned long combined = 0;
   combined = values[3];
   combined = (combined << 8) | values[4];
   return combined;
}

unsigned long getpH() {
  
  // clear the receive buffer
  mod.flushInput();

  // switch RS-485 to transmit mode
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);

  // write out the message
  for (uint8_t i = 0; i < sizeof(soil_ph); i++ ) mod.write( soil_ph[i] );

  // wait for the transmission to complete
  mod.flush();
  
  // switch RS-485 to receive mode
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  // crude delay to allow response bytes to be received!
  delay(100);

  // read in the received bytes
  for (byte i = 0; i < 7; i++) {
    values[i] = mod.read();
  }
  unsigned long combined = 0;
  combined = values[3];
  combined = (combined << 8) | values[4];
  return combined;
}

unsigned long getNitrogen() {
  // clear the receive buffer
  mod.flushInput();

  // switch RS-485 to transmit mode
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);

  // write out the message
  for (uint8_t i = 0; i < sizeof(nitro); i++ ) mod.write( nitro[i] );

  // wait for the transmission to complete
  mod.flush();
  
  // switch RS-485 to receive mode
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  // crude delay to allow response bytes to be received!
  delay(100);

  // read in the received bytes
  for (byte i = 0; i < 7; i++) {
    values[i] = mod.read();
  }
    unsigned long combined = 0;
    combined = values[3];
    combined = (combined << 8) | values[4];
    return combined;
}

unsigned long getPhosphorous() {
  mod.flushInput();
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  for (uint8_t i = 0; i < sizeof(phos); i++ ) mod.write( phos[i] );
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  delay(100);
  for (byte i = 0; i < 7; i++) {
    values[i] = mod.read();
  }
   unsigned long combined = 0;
   combined = values[3];
   combined = (combined << 8) | values[4];
   return combined;
}

unsigned long getPotassium() {
  mod.flushInput();
  digitalWrite(DE, HIGH);
  digitalWrite(RE, HIGH);
  delay(10);
  for (uint8_t i = 0; i < sizeof(pota); i++ ) mod.write( pota[i] );
  mod.flush();
  digitalWrite(DE, LOW);
  digitalWrite(RE, LOW);

  delay(100);
  for (byte i = 0; i < 7; i++) {
    values[i] = mod.read();
  }
  unsigned long combined = 0;
   combined = values[3];
   combined = (combined << 8) | values[4];
   return combined;
}

I updated the post @anon57585045

Thanks, much better...

1 Like

One thing about your schematic, though.. you say you have a difference based on power supply, the schematic doesn't show how either processor board is powered.... nor does it include any common ground connections....

Im sorry for that, the proteus im using doesn't have max485 component, but it was being powered by the Arduino uno. Same goes for the esp8266.

Post close up images of your actual hardware setup. Make a pen and paper drawing of the power distribution and include that.

It is a mess and still on a breadboard, just a sec

Could that ever cause a failure? :slight_smile:

No i mean, the wiring is a mess, its hard to see the connections.

That's where the pen and paper drawing comes in.

1 Like

I tried to disconnect the VIN of Arduino uno to the power supply, and connect the usb to the pc to read the serial, and its working just fine, the nodemcu received it okay.

Ok, wait a sec sir.

Most people here won't follow this without the requested diagram. Take your time so it will be clear and complete.

1 Like