Sdos a todos los del foro, en esta seccion quiero compartir un proyecto que realize y que ya tiene un año de prueba con resultados excelentes, la idea surge de la necesidad de medir temperatura en un auto de los años 50 con arduino, display 7 segmentos y usando el sensor original del auto. posteare el codigo y la vista PCB de fritzing, y los planos para imprimir en PCB, asi como algunas fotos de relojes de temp trabajando. Sdos y Gracias.
PD: La vista en protoboard se las debo con la premura no la hice.
Este es el reloj funcionando ya, como se puede ver a la izquierda esta el sensor de temperatura del auto. este es una resistencia variable NTC por lo tanto se tomaron muestras de su valor a diferentes temperaturas para ver la variacion no lineal, y se calculo mediante formula como se vera en el codigo.
Cabe destacar que cada sensor tendra su calculo independiente para lograr la fidelidad de la lectura.
#include <math.h>
//
// Temperatura de carro
// Construcción de un medidor de temperatura para autos con Arduino
// 20.03.2019
//
const int SEGMENTS = 7;
const int SEG_PINS[SEGMENTS] = {4, 8, 11, 9, 2, 5, 12};
const int DP_PIN = 10;
const int DIGITS = 3;
const int DIG_PINS[DIGITS] = {3, 6 , 7,};
const int SYMBOL_COUNT = 10;
//const int SYMBOLS[SYMBOL_COUNT][SEGMENTS] = {//CATODO COMUN CAMBIAR LOW,HIGH
// {1, 1, 1, 1, 1, 1, 0}, //| 0
// {0, 1, 1, 0, 0, 0, 0}, //| 1
//{1, 1, 0, 1, 1, 0, 1}, //| 2
// {1, 1, 1, 1, 0, 0, 1}, //| 3
// {0, 1, 1, 0, 0, 1, 1}, //| 4
// {1, 0, 1, 1, 0, 1, 1}, //| 5
// {1, 0, 1, 1, 1, 1, 1}, //| 6
// {1, 1, 1, 0, 0, 0, 0}, //| 7
// {1, 1, 1, 1, 1, 1, 1}, //| 8
// {1, 1, 1, 1, 0, 1, 1}, //| 9
const int SYMBOLS[SYMBOL_COUNT][SEGMENTS] = {//ANODO COMUN CAMBIAR LOW,HIGH
{0, 0, 0, 0, 0, 0, 1}, //| 0
{1, 0, 0, 1, 1, 1, 1}, //| 1
{0, 0, 1, 0, 0, 1, 0}, //| 2
{0, 0, 0, 0, 1, 1, 0}, //| 3
{1, 0, 0, 1, 1, 0, 0}, //| 4
{0, 1, 0, 0, 1, 0, 0}, //| 5
{0, 1, 0, 0, 0, 0, 0}, //| 6
{0, 0, 0, 1, 1, 1, 1}, //| 7
{0, 0, 0, 0, 0, 0, 0}, //| 8
{0, 0, 0, 0, 1, 0, 0}, //| 9
};
const int ITERATIONS = 50;
const int DELAY = 4;
const int Rc=2000; //se ponen dos resistencias de 1k en serie con los 5v de arduino esta es la resistencia maxima a temp ambiente.
const int Vcc=5;
const int SensorPIN=A0;
const int zumbador=15;
float celcius=0;
float A=1.759045004e-3;
float B=1.562590388e-4;
float C=8.271117805e-7;
float K=2.5;
void setup()
{
float measureN=MeasureN(30, getTemperature);
pinMode(zumbador,OUTPUT);
for (int i = 0; i < SEGMENTS; i++) {
pinMode(SEG_PINS[i], OUTPUT);
}
pinMode(DP_PIN, OUTPUT);
for (int i = 0; i < DIGITS; i++) {
pinMode(DIG_PINS[i], OUTPUT);
}
}
void loop() {
displayTemperature(getTemperature());
pitaTemp(vigilaTemp());
}
float MeasureN( int samplesNumber, float(*funct)())
{
float sum;
for (int i=0; i<samplesNumber; i++)
{
sum +=funct();
}
return sum/samplesNumber;
}
float getTemperature()
{
float raw= analogRead(SensorPIN);
float V= raw/1024*Vcc;
float R=(Rc*V)/(Vcc-V);
float logR=log(R);
float R_th=1.0/(A+B*logR+C*logR*logR*logR);
float kelvin=R_th-V*V/(K*R)*1000;
float celcius=kelvin-273.15;
return celcius;
}
float vigilaTemp()
{
int alarma=0;
if (alarma >= 95){
digitalWrite(zumbador,HIGH);
}else{
digitalWrite(zumbador,LOW);
}
}
void pitaTemp(int measureN)
{
int alarma=int(measureN);
}
void displayTemperature(int measureN) {
int int_part = int(measureN);
int digits[3];
digits[0] = int_part % 1000/100;
digits[1] = int_part % 100/10;
digits[2] =int_part % 100%10;
if (digits[2] == 10) {
digits[2] = 0;
digits[1]++;
if (digits[1] == 10) {
digits[1] = 0;
digits[0]++;
}
}
for (int i = 0; i < ITERATIONS; i++) {
displaySymbol(0, digits[0], 0);
delay(DELAY);
displaySymbol(1, digits[1], 0);
delay(DELAY);
displaySymbol(2, digits[2], 0);
delay(DELAY);
}
}
void displaySymbol(int digit, int symbol, int dp) {
//| Check arguments are between ranges.
if (digit < 0 || digit >= DIGITS) {
return;
}
if (symbol < 0 || symbol > SYMBOL_COUNT) {
return;
}
for (int i = 0; i < DIGITS; i++) {
if (i == digit) {
digitalWrite(DIG_PINS[i], HIGH);
}
else {
digitalWrite(DIG_PINS[i], LOW);
}
}
for (int i = 0; i < SEGMENTS; i++) {
digitalWrite(SEG_PINS[i], SYMBOLS[symbol][i] ? HIGH : LOW);
}
if (dp) {
digitalWrite(DP_PIN, LOW);
}
else {
digitalWrite(DP_PIN, HIGH);
}
}
TEMPERATURA_CARRO_MEDIA.ino (6,4 KB)
esta es la imagen del PCB diseñado en Fritzing y le s doy ahora los planos en PDF
TEMPERATURA CARRO_etch_copper_bottom.pdf (19,3 KB)
TEMPERATURA CARRO_etch_mask_bottom.pdf (9,0 KB)
TEMPERATURA CARRO_etch_silk_top.pdf (1,2 KB)
Sdos y Gracias






