Digistump Forums
The Digispark => Digispark Project Ideas => Topic started by: dougal on March 26, 2013, 12:37:11 pm
-
Based on @microtherion's comment, I found this: http://andrey.mikhalchuk.com/2011/06/20/reading-attiny854525-internal-temperature-sensor.html
Then I tried this:
#include <TinyWireM.h>
#include <LiquidCrystal_I2C.h>
#define GPIO_ADDR 0x27
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines
void setup(){
TinyWireM.begin(); // initialize I2C lib - comment this out to use with standard arduinos
lcd.init(); // initialize the lcd
lcd.backlight(); // Print a message to the LCD.
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();
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print("Intrn Tmp: ");
lcd.print(temp); lcd.print("C");
delay(1000);
}
I was getting readings of around 10C originally, which didn't seem right. So I removed the 13 degree adjustment in Andrey's code (commented line). Adding that back in currently results in a 23C reading, or 73.4F, which is probably about right for this office.
Also, according to Andrey's notes, if you do other analog reads, you might have to reset the internal reference again before taking another temperature reading.
-
NOOB - I would like to see a remote temperature sensor. Could you transmit that temperature via the wireless nRF24L01+ to another Digispark with an RF24 and an LCD display or a Charliplex display? Very similar to the joystick example: http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo. Are there enough pins on the Digispark for RF24 & LCD/Charliplex? The first spark could also have the external 1-wire temperature sensor, but the onboard should work just fine.
-
An RF24 would take 5 pins
Charlieplex 5
LCD 2
- so you can't combine any of those three. You could with an expander and some recoding of the libraries involved though.