The Digispark > Digispark Project Ideas

Internal temp sensor read w/o LCD

(1/1)

vdubadub34:
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: ---#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);
--- End code ---

Navigation

[0] Message Index

Go to full version