Celica Water Temp Gauge

Any old or new electronic projects on the go
Post Reply
bluejets
Posts: 316
Joined: 19 Jun 2019, 04:09

Celica Water Temp Gauge

Post by bluejets »

Recently did some revamping on the '78 Celica with clutch, water pump, radiator etc.

After a check run down the road, noticed the original temp guage reading a bit high.
A check with the multi and a temp probe showed that the temp was fine, just a bit out on the guage.
This has a bi-metal type regulator for the guage voltages which I replaced many moons ago but made the stuff up of positioning it in a rather hard to access place.
Well, set and forget, so should be no problem but during the above refit, must have bumped the settings.

To save all the ripping out again, decided on a 128 x 32 Oled and DS18B20 temp sensor in the dash where the air-con button used to live. RAC never ever worked properly and was abandoned yonks ago.

Anyhow, couple of pics of the yet to be completed and fitted guage, code etc.

Code: Select all

/*128x32 Oled temp guage Celica 1_November 2020
*/
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
#define ONE_WIRE_BUS 2                   // Data wire is plugged into pin 2 on the Arduino
#include <DallasTemperature.h>

OneWire oneWire(ONE_WIRE_BUS);          // Setup a oneWire instance to communicate with any OneWire devices

DallasTemperature sensors (&oneWire);   // Pass our oneWire reference to Dallas Temperature.

U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);

void setup() {
  u8g2.begin();
  sensors.begin();


}

void loop() {
  sensors.requestTemperatures();
  u8g2.clearBuffer();                     // clear the internal memory
  u8g2.setFont(u8g2_font_logisoso32_tf);  // choose a suitable font
  u8g2.setCursor (0, 32);
  
  //comment out whichever of the following for degrees Celcuis or Fahrenheit
  //u8g2.print (sensors.getTempCByIndex(0),1);  // 
  u8g2.print(sensors.getTempFByIndex(0),1);
  
  u8g2.setCursor(100, 38);
  u8g2.print((char)176); //degrees symbol
  u8g2.setCursor(110, 32);
  u8g2.print("F");
  u8g2.sendBuffer();          // transfer internal memory to the display
  delay(200);


}
Attachments
3.jpg
bluejets
Posts: 316
Joined: 19 Jun 2019, 04:09

Re: Celica Water Temp Gauge

Post by bluejets »

Phil_G wrote: 06 Nov 2020, 11:09 Thats a proper shopping list Jeff!

Hehehe......yeah...just keeping track of what I have on order and what has or hasn't arrived.
Old age I guess..... :D
bluejets
Posts: 316
Joined: 19 Jun 2019, 04:09

Re: Celica Water Temp Gauge

Post by bluejets »

Wanted to add an alarm level trip to the above and the update delay time for the display, under certain settings, would not allow correct "blink-without-delay" timing.

So went for the simple answer, added a flashing type LED. :)

This latest version also has the ability to adjust the alarm trip level at any time with a button press and via a 15 turn pot.
I think that'll be enough for now.

Cheers Jorgo

Code: Select all

/*128x32 Oled temp guage with alarm flashing type LED.....Celica 9_November 2020
  7809 9V regulator feeding into RAW terminal Arduino ProMini
  A4 ...SDA
  A5 ...SCL
  Flashing 3mm LED on pin 3
  DS18B20 waterproof temperature sensor assy 5V, neg and 4k7 resistor from 5v to signal....
  Temperature signal into pin 2
  Setup switch to enable a 15 turn pot to adjust the trip level during setup
  Note that the Wire.h library doesn't seem necessary.....it was included in the original code from Julian Ilett (https://www.youtube.com/watch?v=MHogSbRPa28)

*/
#include <Arduino.h>
#include <U8g2lib.h>
//#include <Wire.h>
#define ONE_WIRE_BUS 2                   // Data wire is plugged into pin 2 on the Arduino
#include <DallasTemperature.h>

OneWire oneWire(ONE_WIRE_BUS);          // Setup a oneWire instance to communicate with any OneWire devices

DallasTemperature sensors (&oneWire);   // Pass our oneWire reference to Dallas Temperature.

U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0);

int tripPot = A0; //Adjust to required level after testing...possibly 200
int tripLevel = 0;  //analog level from 0 to 256
int tripVal = 0;
int alarmPin = 3;  // change to pin 3 after testing complete
int swPin = 4;     //set up trip level during setup


void setup() {
  u8g2.begin();
  sensors.begin();
  pinMode(alarmPin, OUTPUT); // on-board LED for test...pin 3 there-after
  pinMode(swPin, INPUT_PULLUP); //set up trip level switch

  tripVal = analogRead(tripPot);
  delay(200);
  tripLevel = map(tripVal,0,1023,0,255);
  
}

void loop() {
  
  //setup trip level

  while (digitalRead(swPin) == LOW) {
    tripVal = analogRead(tripPot);
    delay(200);
    tripLevel = map(tripVal, 0, 1023, 0, 255);
    u8g2.clearBuffer();
    u8g2.setFont(u8g2_font_logisoso32_tf);
    u8g2.setCursor(0, 32);
    u8g2.print(tripLevel);
    u8g2.sendBuffer();
    delay(100);
  }

  

  //Read and display temperature

  sensors.requestTemperatures();
  u8g2.clearBuffer();                     // clear the internal memory
  u8g2.setFont(u8g2_font_logisoso32_tf);  // choose a suitable font .....NOTE:- changed suffix from tr to tf to get degree symbol to work
  u8g2.setCursor (0, 32);

  //comment out whichever of the following for degrees Celcuis or Fahrenheit
  //u8g2.print (sensors.getTempCByIndex(0),1);  //
  u8g2.print(sensors.getTempFByIndex(0), 1);

  // alarm output to flashing LED
 
  if (sensors.getTempFByIndex(0) >= tripLevel) {
    digitalWrite(alarmPin, HIGH);
  }
  else {
    digitalWrite(alarmPin, LOW);
  }

  // now set up and display the screen
  
  u8g2.setCursor(100, 38);
  u8g2.print((char)176); //degrees symbol
  u8g2.setCursor(110, 32);
  u8g2.print("F");
  u8g2.sendBuffer();          // transfer internal memory to the display
  delay(200);
}
Guage Circuit.jpg
Post Reply