Show Posts
Pages: 1 ... 6 7 [8]
106  Using Arduino / Project Guidance / Re: Arduino killing all my temp sensors? on: March 17, 2012, 07:36:13 am


Try replacing the 1 uF cap with a 10k or more resistor.


Will do when I get back home
107  Using Arduino / Project Guidance / Re: Arduino killing all my temp sensors? on: March 17, 2012, 07:35:01 am
Have a look at http://www.ladyada.net/learn/sensors/tmp36.html

Looks like you wiring is OK - could you post your code?



Here is the code for the “sensors bench”:
Code:
// A1 : thermistor 10k SR PASSIVES (Ref tme.eu NTCC-10K)
// A2 : thermistor 10k noname (Ref tme.eu 640-10K)
// A3 : LM35DZ
// A4 : LM335Z
// A5 : MCP9700
// resultat LM35 = NTCC-10K > 640-10K > MCP9700 (impedance) > LM335 (nocal)

#include <math.h>;

int therm1Pin = A1;
int therm2Pin = A2;
int lm35Pin = A3;
int lm335Pin = A4;
int mcp9700Pin = A5;

void setup() {
  Serial.begin(9600);
  Serial.println("Ready.");
}

//this function copy pasted from an example I found
double Thermistor(int RawADC) {
  double Temp;
  // See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15;           // Convert Kelvin to Celcius
  return Temp;
}

void loop() {
  // display labels
  Serial.println("\t\tTherm1\t\tTherm2\t\tLM35\t\tLM335\t\tMCP9700");
 
  // read every sensor senseurs
  int therm1 = analogRead(therm1Pin);
  int therm2 = analogRead(therm2Pin);
  int lm35   = analogRead(lm35Pin);      //
  delay(5);                              // multiplexage?
      lm35  = analogRead(lm35Pin);      //
  int lm335  = analogRead(lm335Pin);
  delay(5);
      lm335 = analogRead(lm335Pin);
  int mcp9700= analogRead(mcp9700Pin);
  delay(5);
      mcp9700 = analogRead(mcp9700Pin);
     
  // display raw analog
  Serial.print("Analog:\t\t");
  Serial.print(therm1); Serial.print("\t\t");
  Serial.print(therm2); Serial.print("\t\t");
  Serial.print(lm35); Serial.print("\t\t");
  Serial.print(lm335); Serial.print("\t\t");
  Serial.println(mcp9700);
 
  // convert to volts
  float voltTherm1 = therm1 / 1023.0 * 5.0;
  float voltTherm2 = therm2 / 1023.0 * 5.0;
  float voltLm35   = lm35 * (5.0 / 1023);
  float voltLm335  = lm335 / 1023.0 * 5.0;
  float voltMcp9700= mcp9700 / 1023.0 * 5.0;
 
  // display voltages
  Serial.print("Voltages:\t");
  Serial.print(voltTherm1, 4); Serial.print("\t\t");
  Serial.print(voltTherm2, 4); Serial.print("\t\t");
  Serial.print(voltLm35, 4); Serial.print("\t\t");
  Serial.print(voltLm335, 4); Serial.print("\t\t");
  Serial.println(voltMcp9700, 4);
 
  // convert to celsius
  float celsTherm1 = Thermistor(therm1);
  float celsTherm2 = Thermistor(therm2);
  float celsLm35 = (voltLm35*100);
  float celsLm335 = (voltLm335*100)-273.15;
  float celsMcp9700 = ((voltMcp9700-.5)*100);
 
  // display celsius
  Serial.print("Temps:\t\t");
  Serial.print(celsTherm1); Serial.print("\t\t");
  Serial.print(celsTherm2); Serial.print("\t\t");
  Serial.print(celsLm35); Serial.print("\t\t");
  Serial.print(celsLm335); Serial.print("\t\t");
  Serial.println(celsMcp9700);
 
  // new line
  Serial.println("*******************************************************************************************************************************");
  delay(1000);
}

And for the second schematics. This is going to be a fridge temperature monitoring alarm. Note there are provisions for lights and a piezzo. It used to work the way it was in Fritzing and with the same code the first time I wired it around. When I saw the sensor's mess, I disconnected everything but the sensor to try and narrow down the problem:
Code:
// prend la temperature sur A0 (MCP9700), la converti en Volts puis en Celsius puis
// imprime sur port serie

int tempPin = 0;

int loLedPin = 8;
int okLedPin = 9;
int hiLedPin = 10;
int piezoPin = 11;

int analogTempRead;
float celsiusTempRead;
int aref_voltage;

