i do some project. There is DS18B20, 3 mosfet modules, 1 relay, display 1602, buzzer... I built it on bread board, everything worked. Now i soldered it: arduino works, display works but DS18B20 doesn't return temperature.

I tried to solder thermometer over again - no result. Then i glanced at my sketch and tried to remove some code in loop and setup. I understood that DS18B20 works only if in setup function no pinMode(...) for other modules. It's odd!

This is part of my code:

#include <EncButton.h>     // For buttons
#include <microDS18B20.h>  // For thermometer DS18b20
#include <EEPROM.h>        // For EEPROM memory to save settings
#include <ezBuzzer.h>      // For buzzer
#include "Screen.h"

/* --- PINS --- */
#define kettle_relay_pin 4     // Relay of kettle
#define mixer_pin 5            // Mixer pin
#define termometer_pin A2      // Termometer pin
#define hot_pump_pin A0        // Hot water
#define sugar_dispenser_pin A1 // Sugar dispenser
#define buzzer_pin 9           // Buzzer pin

#define l_button_pin 11      // Left button
#define r_button_pin 12      // Right button
#define potent_pin A3        // Potentiometer pin for set int values
/* --- PINS --- */

#define INIT_ADDR 1023  // EEPROM addres for init key
#define INIT_KEY 1      // EEPROM init key

/* --- Initialize objects --- */
// Connect thermometer DS18b20
MicroDS18B20<termometer_pin> ds; 

ezBuzzer buzzer(buzzer_pin); // create ezBuzzer object that attach to a pin;

// Buttons
EncButton<EB_TICK, l_button_pin> l_button; 
EncButton<EB_TICK, r_button_pin> r_button; 

// LCD Display
#define _LCD_TYPE 1
#include <LCD_1602_RUS_ALL.h>
LCD_1602_RUS lcd(0x27, 16, 2);
Screen screen(&lcd); // Create screen object instance for convient work with lcd display
/* --- Initialize objects --- */

/* --- Initial values --- */
enum modes {
  // ...
modes currentMode = normalMode;

// Default settings
struct Settings{
} settings;

// Current values
int current_temp = 25; // Current temperature
// ...
/* --- Initial values --- */

void setup()

    // Buttons and potentiometer
    pinMode(potent_pin, INPUT);

    // Kettle
    pinMode(kettle_relay_pin, OUTPUT);
    digitalWrite(kettle_relay_pin, LOW);
    // Pump
    pinMode(hot_pump_pin, OUTPUT);
    digitalWrite(hot_pump_pin, LOW);

    // Mixer
    pinMode(mixer_pin, OUTPUT);
    digitalWrite(mixer_pin, LOW);

    // Sugar dispenser motor
    pinMode(sugar_dispenser_pin, OUTPUT);
    digitalWrite(sugar_dispenser_pin, LOW);

    // Buzzer
    pinMode(buzzer_pin, OUTPUT);

    // Init EEPROM
    if (EEPROM.read(INIT_ADDR) != INIT_KEY) {
        // EEPROM haven't been initialized yet
        EEPROM.write(INIT_ADDR, INIT_KEY); // Write init key
        EEPROM.put(0, settings); // Set default data

    // Read settings and apply it
    EEPROM.get(0, settings);
    tea_temp = settings.tea_temp_default;       
    sugar_count = settings.sugar_count_default; 
    settings.mixer_time = 15 * 1000;

    // Init display

unsigned long screenUpdateTimer = 0;

void loop() {

  creen.render(); // Always render information on display

  Serial.println(ds.online()); // TRUE

  // For ds18b20 tests
  if (ds.readTemp()) Serial.println(ds.getTemp());
  else Serial.println("error");

What's problem?

If i comment all pinMode and digitalWrite code, ds.readTemp works, else it's error.

UPDATE #1 I figured out that if i use ports A0 and A1, i get message "error" for this sketch:

#include <microDS18B20.h>
MicroDS18B20<A2> sensor;
void setup() {
void loop() {
  if (sensor.readTemp()) Serial.println(sensor.getTemp());
  else Serial.println("error");

And more. I get this message "error" every time without any connected modules. After some connects and disconnects of mosfet module to pins A0, A1, D5, D6. No temperature at all! enter image description here enter image description here enter image description here

Update #2 I think it's died.

My main sketch (it worked yesterday) now doesn't work at all. But then i try some reboots and it works but not properly... So, if it works, i can see my menu on display but it's ierogliphs sometimes. also sometimes buttons stop to work...

Is aruino dead? enter image description here

  • 1
    This doesn't really match your problem description, but it is a problem, I think. LCD_1602_RUS lcd(0x27, 16, 2); 16 is another name for A2 on the atmega328p/atmega168p Nano. Half expect you just typo'd it. Maybe you wired to 6? No diagram so, no way to know.
    – timemage
    Sep 20, 2022 at 18:30
  • No, 1602 must be connected to A4, A5. And it worked for bread board
    – Влад
    Sep 20, 2022 at 18:46
  • Now i figured out one more thing. If i connect mosfet module to A0 or to A1 pin, DS18B20 show error... IDK how it works...
    – Влад
    Sep 20, 2022 at 18:48
  • i tried disconnect 1602 as well, no result
    – Влад
    Sep 20, 2022 at 18:50
  • Include all this stuff you're figuring out in your question. Add a diagram. Remove any unnecessary stuff. If you can create the same problem without a 1602 display involved, remove it it from both your test setup and the question.
    – timemage
    Sep 20, 2022 at 18:54


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.