Author Topic: Internal temp sensor read w/o LCD  (Read 852 times)

vdubadub34

  • Newbie
  • *
  • Posts: 1
Internal temp sensor read w/o LCD
« on: May 15, 2018, 06:48:00 pm »
Just changed some existing code for reading internal temp that dougal posted so it will keyboard print to a leafpad window instead of an LCD. Not really useful for anything as is but it works!

And obviously make sure you have a text editor window open before you plug in the device or well ya know...

Code: [Select]
#include <TinyWireM.h>
#include <DigiKeyboard.h                     
Intrn Tmp:
31C>


#define GPIO_ADDR     0x27





void setup(){
  TinyWireM.begin();                    // initialize I2C lib - comment this out to use with standard arduinos
  analogReference(INTERNAL1V1);
}


int get_temp() {
   int raw = analogRead(A0+15);
   /* Original code used a 13 Cdeg adjustment. But based on my results, I didn't seem to need it. */
   // raw -= 13; // raw adjust = kelvin
   int in_c = raw - 273; // celcius
   return in_c;
}


void loop(){
  int temp = get_temp();
  DigiKeyboard.println("                ");
  DigiKeyboard.println("Intrn Tmp: ");
  DigiKeyboard.print(temp); DigiKeyboard.print("C");
  delay(1000);