View Single Post
ja jeg får til andre analoge ting, men ikke å måle temperatur :S

fikk det til

Her er koden:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int ThermistorPin = A0;
int Vo;
float R1 = 10000.0;
float logR2, R2, T, Tc;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //OLED address
display.clearDisplay();
Serial.begin(115200);
}

void loop() {
Vo = analogReadMilliVolts(2);
R2 = R1 * (((5*1000.0)/ float(Vo))-1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;

display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(70, 0);
display.println("C");
display.display();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(3, 0);
display.println(Tc);
display.display();
delay(10);
}

her er koden fungerende ed at thermistor må være koblet til 3.3 volt og ikke 5volt som jeg lærte nå..

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int ThermistorPin = A0;
int Vo;
float R1 = 10000.0;
float logR2, R2, T, Tc;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //OLED address
display.clearDisplay();
Serial.begin(115200);
}

void loop() {
Vo = analogReadMilliVolts(2);
R2 = R1 * (((3.3*1000.0)/ float(Vo))-1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;

display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(70, 0);
display.println("C");
display.display();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(3, 0);
display.println(Tc);
display.display();
delay(200);
}
Sist endret av ticsyboy; 7. februar 2024 kl. 10:01. Grunn: Automatisk sammenslåing med etterfølgende innlegg.