Sensor temperatura Auto

Buenas noches. Les comparto el proyecto que acabo de hacer para el auto.

Consta de 2 sensores de temperatura (exterior e interior) y medidor de voltaje de la batería. También tiene 1 botón, con el cual se pasa de "pantalla" en pantalla.

Por el momento, lo tengo así, a futuro me queda colocar un sensor de temperatura en las toberas de aire.

Se los quiero compartir, porque me costo bastante la parte del código del botón y hacer andar el modulo OLED en general.

Les adjunto un par de fotos y el sketch.

Fotos

//SCL pin13
//SDA pin11
//RES pin2
//DC pin9

#include "U8glib.h"

int Vo1;
int Vo2;
float R1pd = 10000;
float logR2, R2pd, T, T2;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

int state=1;
int buttonPoll=0;

unsigned long previousMillis = 0;
const long interval = 1000;

int value;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // resistance of R1 (100K) -see text!
float R2 = 10000.0; // resistance of R2 (10K) - see text!

// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The following list is incomplete. The complete list of supported 
// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device

//U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(13, 11, 99, 9, 2); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
U8GLIB_SSD1306_128X64 u8g(13, 11, 99, 9, 2); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9


void setup(void) {
Serial.begin(9600);
  // flip screen, if required
  // u8g.setRot180();
  
  // set SPI backup if required
  //u8g.setHardwareBackup(u8g_backup_avr_spi);

  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}

void loop(void) {
  unsigned long currentMillis = millis();
  static unsigned long thisMicros = 0;
  static unsigned long lastMicros = 0;
  
  if(digitalRead(8)==1){
   delay(10);
   Serial.println("Boton Presionado+++++++++++++++++++++++");
while(digitalRead(8)==1)

{
  Serial.print("Lectura digitalRead:");
  Serial.println(digitalRead(8));
  delay(10);
   Serial.println("LIBERE BOTON/////////////////////////////");
   Serial.print("State:");
   Serial.println(state);
}

Serial.println("BOTON LIBERADO--------------------------");
state=state+1;
}


switch (state) {
case 1:
Serial.println("Caso 1");

    if (currentMillis - previousMillis >= interval) {
    Serial.println(currentMillis);
    previousMillis = currentMillis;
    actutemp(); 
    }

    u8g.firstPage();
    do {
    u8g.setFont(u8g_font_7x14);
    u8g.setPrintPos( 0, 10);
    u8g.print(thisMicros - lastMicros);

    //u8g.setFont(u8g_font_6x13);
    //u8g.setPrintPos(0, 10); 
    //u8g.print("Pantalla 1:");
    
    u8g.setFont(u8g_font_7x14);
    u8g.setPrintPos(0, 30);
    u8g.print("Interior");
    u8g.setPrintPos(0, 55);
    u8g.print("Exterior");
    
    u8g.setFont(u8g_font_helvB18);
    u8g.setPrintPos(82, 35);
    u8g.print(T);
    u8g.setPrintPos(82, 62);
    u8g.print(T2);
    
    //u8g.drawLine(0, 40, 128, 40);

    } while( u8g.nextPage() );
  // rebuild the picture after some delay
  break;

case 2:
Serial.println("Caso 2");

    if (currentMillis - previousMillis >= interval) {
    Serial.println(currentMillis);
    previousMillis = currentMillis;
    actuvolt(); 
    }

    u8g.firstPage();
    do {
    u8g.setFont(u8g_font_7x14);
    u8g.setPrintPos( 0, 10);
    u8g.print("2/3");

    u8g.setPrintPos(82, 35);
    u8g.print(vin);
    
    } while( u8g.nextPage() );
  // rebuild the picture after some delay
  break;

  case 3:
Serial.println("Caso 3");
    u8g.firstPage();
    do {
    u8g.setFont(u8g_font_7x14);
    u8g.setPrintPos( 0, 10);
    u8g.print("3/3");
    } while( u8g.nextPage() );
  // rebuild the picture after some delay
  break;

 default:
 Serial.println("RESET a cero");
 state=1;
 break;
} //fin State
  lastMicros = thisMicros;
  thisMicros = micros();
}

void actutemp(void) {
  Serial.println("Actualizo Temperatura");
  Vo1 = analogRead(A1);
  R2pd = R1pd * (1023.0 / (float)Vo1 - 1.0);
  logR2 = log(R2pd);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T = T - 273.15;

  Vo2 = analogRead(A2);
  R2pd = R1pd * (1023.0 / (float)Vo2 - 1.0);
  logR2 = log(R2pd);
  T2 = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T2 = T2 - 273.15;

  }

void actuvolt(void) {
  Serial.println("Actualizo Voltaje");
  value = analogRead(A5);
  vout = (value * 5.15) / 1023.0; // see text
  vin = vout / (R2 / (R1 + R2));
  vin = vin + 0.12;
  }

OLED_CAR_PROYECT_TEMPyVOLTS.ino (4.21 KB)

Hola diegotala1985, buen trabajo!!
Moví tu hilo y luego me arrepentí y lo regresé a proyectos justamente porque vi el trabajo que le pusiste, asi que merece estar acá.
Lástima que tus imágenes son de gran tamaño y no pueden verse en el hilo a menos que las reduzcan en bytes.
No puedes superar 2MB y cada foto tiene mas o menos ese tamaño.