2

I'm having what I believe to be a power issue with an Arduino project. I've tried 3 different power supplies (all separately):

  1. My computer via USB B
  2. A 5V USB "outlet" via USB B
  3. A 5V USB "outlet", through a 5V->9V boost converter, to the arduino's barrel jack

I can run the sketch without an issue when connected to my computer (supply 1), even if the computer is sleeping and the Arduino program is closed. However, when using supply 2 or 3, everything works EXCEPT reading the pilot light thermocouple through the MAX6675 module. It runs without throwing errors, but always reads 32.0 degrees F from the pilot light thermocouple. The other thermocouples run and update as expected.

Details:

  • Arduino Uno (bought ~November 2016)
  • Running Arduino 3 for programming (downloaded October 2017)
  • Code and Wiring Schematic below

Wiring Schematic Here

Thanks for your help!

EDIT 1

I can run the Arduino with no problems off a small battery bank (like the kind you use to charge a phone with on the go). This isn't a permanent solution because the battery banks will only last 1-2 days powering the arduino. Anyway, I think this indicates that there's something to do with isolation/noise issues from the USB outlet, or something to do with not having a common ground.

Also, to clarify, the 5V USB outlet is powered by a 12V deep cycle battery, hooked up to a solar system with charge controller, other circuits, etc. I don't know if this is relevant, just trying to provide as much information as possible.

//-------------------------------------------------------------------------------------------
//--------------Inputs-----------------------------------------------------------------------

// DS18B20 Thermocouples
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// High temp thermocouple
#include <max6675.h>

// LCD Libraries
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

// Set temperature
int heatSetTemp = 60; // deg F
int bandwidth = 2; // if temp is within "bandwidth" of set point, it's acceptable

float freshWaterTemp; // deg F, current fresh water temp
float insideTemp; // deg F, current indoor temp
float outsideTemp; // deg F, current outside temp
float pilotTemp; // deg F, pilot light temperature

boolean pilotIsOn = false;
char pilotIsOnText = 'n';
boolean gasIsOn = false;
char gasIsOnText = 'n';

// Set up high temp thermocouple
int pilotThermo_sck_pin = 10;
int pilotThermo_cs_pin = 9;
int pilotThermo_so_pin = 8;
MAX6675 pilotThermo(pilotThermo_sck_pin, pilotThermo_cs_pin, pilotThermo_so_pin);

// Set up pilot light solenoid relay
// pin 3 is saved for A/C control - to be implemented
int ac_relay_pin = 3;
int gasSolenoid_pin = 2;

// Pin 4 has a wire jammed in it - not used

// Set up ambient thermocouples
int freshWaterThermo_pin = 5;
int insideThermo_pin = 6;
int outsideThermo_pin = 7;

OneWire freshWaterThermo(freshWaterThermo_pin);
DallasTemperature freshWaterThermoSensor(&freshWaterThermo);
OneWire insideThermo(insideThermo_pin);
DallasTemperature insideThermoSensor(&insideThermo);
OneWire outsideThermo(outsideThermo_pin);
DallasTemperature outsideThermoSensor(&outsideThermo);

// Set up LCD for user interface
int firstLCDLine = 0;
boolean backlightIsOn = true;

//-------------------------------------------------------------------------------------------
//--------------Functions--------------------------------------------------------------------
void turnGasOn() {
  digitalWrite(gasSolenoid_pin, LOW);
  gasIsOn = true;
  gasIsOnText = 'y';
}

void turnGasOff() {
  digitalWrite(gasSolenoid_pin, HIGH);
  gasIsOn = false;
  gasIsOnText = 'n';
}

void blinkLED() {
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(100);                       
  digitalWrite(LED_BUILTIN, LOW);    
  delay(100); 
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(100);
  digitalWrite(LED_BUILTIN, LOW);                           
}

void writeTempsLine() {
  lcd.print("In:"); lcd.print(insideTemp, 1);
  lcd.print(" Out:"); lcd.print(outsideTemp, 1);
}

void writeSetLine() {
  lcd.print("Set:"); lcd.print(heatSetTemp);
  lcd.print(" Wt:"); lcd.print(freshWaterTemp, 1);
}

void writeGasLine() {
  lcd.print("P:"); lcd.print(pilotTemp, 1); 
  lcd.print(" P:"); lcd.print(pilotIsOnText);
  lcd.print(" G:"); lcd.print(gasIsOnText);
} 

