Arduino NTC teplomer s MAX7219
Moderátor: Moderátoři
- Přílohy
-
Thermometer32_3xNTC_ver_MAX7219_test.zip- (3.16 KiB) Staženo 45 x
- Přílohy
-
Thermometer32_3xNTC_ver_MAX7219_test.zip- (3.19 KiB) Staženo 62 x
Kód: Vybrat vše
#include "LedControl.h"
LedControl lc(2,4,3,3);
int ThermistorPina = A0;
int ThermistorPinb = A1;
int ThermistorPinc = A2;
float teplotaa;
float teplotab;
float teplotac;
void setup(){
for ( int i = 0; i < 3; i++ )
{
lc.shutdown(i, false);
lc.setIntensity(i, 0);
lc.clearDisplay(i);
}
}
static void zpracujTeplotu(int adresa, int termistorPin, float *teplota)
{
int Va;
int tempC;
float Reading;
float R1 = 10000;
float logR2, R2, T, Tc, Tca, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
char minus;
Va = analogRead(termistorPin);
R2 = R1 * (1023.0 / (float)Va -1);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tca = (T - 273.15);
Tf = (T * 9.0)/ 5.0 + 32.0;
tempC=Tca*10;
minus = ' ';
if ( tempC < 0 ){minus = '-'; tempC *= -1;}
int temp1 = (tempC % 10); // one of temp
int temp2 = (tempC / 10) % 10; // tens of temp
int temp3 = (tempC / 100) % 10; // units of temp
lc.setRow(adresa,7,15);
lc.setRow(adresa,6,0);
lc.setRow(adresa,5,0);
if ( temp3 == 0 ){
lc.setChar(adresa,4,' ',false);
lc.setChar(adresa,5,minus,false);}
else {lc.setChar(adresa,5,minus,false);
lc.setDigit(adresa,4,temp3,false);}
lc.setDigit(adresa,3,temp2,true);
lc.setDigit(adresa,2,temp1,false);
lc.setRow(adresa,1,99);
lc.setRow(adresa,0,78);
*teplota = Tca;
}
void loop(){
zpracujTeplotu(0, ThermistorPina, &teplotaa);
zpracujTeplotu(1, ThermistorPinb, &teplotab);
zpracujTeplotu(2, ThermistorPinc, &teplotac);
delay(300);
}Použití se snad dá okoukat z tohohle:
Kód: Vybrat vše
#include "LedControl.h"
#include "blikac.h"
int ThermistorPina = A0;
int ThermistorPinb = A1;
int ThermistorPinc = A2;
float teplotaa;
float teplotab;
float teplotac;
#define power 11 //LED výstup-11-POWER/Porucha-bliká
unsigned long lastTempTime;
LedControl lc(2,4,3,3);
BlikacPin blikacPower(power);
BlikacText blikacText(&lc, 0);
void setup(){
pinMode(power, OUTPUT); //LED výstup-11-režim normal(svieti trvalo-POWER)/režim porucha(bliká)
lastTempTime = millis();
for ( int i = 0; i < 3; i++ )
{
lc.shutdown(i, false);
lc.setIntensity(i, 10);
lc.clearDisplay(i);
}
blikacPower.nastavDoby(200, 200);
blikacPower.svit();
blikacText.nastavDoby(200, 200);
blikacText.nastavJas(10);
blikacText.blikej();
}
static void zpracujTeplotu(int adresa, int termistorPin, float *teplota)
{
int Va;
int tempC;
float Reading;
float R1 = 10000;
float logR2, R2, T, Tc, Tca, Tf;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
char minus;
Va = analogRead(termistorPin);
R2 = R1 * (1023.0 / (float)Va -1);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tca = (T - 273.15);
Tf = (T * 9.0)/ 5.0 + 32.0;
tempC=Tca*10;
minus = ' ';
if ( tempC < 0 ){minus = '-'; tempC *= -1;}
int temp1 = (tempC % 10); // one of temp
int temp2 = (tempC / 10) % 10; // tens of temp
int temp3 = (tempC / 100) % 10; // units of temp
lc.setRow(adresa,7,15);
lc.setRow(adresa,6,0);
lc.setRow(adresa,5,0);
if ( temp3 == 0 ){
lc.setChar(adresa,4,' ',false);
lc.setChar(adresa,5,minus,false);}
else {lc.setChar(adresa,5,minus,false);
lc.setDigit(adresa,4,temp3,false);}
lc.setDigit(adresa,3,temp2,true);
lc.setDigit(adresa,2,temp1,false);
lc.setRow(adresa,1,99);
lc.setRow(adresa,0,78);
*teplota = Tca;
}
void loop(){
blikacPower.loop();
blikacText.loop();
if ( millis() - lastTempTime < 300 ) return;
lastTempTime = millis();
zpracujTeplotu(0, ThermistorPina, &teplotaa);
zpracujTeplotu(1, ThermistorPinb, &teplotab);
zpracujTeplotu(2, ThermistorPinc, &teplotac);
if ( teplotac > 43 )
{
blikacPower.nastavDoby(100, 100);
blikacPower.blikej();
}
}- Přílohy
-
blikac.zip- (1.49 KiB) Staženo 63 x