Ds18b20 z Ali.....

dobo
Posts: 1051
Joined: Sun Apr 07, 2019 8:14 pm
Location: Nadarzyn

Post

Ja testowałem na Arduino Nano

Code: Select all

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

const int oneWireBus = 3;

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

void setup() {
  Serial.begin(9600);
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();

  DeviceAddress sensorAddress;
  sensors.getAddress(sensorAddress, 0);

  // Wyświetl numer seryjny przed sprawdzeniem warunku
  Serial.print("Numer seryjny: ");
  for (int i = 0; i < 8; i++) {
    Serial.print(sensorAddress[i], HEX);
    Serial.print(" ");
  }
  Serial.println();

  // Odczytaj i wyświetl temperaturę
  float temperature = sensors.getTempCByIndex(0);
  Serial.print("Temperatura: ");
  Serial.println(temperature);

  // Sprawdź warunek poprawności fragmentu identyfikatora (ROM)
  if (!sensorAddress[5] && !sensorAddress[6]) {
    Serial.println(F("SN ROM OK"));
  } else {
    Serial.println(F("SN ROM ERROR"));
    // Tutaj możesz podjąć odpowiednie działania w przypadku błędu, na przykład oznaczyć czujnik jako fałszywy
  }

  delay(1000);
}

Możesz też sprawdzić w GG trzeba podać minimum 2 DSy bo wtedy wyświetla adresy.

.
DS18B20 - Podróba-Oryginał.png
You do not have the required permissions to view the files attached to this post.
zzrr
Posts: 1864
Joined: Wed Oct 26, 2022 7:35 pm
Has thanked: 76 times
Been thanked: 119 times

Post

mar11111 wrote: Tue Jan 23, 2024 8:34 pm A gdzie taki soft dostanę? :D może sobie sprawdzę w wolnym czasie
jak byś się lepiej postarał to już byś miał :) ;)
Żartuję oczywiście. @dobo widzę soft podał. W razie jak będziesz potrzebował bina to napisz. Tylko podaj w razie czego na jaki moduł.
mar11111
Posts: 117
Joined: Sun Jul 16, 2023 4:06 pm

Post

Ooo widzę że oryginałem to ja nie grzeszę :lol:
You do not have the required permissions to view the files attached to this post.

Return to “Pomoc”