void toggleBacklight() {
  if (backlightIsOn) {
    lcd.setBacklight(0x0);
    backlightIsOn = false;
  }
  else {
    lcd.setBacklight(0x1);
    backlightIsOn = true;
  }
}

//-------------------------------------------------------------------------------------------
//--------------Setup------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);

  // Set up relay to gas solenoid
  pinMode(gasSolenoid_pin, OUTPUT);
  turnGasOff(); // Set solenoid to closed by default

  // Start DallasTemperature Library
  freshWaterThermoSensor.begin();
  insideThermoSensor.begin();
  outsideThermoSensor.begin();

  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);

  // Indicator LED
  pinMode(LED_BUILTIN, OUTPUT);
}
//-------------------------------------------------------------------------------------------
//--------------Main Program-----------------------------------------------------------------
void loop() {

  // Read Temperatures
  pilotTemp = pilotThermo.readFahrenheit();

  freshWaterThermoSensor.requestTemperatures();
  insideThermoSensor.requestTemperatures();
  outsideThermoSensor.requestTemperatures();
  freshWaterTemp = freshWaterThermoSensor.getTempFByIndex(0);
  insideTemp = insideThermoSensor.getTempFByIndex(0);
  outsideTemp = outsideThermoSensor.getTempFByIndex(0);

  // Check Pilot Light
  pilotIsOn = (pilotTemp > 300); // flame temp goes here in degF
  if (pilotIsOn) { pilotIsOnText = 'y'; }
  else { pilotIsOnText = 'n'; }

  // Actuate Relay
  if (insideTemp < (heatSetTemp - bandwidth)) // Temp too cold, gas not on yet
  { 
    if(pilotIsOn) { turnGasOn(); }
    else { turnGasOff(); } // because pilot is off
  }
  else if (gasIsOn && insideTemp < heatSetTemp) // Temp still too cold, but gas already on
  { 
    if(pilotIsOn) { //leave gas on 
    }
    else { turnGasOff(); } // because pilot is off
  }
  else // Temp is hot enough
  {
    turnGasOff();
  }

  //Check for button presses
  uint8_t buttons = lcd.readButtons();
  if (buttons) {
    if (buttons & BUTTON_UP) {
      Serial.println("button up pressed");
      firstLCDLine++;
    }
    if (buttons & BUTTON_DOWN) {
      Serial.println("button down pressed");
      firstLCDLine--;
    }
    if (buttons & BUTTON_RIGHT) {
      Serial.println("button right pressed");
      heatSetTemp++;
    }
    if (buttons & BUTTON_LEFT) {
      Serial.println("button left pressed");
      heatSetTemp--;
    }
    if (buttons & BUTTON_SELECT) {
       Serial.println("button select pressed!!!");
       toggleBacklight();
    }
  }


  // Output to Serial Monitor
  Serial.println(String("Fresh Water: ") + freshWaterTemp);
  Serial.println(String("Inside: ") + insideTemp);
  Serial.println(String("Outside: ") + outsideTemp);
  Serial.println(String("Pilot: ") + pilotTemp);
  Serial.println(String("Pilot Is On: ") + pilotIsOn);
  Serial.println(String("Gas Is On: ") + gasIsOn);
  Serial.println(String("Heat Set Temp: ") + heatSetTemp);
  Serial.println(String("firstLCDLine: ") + firstLCDLine);
  Serial.println();

  // Output to LCD
  lcd.clear();
  if(firstLCDLine % 3 == 0) {
    lcd.setCursor(0, 0); writeTempsLine();
    lcd.setCursor(0, 1); writeGasLine();
  }
  else if (firstLCDLine % 3 == 1) {
    lcd.setCursor(0, 0); writeGasLine();
    lcd.setCursor(0, 1); writeSetLine();
  }
  else {
    lcd.setCursor(0, 0); writeSetLine();
    lcd.setCursor(0, 1); writeTempsLine();
  }

  // Automatic scrolling
  firstLCDLine++;

  // Indicate "heartbeat" of sketch
  //blinkLED();
}
  • Try to remove some power consumption, like the relay board. – MatsK Oct 4 '17 at 18:31
  • @MatsK Thanks for the suggestion. I tried disconnecting the relay board, and it still runs exactly the same way. The only other thing I can think of that the LCD (this one from Adafruit) is drawing a lot of power, but it doesn't seem likely. – lg22woo Oct 6 '17 at 1:55
  • There is a method to troubleshoot and it's called reduce the circuit to a barebone and then add and see when it fails. – MatsK Oct 6 '17 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.