LM35 and LCD display without doesnt work w/o usb

hi there,

I was able to hookup my Arduino Uno R3 to a display and a LM35 thermo. so the temperature is displayed on the screen in C and F.everything works fine, but when i hookup the circuit to a 9v Bat. nothing happens, i thought my battery was dead so i checked its at 6.48v right now so i think its good enough. I get no display on the LCD, is cause im using serial commands? if yeh how can i over come that? pls help. my code is attached and so is the pic. thanks in advance.
SN

// include the library code:
#include <LiquidCrystal.h>

int pin = 0; // analog pin
int tempc = 0,
tempf=0; // temperature variables
int i;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600); // start serial communication
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);

// Print a message to the LCD.
lcd.print("C => ");
lcd.setCursor(0,1);
lcd.print("F => ");
}

void loop()
{

tempc = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit
lcd.setCursor(5,0);
lcd.print(tempc);
lcd.setCursor(5,1);
lcd.print(tempf);

tempc = 0;
delay(1000);
}

I get no display on the LCD, is cause im using serial commands?

Are you trying to access the same Serial port that is the one and only one Hardware Serial ports that is the Rx/Tx at the same time?
may be a clash must be happening between the serial connectivity that flows into to your LCD and your computer.

6.48V without a load connected to the battery seems pretty dead to me. BTW, are you using the back light? I can't say for sure. I saw pin 16 to GND but don't know where pin 15 is connected to.

are you using the back light?

To me it seems like he's using it.

I asked him about the series resistor for his backlight in another thread (Arduino Forum) but he didn't answer that question. I suspect that the current drawn by backlight, even with a series resistor, is more than the battery can supply.

Don

floresta:
I asked him about the series resistor for his backlight in another thread (http://arduino.cc/forum/index.php/topic,100810.msg755902.html#msg755902) but he didn’t answer that question. I suspect that the current drawn by backlight, even with a series resistor, is more than the battery can supply.

Don

Hey Don, i am using the backlight

prowler_sn:

floresta:
I asked him about the series resistor for his backlight in another thread (Arduino Forum) but he didn't answer that question. I suspect that the current drawn by backlight, even with a series resistor, is more than the battery can supply.

Don

Hey Don, i am using the backlight

But I asked about the series resistor that you may or may not be using with the backlight.

Don

No the back light has no resistor in serries, should i place one? how many ohms?

prowler_sn:
No the back light has no resistor in serries, should i place one? how many ohms?

Please get at least 150ohm. Exact value is irrelevant.

I hope you have found another battery. Your circuit won't work for long even with a new battery but it won't work at all with the dead one that you are currently using.

Don

floresta:
I hope you have found another battery. Your circuit won't work for long even with a new battery but it won't work at all with the dead one that you are currently using.

Don

I suspect it's dead too, with that kind of voltage. Even if it's not dead, that voltage is not enough to power the 5V voltage regulator. That needs 7V and more.

U guys were right!!!..I just bought a new 9v and its ALIVE!!!..oh and i also placed in a 150ohm res for the backlight, all is good. just one last thing that’s bothering me. take a look at this loop (below): its suppose to indicate just the temp in C and in F. but if the temp goes above a certain point its suppose to display on the LCD “Warning its hot!”, this works fine, the problem is that when the temp drops below the warning temp it STILL displays the warning!!. i just want the 2 warnings to appear on the LCD when the limits are crossed? any suggestions? thanks

void loop()
{

tempc = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tempf = (tempc * 9)/ 5 + 32; // converts to fahrenheit

lcd.setCursor(5,0);
lcd.print(tempc);
lcd.setCursor(5,1);
lcd.print(tempf);

if (tempc > 28) // ideally no more than 29
{
lcd.setCursor(8,0);
lcd.print(“WARNING!”);
lcd.setCursor(8,1);
lcd.print(“Too Hot!”);
}

if (tempc < 20) // ideally no less than 18
{

lcd.setCursor(8,0);
lcd.print(“WARNING!”);
lcd.setCursor(8,1);
lcd.print(“Too Cold!”);
}

The easiest and laziest way to do it is to print some " " where the warning is every iteration, that's before deciding to display a warning or not. That covers up the previous message. Certainly if you want elegance, you need

if (temp has been>20 for several seconds) erase warning

Not a bad exercise for you. Every bit of detail added (needed) is going to steer a program in some unexpected way.

This is a lazy way, but should work:

  if (tempc > 28) // ideally no more than 29
  {
      lcd.setCursor(8,0);
      lcd.print("WARNING!");
      lcd.setCursor(8,1);
      lcd.print("Too Hot!");
  }
  else if (tempc < 20) // ideally no less than 18 
  {
    
      lcd.setCursor(8,0);
      lcd.print("WARNING!");
      lcd.setCursor(8,1);
      lcd.print("Too Cold!");
  }
  else
  {
    lcd.setCursor(8,0);
    lcd.print("        ");
    lcd.setCursor(8,1);
    lcd.print("         ");
  }

To make it less lazy, keep track of whether you’re currently displaying a warning and only clear it if you need to.

Thanks!!!!... the lazy thing worked!!. thanks alot for the help and quick replies
cheers
SN

Live Life Love Life

Hi there,

So i Have moved up a bit. now i have connected a fan. so the the fan turns on when its too hot and turns off when its too cold. the problem is that the temperature reading on the LCD is ok until the fan kicks in (when the temp reaches a certain limit), the temp shoots up ~4 degrees!!, i noticed it always shoots up when the speed (analogwritevalue) is set to a value other than zero. should i be adding a resistor to the temp sensor or something? if it helps here is the scope code:

void loop()
{
tempC = ( 5.0 * analogRead(temPin) * 100.0) / 1024.0;
lcd.setCursor(5,0);
lcd.print(tempC);

if (tempC > 27) // ideally no more than 29
{
lcd.setCursor(8,0);
lcd.print(“WARNING!”);
lcd.setCursor(8,1);
lcd.print(“Too Hot!”);
analogWrite(fanPin, 255);//0 - 225
}
else if (tempC < 23) // ideally no less than 18
{
lcd.setCursor(8,0);
lcd.print(“WARNING!”);
lcd.setCursor(8,1);
lcd.print(“Too Cold!”);
analogWrite(fanPin,0);
}
else
{
lcd.setCursor(8,0);
lcd.print(“Nominal”);
lcd.setCursor(8,1);
lcd.print(“Envirmnt”);
analogWrite(fanPin, 0);
}
tempC = 0;//set it to zero, get it ready for next loop
delay(1000); //Every second update
}

also, when i set the value other than 0 or 255 the fan gets very noisy... why is that? thanks

I have connected a fan

So, any picture of the connection?
I simply don't like the sound of this "9V battery + LCD + fan" combo, do you know why?

sorry about that… Im not using a 9v bat, i was just doing that in the beginning to see if it works. im using an external power supply to power the 12v fan, but yeh the sensor and lcd use the Arduino power. i have attached the schematic. reference:
http://www.barnesian.com/2011/05/arduino-powered-smart-fan-controller.html

i made some changes though:
-not using the rotary encoder (looks too complicated right now…i mean the programing part,not ready for it) so took it out

  • using the LM35 temp sensor going to analog A0 pin (WITHOUTthe 4.6K res) because all the tutorials I’ve seen regarding the LM35, no one uses the resistor so i assumed i don’t have to either
  • not using the IRF510 mosfet, instead using TIP-122.
  • my fan had three wires (black, blue, and red) not using the blue, just black and red.

hope this would help as to point out where the problem may be.
thanks in advance.
SN
Cheers

What is the power rating of your external power and the fan?