Smart Home Automation Forum
Problem with ds18b20 on Port 1-3 - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A16v3 (https://www.kincony.com/forum/forumdisplay.php?fid=68)
+--- Thread: Problem with ds18b20 on Port 1-3 (/showthread.php?tid=8405)



Problem with ds18b20 on Port 1-3 - ubfox - 08-02-2025

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

#define ONE_WIRE_BUS 21

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress addr;

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("Starte Sensor-Test...");
  delay(500);
  sensors.begin();
  delay(5000);

  int count = sensors.getDeviceCount();
  Serial.printf("Gefundene Sensoren: %d\n", count);

  if (count == 0) {
    Serial.println("Keine Sensoren gefunden.");
    return;
  }

  for (int i = 0; i < count; i++) {
    if (sensors.getAddress(addr, i)) {
      Serial.print("Sensor-Adresse: ");
      for (uint8_t j = 0; j < 8; j++) {
        Serial.printf("%02X", addr[j]);
      }
      Serial.println();
    } else {
      Serial.printf("Sensor %d: Adresse nicht lesbar\n", i);
    }
  }
   
}

void loop() {
  Serial.println("Starte Sensor-Test1...");
  delay(5000);
}

This dos not work - why  

; PlatformIO Project Configuration File
;
;  Build options: build flags, source filter
;  Upload options: custom upload port, speed and extra flags
;  Library options: dependencies, extra library storages
;  Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32-s3-devkitm-1]
platform = espressif32
board = esp32-s3-devkitm-1
framework = arduino
monitor_speed = 115200 
monitor_auto = yes
monitor_rts = 0
monitor_dtr = 0

build_flags =
  -D ARDUINO_USB_MODE=1
  -D ARDUINO_USB_CDC_ON_BOOT=1

   
lib_deps =
  # RECOMMENDED
  # Accept new functionality in a backwards compatible manner and patches
 
  ;pstolarz/OneWireNg @ ^0.13.3
  paulstoffregen/OneWire @ ^2.3.8
  milesburton/DallasTemperature @ ^4.0.4


RE: Problem with ds18b20 on Port 1-3 - admin - 08-03-2025

you can use our arduino demo code for KC868-A16v3: https://www.kincony.com/forum/showthread.php?tid=7539