Ds18b20 temp sensor and dim leds

Hello, i’m working on a simple project, i’m just a beginner with arduino.
I have 2x Ds18b20 temp sensor on 1 wire mode linked on digital pin 3. My code is reading the 2 temperatures, and while their sum is higher than a certain value, i’m lighting a led with a simple IF construct. Everything works fine, but the problem is the light of the led is very dim, while when i previously tried simple codes to light up leds it was MUCH brighter.

the temp sensor are linked like this:

while i have the led connected in digital pin n.4 with the anode, and to the ground with a 220ohm res with the cathode. I also tried to remove the resistance to have more current on the led, but the light was the same.
Also i tried different leds, same as before.
Any advice? thanks in advance

edit: i tried the example for the blinking led in the same config, just removing the 2 sensor, and the light was much brighter. Is it possible that both sensor are using too much power?

the code i’m using is the following

// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// Tutorial:

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x78, 0xE5, 0x74, 0x05, 0x00, 0x00, 0xBC };
DeviceAddress outsideThermometer = { 0x28, 0x55, 0x73, 0x97, 0x04, 0x00, 0x00, 0x01 };

const float soglia=45.0;

void setup(void)
  // start serial port
  // Start up the library
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  //for(int pin=2;pin<7;pin++){
    //pinMode(pin, OUTPUT);
    //digitalWrite(pin, LOW);
    pinMode(5, OUTPUT);
    digitalWrite(5, LOW);

void printTemperature(DeviceAddress deviceAddress)
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");


void loop(void)
  float t1=sensors.getTempC(insideThermometer);
  float t2=sensors.getTempC(outsideThermometer);
  float somma=t1+t2;
  Serial.print("Getting temperatures...\n\r");
  Serial.print("somma: ");
  Serial.print("Inside temperature is: ");
  Serial.print("Outside temperature is: ");
  if (somma>soglia) {
    digitalWrite(4, HIGH);
    Serial.print("somme>soglia: ");

In a first look your code looks fine.Try to set the LED HIGH permanently in your code and see if removing the sensors makes any difference.Also what arduino did you have?

possible that both sensor are using too much power?

The sensor just need a minimum current, in fact you could use just 2 wires, ground and data, using the parasite mode of it.Unless they have a wiring problem or bad sensor.

In setup() you have:

    pinMode(5, OUTPUT);

but in loop() you have:

    digitalWrite(4, HIGH);

This is why it is useful to define a name for the pin and use that throughout.

#define LED_PIN 4
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, LOW);
    digitalWrite(LED_PIN, HIGH);


Damn thanks Pete that’s solved it :slight_smile: sleep deprivation makes some bad jokes :slight_smile:

In setup() you have:

pinMode(5, OUTPUT);

but in loop() you have:

digitalWrite(4, HIGH);

This is why it is useful to define a name for the pin and use that throughout.

:grin: It escapes me to :blush: