Hi! I'm currently doing a project for uni, where I'm using the TMP36 temperature sensor and serial comunication, between the Arduino UNO and Processing, to have the sensor control visuals. However, I've run into a problem, where the Arduino serial monitor gives me viable answers in celsius, between 25 degrees and 37-40 degrees when I touch it. However, when I print the values from the sensor in the Processing serial monitor, the numbers are way different - and not just in a way where they can be calculated and converted, they fluctuate way more in Processing for some reason.
Here is my Arduino code:
float temp;
int tempPin = 1;
void setup()
{
Serial.begin(9600);
} void loop()
{
temp = analogRead(tempPin);
temp = temp * 0.48828125; //calculates value in fahrenheit
temp = ((temp - 32) * 5) / 9; //converts from fahrentheit to celcius
Serial.println(temp);
delay(500);
}
And the values the Arduino's giving me
Processing code:
import processing.serial.*;
Serial myPort;
float tempValue;
void setup() {
size(1200, 600);
myPort = new Serial(this, "COM3", 9600);
}
void draw() {
tempValue = myPort.read();
println(tempValue);
delay(500);
}
The values Processing is giving me
Arduino UNO and breadboard setup:
I must've done something wrong somewhere, but I hope someone can help me!