void setup() {
  Serial.begin(9600);
  aref_voltage = 50;           // *10 to avoid setting a float if using 3.3V
  pinMode(loLedPin, OUTPUT);
  pinMode(okLedPin, OUTPUT);
  pinMode(hiLedPin, OUTPUT);
  pinMode(piezoPin, OUTPUT);
  Serial.println("Ready.");
}

void loop() {
  analogTempRead = 0;
  for (int i =0; i<16; i++) analogTempRead += analogRead(tempPin);
  float volt = analogTempRead * (aref_voltage/10.0)/16368;
  Serial.print(volt); Serial.println(" V");

  int celsiusTempRead = ((volt-.5)*100)+0.5;   // +0.5 to round up
  //celsiusTempRead = 150;
  Serial.print("Temperature = "); Serial.print(celsiusTempRead);
  Serial.println(" C");
 
  if (celsiusTempRead >= -30 && celsiusTempRead <= 0) {
    digitalWrite(loLedPin, HIGH);
    digitalWrite(okLedPin, LOW);
    digitalWrite(hiLedPin, LOW);
    delay(300);
  }
  if (celsiusTempRead > 0 && celsiusTempRead <= 8) {
    digitalWrite(loLedPin, LOW);
    digitalWrite(okLedPin, HIGH);
    digitalWrite(hiLedPin, LOW);
    delay(300);
  }
  if (celsiusTempRead > 8 && celsiusTempRead <= 100) {
    digitalWrite(loLedPin, LOW);
    digitalWrite(okLedPin, LOW);
    digitalWrite(hiLedPin, HIGH);
    delay(300);
  }
  if (celsiusTempRead < -30 || celsiusTempRead > 100) {
    digitalWrite(loLedPin, HIGH);
    digitalWrite(okLedPin, LOW);
    digitalWrite(hiLedPin, HIGH);
    analogWrite(piezoPin, 1);
    delay(150);
    digitalWrite(loLedPin, LOW);
    digitalWrite(okLedPin, HIGH);
    digitalWrite(hiLedPin, LOW);
    delay(150);
  }
}
108  Using Arduino / Project Guidance / Re: Arduino killing all my temp sensors? on: March 17, 2012, 07:28:59 am
I am still a newb so sorry if this is simple but I found if you are using serial monitor you need to make sure the speeds are the same.
If you set in code then change the serial monitor to match.

Also in 2nd picture, your capacitor is behind the feeds, wouldn't it need to be in front?  Again I am just guessing as I don't really know smiley

Hope this helps.
I have RHT03, DS1307, BMP085, 16x2 LCD connecting to a UNO.  But not fully working yet.
Sensors are nice though smiley-wink are yours good?

When I say incoherent readings I meant -30C then jumping to +450C, not ASCII gibberish like when the speeds are not the same.
AFAIK, resistors can be put anywhere as long as they are there. I was confused too because on schematics and tutorials you can find, they can be placed after or before a component but I googled it up and it seems it makes no difference.

My sensors are good and I can see a lot of applications for them, when they don't heat up like crazy!
109  Using Arduino / Project Guidance / [SOLVED] Arduino killing all my temp sensors? on: March 16, 2012, 03:58:16 pm
Hi all,

I'm fairly new to electronics but I successfully built a few things with my breadboard, some resistors, LEDs and temperature sensors.

This afternoon I received a collection of thermistors and some temperature sensors (LM35, LM335). I wanted to benchmark them all against each other so I made a little assembly, they were all working fine, everything was perfect.


Then I want to work again on another project involving the MPC9700 and so I make this:

Resistor is 220 ohms, capacitor 1uF.

And I am getting strange readings. I realised I inverted polarity on the MPC9700 so I turn it around. But it was not returning coherent readings using a code I knew was working before with this sensor.

so I replaced it with an LM35 thinking that I might have destroyed it by inverting + and -


But the LM35 was returning strange values too (it was working not even an hour ago) and became very very very very very hot. I tried again with the MPC9700, the capacitor and the resistor with the same result. I unplugged everything and I have been wondering ever since... What is going on??
Did I damage my Arduino? It's still blinking, the digital outputs are fine (tested with LEDs) but now I'm scared to hook anything up to the analog pins... Anyone got a clue as to what happened?
110  Using Arduino / Sensors / Re: Inconsistant analog readings on: March 16, 2012, 02:22:26 pm

I am using an external 12V 0.5mA power supply with the Arduino Uno R3.


Presume you meant 0.5A, or 500mA, not 0.5mA!

Indeed.

I found where the problem was.

