Author Topic: DigiSpark as a thermometer  (Read 11655 times)

seldenr

  • Newbie
  • *
  • Posts: 6
DigiSpark as a thermometer
« on: January 03, 2014, 05:25:42 pm »
Hi Everybody,
I was wondering if there is any way to turn the DigiSpark into a thermometer. I'm new to this. Could the temperature reading display on the screen of the programming computer or would the digispark need its own little display? I have heard about a built-in temperature sensor included in the chip on the digispark, but if this isn't true, I would use the DS18B20 -One Wire Temperature Sensor sold by digistump.
Thanks for your input.
seldenr

MichaelMeissner

  • Full Member
  • ***
  • Posts: 166
Re: DigiSpark as a thermometer
« Reply #1 on: January 03, 2014, 07:59:00 pm »
Those are within the scope of digispark.  I would suggest getting a secondary screen, such as the 16x2 i2c character screen that digistump sells.  That way you can move your system to a different location, and just provide power.

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: DigiSpark as a thermometer
« Reply #2 on: January 03, 2014, 08:46:18 pm »
The ATTiny85 does have an internal temperature sensor. You can find some sample code for reading it and displaying on an LCD display here:

http://digistump.com/board/index.php/topic,893.0.html

Note that since this is sensor internal to the MCU, it will probably not be terribly accurate, and will likely rise the longer it runs, as the chip heats up. But it's still neat to experiment with, just because. :)

seldenr

  • Newbie
  • *
  • Posts: 6
Re: DigiSpark as a thermometer
« Reply #3 on: January 03, 2014, 10:16:42 pm »
The ATTiny85 does have an internal temperature sensor. You can find some sample code for reading it and displaying on an LCD display here:

http://digistump.com/board/index.php/topic,893.0.html

Note that since this is sensor internal to the MCU, it will probably not be terribly accurate, and will likely rise the longer it runs, as the chip heats up. But it's still neat to experiment with, just because. :)

I like the look of that code. Only thing is that I actually wanted to display it on the computer screen and just have a little thermometer to plug into my computer. I'm not too familiar with how Arduino works in terms of displaying on the computer; Is there any way to just "print" the temperature directly in the IDE on the computer? I'm using the Digistump IDE on a MacBook Pro.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: DigiSpark as a thermometer
« Reply #4 on: January 03, 2014, 10:39:57 pm »
combine the temperature code and the DigiUSB example and then use the DigiUSB Programs to receive the text

seldenr

  • Newbie
  • *
  • Posts: 6
Re: DigiSpark as a thermometer
« Reply #5 on: January 03, 2014, 10:49:22 pm »
combine the temperature code and the DigiUSB example and then use the DigiUSB Programs to receive the text

Ooh, that's cool. I didn't even realize that was there. Only problem is that when I run the monitor app in the python folder, nothing happens. I have gatekeeper set to apps from anywhere. Do I need the digispark plugged in before I run the monitor app? Also, what line of the code that dougal linked to above sends the temperature reading back to the monitor. All I can see is that it prints it on the LCD. Is it the line "   return in_c;" that the monitor will display? Or do I need to add some code for the monitor app to recognize?
« Last Edit: January 03, 2014, 11:12:54 pm by seldenr »

dougal

  • Sr. Member
  • ****
  • Posts: 289
Re: DigiSpark as a thermometer
« Reply #6 on: January 06, 2014, 02:53:46 pm »
You have to replace all the LCD library calls with USB library calls. Here's a quick, crude, untested try:

Code: [Select]
#include <TinyWireM.h>
#include <DigiUSB.h>

void setup(){
  TinyWireM.begin();
  DigiUSB.begin();
  analogReference(INTERNAL1V1);
}

int get_temp() {
   int raw = analogRead(A0+15);
   //raw -= 13; // raw adjust = kelvin
   int in_c = raw - 273; // celcius
   return in_c;
}

void loop(){
  DigiUSB.refresh();
  int temp = get_temp();
  DigiUSB.send(temp); // send the temperature value back to the PC over USB
  DigiUSB.delay(1000); // one second delay
}

You should be able to receive the results using the "receive" or "monitor" program on your PC. And yes, you should plug in the DigiSpark first.

This example will just send the raw temperature value, once per second, with no formatting. And I didn't double-check to see if it needs to be converted to a string value first...

seldenr

  • Newbie
  • *
  • Posts: 6
Re: DigiSpark as a thermometer
« Reply #7 on: January 06, 2014, 06:51:29 pm »
You have to replace all the LCD library calls with USB library calls. Here's a quick, crude, untested try:

Code: [Select]
#include <TinyWireM.h>
#include <DigiUSB.h>

void setup(){
  TinyWireM.begin();
  DigiUSB.begin();
  analogReference(INTERNAL1V1);
}

int get_temp() {
   int raw = analogRead(A0+15);
   //raw -= 13; // raw adjust = kelvin
   int in_c = raw - 273; // celcius
   return in_c;
}

void loop(){
  DigiUSB.refresh();
  int temp = get_temp();
  DigiUSB.send(temp); // send the temperature value back to the PC over USB
  DigiUSB.delay(1000); // one second delay
}

You should be able to receive the results using the "receive" or "monitor" program on your PC. And yes, you should plug in the DigiSpark first.

This example will just send the raw temperature value, once per second, with no formatting. And I didn't double-check to see if it needs to be converted to a string value first...

Thank You SOO Much! That makes perfect sense. That's exactly what I needed.