Temp sensor DS18B20 shows -127

I have wired up an ATTiny85 Digispark board with two temp sensors and an OLED display. I’ve tried to do it by the book and both sensors show -127 which could mean different things I suppose other than it is something wrong. I’ve seen sites showing wiring which is propably wrong for OneWire but I can’t be sure, this one Wiring The DS18B20 1-Wire Temperature Sensor | 14core.com shows a connection of 5V to Vdd on the sensors.

#include <Arduino.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <SSD1306xLED.h>
#include <font6x8.h>
#include <font8x16.h>

#define ONEWIRE_BUS 4

float leftC, rightC;      // Temperature in Celsius
char tArr[4];

DeviceAddress MagLeft =  {0x28, 0x4E, 0xB0, 0x75, 0xD0, 0x01, 0x3C, 0xDE};
DeviceAddress MagRight = {0x28, 0x9E, 0x9D, 0x75, 0xD0, 0x01, 0x3C, 0x0E};

OneWire oneWire(ONEWIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup()
    sensors.setResolution(MagLeft, 9);
    sensors.setResolution(MagRight, 9);

void loop()
    leftC = int(sensors.getTempC(MagLeft));
    rightC = int(sensors.getTempC(MagRight));
    SSD1306.ssd1306_setpos(0, 1);
    itoa(leftC, tArr, 10); // int > char*
    SSD1306.ssd1306_string_font6x8((char *)"Left mag:  ");

    SSD1306.ssd1306_setpos(0, 3);
    itoa(rightC, tArr, 10); // int > char*
    SSD1306.ssd1306_string_font6x8((char *)"Right mag: ");

    // SSD1306.ssd1306_char_f8x16(0, 4, (char*)"ABCDEFGHI");

Per datasheet there are two modes available for the power supply:

So in your schematic you’re doing the parasitic powersupply design. You can try the other one as well with the VDD pin being connected to 5V instead.


I rewired it like you suggested which I have tried before and now the display shows 25 for both sensors and it never changes. I was wondering if I have made a mistake converting the values. I also measured the voltage out from the Digistump and it shows 4.45V which is lower than I expected.


Well 25 loks better than -127 for both sensors. If the sensors are closeby they may read the same value. Grasping one sensor with your fingers to warm it up doesn’t change the temp?

Can you integrate the code at Arduino-Temperature-Control-Library/Tester.ino at master · milesburton/Arduino-Temperature-Control-Library · GitHub to maybe print the number of discovered sensors on the bus, to verify it’s 2?