1. The breadboard causes some interference in the readings (I shouldn't use the + and - rails)
2. A 220 Ohms resistor on the Vdd and a 1uF capacitor between Vout and GND on the MCP9700 filter out the interferences and I'm getting more accurate values
111  Using Arduino / Sensors / Re: Inconsistant analog readings on: March 13, 2012, 07:34:27 pm
The sensor is a MCP9700. I ordered other sensors and thermistors to match them against each other.
I am using an external 12V 0.5mA power supply with the Arduino Uno R3.

Thanks for the tips!
112  Using Arduino / Sensors / Re: Inconsistant analog readings on: March 11, 2012, 11:26:35 am
The correct way to wire up is to avoid ground "loops" like this and use a "star" configuration - each off-board device gets a separate ground wire.  Certainly you shouldn't share a ground wire between an analog sensor and a high-current output device (well, medium current I suppose).

Hmm. So I should put every sensor on its own ground line? Maybe I'm missing something out here but there are only 3 GND pins on the Arduino…

Does using 3.3V instead of 5V change anything?
113  Using Arduino / Sensors / Inconsistant analog readings on: March 10, 2012, 06:19:24 pm
Hi all,

I'm sorry if this is a dull question, I don't know much about electronics (I just started out).

This is what my actual breadboard looks like (cf attachment).

If I put all the components to the GND rail on my breadboard, I am getting wrong and inconsistent readings: 28C to 30C vs 26C as per another standalone close by thermometer.

But if I put the sensor and the LEDs to different GND pins directly on the Arduino (thus bypassing the power rails of my breadboard), then I am getting more accurate and consistent readings.

I suspect this has to do with interference maybe between the digital and analog “parts” of the ATMega or maybe because it's too much wire and catching too much interference?

Either way, I'd like to understand what is happening and what would be the “best practice” answer to this situation?
Thanks,
114  Using Arduino / Programming Questions / Re: Conditional loop with a range of values instead of exact values? on: March 10, 2012, 04:32:23 pm
Thanks
115  Using Arduino / Programming Questions / Re: float number calculation issue on: March 10, 2012, 03:50:35 pm
Very useful info, much appreciated smiley
116  Using Arduino / Programming Questions / Conditional loop with a range of values instead of exact values? on: March 10, 2012, 03:49:07 pm
Hi all,

I have a little project where I want to use a temperature sensor to check if the temperature in the fridge is too low too high or within normal range and light LEDs accordingly.

I am struggling with the conditional loop to figure out which LED to light out. I would like to light up the LOW indicator if the temperature is between say -30C and 0C, light up the NORMAL indicator if temperature is between +1C and +6C, light up the HIGH indicator if temperature is between +7C and above and light up the LOW and HIGH if it is outside of these ranges.

I guess I could do it with an if() statement but I would like to know if there is a cleaner way of doing this?

Thanks!
117  Using Arduino / Programming Questions / Re: float number calculation issue on: March 09, 2012, 11:38:31 am
I see, thanks!
118  Using Arduino / Programming Questions / float number calculation issue on: March 09, 2012, 07:05:39 am
Hello all,

I just received my Arduino and I am following some basic tutorial to better understand how to program it etc.

Now, my very simple program reads the temperature sensor and converts its output in ºC.

Code:
int tempPin = 0;
int analogTempRead;
float celsiusTempRead;

void setup() {
  Serial.begin(9600);
  Serial.println("Ready.");
}

void loop() {
  analogTempRead = analogRead(tempPin);
  delay(3);
  analogTempRead += analogRead(tempPin);  // Taking 5 samples in an attempt
  delay(3);                               // to get a more accurate reading
  analogTempRead += analogRead(tempPin);  // but I'm not sure it makes any
  delay(3);                               // difference…
  analogTempRead += analogRead(tempPin);
  delay(3);
  analogTempRead += analogRead(tempPin);
  analogTempRead /= 5;
  celsiusTempRead = (((analogTempRead*5/1024)-.5)*100);
  Serial.print("Temperature = "); Serial.print(celsiusTempRead);
  Serial.println(" C");
  delay(1000);
}

What I don't understand is what happens on this line:
Code:
celsiusTempRead = (((analogTempRead*5/1024)-.5)*100);
If I divide by 1024, I am getting a bogus result (ie -50.00 C) but if I divide by 1024.0 then I am getting around 25 which is about the right temperature.
Why does 1024 vs 1024.0 make any difference?

Also, if you have any suggestions re the general structure of the code, I'd be glad to hear them as I learnt how to code by myself.
Pages: 1 ... 6 7 [8]