Hola quiero montar un indicador de temperatura con el DS18B20 y el TM1637 . El problema que tengo que el cogido esta echo para Arduino Nano y yo lo quiero utilizar en Arduino Uno. Mi duda es sobre los pines que en el Arduino Nano son CLOCK D8 DATA D9 SENSOR PIN 10 yo los puse igual en el Arduino Uno pero el problema que el sensor DS18B20 me marca 0C , me pueden ayudar donde esta el problema les dejo el código .
// TM1637_7_seg_led_display_DS18B20_nnn
//
// Floris Wouterlood
// august 5, 2018
// reports temperature of a DS18B20 probe
// open source - use as you wish
#include <TM1637Display.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define onewirepin 10
OneWire oneWire(onewirepin);
DallasTemperature sensors(&oneWire);
// follows the device address unique for this specimen of DS18B20. You must supply the correct address
DeviceAddress Probe = {0x28, 0xFF, 0x7B, 0x74, 0xA3, 0x15, 0x04, 0x93 };
// if you do not know the device address, use an onewire address finder sketch to determine it.
const int CLK = 9; // set the CLK pin connection to the display
const int DIO = 8; // set the DIO pin connection to the display
int t_ds18b20 = 0; // temperature vraiable
const uint8_t DEGREES[] = {
0x0, 0x0,
SEG_A | SEG_B | SEG_G | SEG_F, // superscript o
SEG_A | SEG_F | SEG_E | SEG_D, // C
};
TM1637Display display(CLK, DIO); // set up the 4-Digit Display.
void setup(){
Serial.begin (9600);
Serial.print ("Initializing Temperature Control Library Version ");
Serial.println (DALLASTEMPLIBVERSION);
sensors.begin (); // initialize the sensor and set resolution level
sensors.setResolution(Probe, 10);
display.setBrightness(0x0a); // set display to maximum brightness
delay(1000);
Serial.println(); // debugging: report DS18B20 data to Serial Monitor
Serial.print ("Number of Devices found on bus = ");
Serial.println (sensors.getDeviceCount());
Serial.print ("Getting temperatures... ");
Serial.println ();
}
void loop()
{
sensors.requestTemperatures(); // command all devices on bus to read temperature
printTemperature(Probe); // call to subroutine
to_the_display(); // call to subroutine
}
// subroutines =======================================================================
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print ("Error getting temperature ");
}
else
{
t_ds18b20=tempC;
Serial.print (tempC);
Serial.println (" *C");
}
}
void to_the_display (){
display.setSegments(DEGREES); //Display the Variable value;
display.showNumberDec(t_ds18b20,false,2,0);
delay (4000);
}