3

I am trying to get my new velleman vma320 to work with my arduino. It doensn't work at all, the temperature goes down its heated up. I've tried everything. Can somebody help me? Here is my code...

int SensorPin = A0;

void setup() {

  Serial.begin(9600);

}

void loop() {

  //reading
  int sensorvalue = analogRead(SensorPin);
  Serial.print("value: ");
  Serial.print(sensorvalue);

  //voltage
  float voltage = sensorvalue * 5.0;
  voltage /= 1024.0;
  Serial.print(", volts: ");
  Serial.print(voltage); 

  //temperature
  float temperature = (voltage - 0.5) * 100 ;
  Serial.print(" degrees C");
  Serial.println(temperature);

}

Is it something I have done wrong? Or is it just the sensor? I tried it with two sensors.

If you can help me that would be awesome.

Thanks in advance, Jens Van den Eede.

  • 1
    That sensor is a voltage divider and the relation between resistance of the thermistor and output voltage is not linear. Arduino has a [tutorial on reading temperature from a thermistor](https://playground.arduino.cc/ComponentLib/Thermistor2). Except your sensor has a pullup instead a pulldown. – gre_gor Jun 25 '17 at 19:20
  • Thanks @gre_gor, it works now ! – Jens Van den Eede Jun 25 '17 at 20:22
  • 3
    If you solved your problem, you should answer your own question. – gre_gor Jun 25 '17 at 20:34

2 Answers2

3

So, this is the working code for a thermister velleman vma320. According to the way it's wired, voltage will go down as the temperature goes up, and it's not linear.

#include <math.h>

double Thermistor(int RawADC) {
 double Temp;
 Temp =log(10000.0/(1024.0/RawADC-1)); // for pull-up configuration
 Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
 Temp = Temp - 273.15;            // Convert Kelvin to Celcius
 return Temp;
}

void setup() {
 Serial.begin(9600);
}

void loop() {
 Serial.println(int(Thermistor(analogRead(A0))));
 delay(1000);
}
0

Please note the above code only provides accurate temperatures if you are supplying the VMA320 with 3.3VDC (from VCC, not 5V).

Also add "Temp = (Temp * 9.0)/ 5.0 + 32.0;" above "return Temp;" if you wish to convert to °F

Jake
  • 1
  • 1