DS18B20 - LCD print ADRESS

Hello

I need to do a project with DS18B20. I need to view the display Adresse sensor.
I have yet only temperature on displey.
How to make a depicted of the sensor, the display?
:confused:

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

// Data wire is plugged into port 8 on the Arduino
#define ONE_WIRE_BUS 8

OneWire  ds(8);

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

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

void setup(void)
{
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
 
  // Print a message to the LCD.
  lcd.print("DS18B20 adress:");
  
  // Start up the library
  sensors.begin();
}

void getDeviceAddress(void) {
  byte i;
  byte addr[8];

while(ds.search(addr)) {
   lcd.setCursor(0, 1);
 
    for( i = 0; i < 8; i++) {
      lcd.print("0x");
      if (addr[i] < 16) {
        lcd.print('0');
      }
      // print each byte in the address array in hex format
      lcd.print(addr[i], HEX);
      if (i < 7) {
        lcd.print(", ");
      }
    }
    // a check to make sure that what we read is correct.
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        lcd.print("CRC is not valid!\n");
        return;
    }
  }
  ds.reset_search();
  return;
}


void loop(void)
{ 

}
  /*
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  sensors.requestTemperatures(); // Send the command to get temperatures
    // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);


  lcd.print(sensors.getTempFByIndex(0)); 
  lcd.print((char)223);
  lcd.print("F  ");
   
  lcd.print(sensors.getTempCByIndex(0));
  lcd.print((char)223); 
  lcd.print("C");
  
  delay(500);
}
  */

This is my artwork:

#include <OneWire.h>

OneWire ds(10); // This is where DQ of your DS18B20 will connect.

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

void getDeviceAddress(void) {
byte i;
byte addr[8];

Serial.println(“Getting the address…\n\r”);
/* initiate a search for the OneWire object we created and read its value into
addr array we declared above*/

while(ds.search(addr)) {
Serial.print(“The address is:\t”);
//read each byte in the address array
for( i = 0; i < 8; i++) {
Serial.print(“0x”);
if (addr < 16) {

  • Serial.print(‘0’);*
  • }*
  • // print each byte in the address array in hex format*
    _ Serial.print(addr*, HEX);_
    _
    if (i < 7) {_
    _
    Serial.print(", ");_
    _
    }_
    _
    }_
    _
    // a check to make sure that what we read is correct._
    _
    if ( OneWire::crc8( addr, 7) != addr[7]) {_
    _
    Serial.print(“CRC is not valid!\n”);_
    _
    return;_
    _
    }_
    _
    }_
    ds.reset_search();
    _
    return;_
    _
    }_
    void loop(void) {
    _
    // do nothing*_
    }

How to write the address to fit on one line?

[quote author=Kaniiisek link=msg=2990458 ] I need to view the display Adresse sensor. [/quote]

Why? I bet nobody else does.

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

#include <Wire.h> // This library is already built in to the Arduino IDE
#include <LiquidCrystal_I2C.h> //This library you can add via Include Library > Manage Library >
LiquidCrystal_I2C lcd(0x27, 16,2);

//uint8_t insideThermometer;
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
float tempC;
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

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

// arrays to hold device address
DeviceAddress insideThermometer;

/*

  • Setup function. Here we do the basics
    */
    void setup(void)
    {
    // start serial port
    Serial.begin(9600);
    Serial.println(“Dallas Temperature IC Control Library Demo”);
    lcd. begin(); // initializing the LCD
    lcd.backlight(); // Enable or Turn On the backlight
    // locate devices on the bus
    Serial.print(“Locating devices…”);
    sensors.begin();
    Serial.print(“Found “);
    Serial.print(sensors.getDeviceCount(), DEC);
    Serial.println(” devices.”);

// report parasite power requirements
Serial.print("Parasite power is: ");
if (sensors.isParasitePowerMode()) Serial.println(“ON”);
else Serial.println(“OFF”);

// Assign address manually. The addresses below will beed to be changed
// to valid device addresses on your bus. Device address can be retrieved
// by using either oneWire.search(deviceAddress) or individually via
// sensors.getAddress(deviceAddress, index)
// Note that you will need to use your specific address here
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };

// Method 1:
// Search for devices on the bus and assign based on an index. Ideally,
// you would do this to initially discover addresses on the bus and then
// use those addresses and manually assign them (see above) once you know
// the devices on your bus (and assuming they don’t change).
if (!sensors.getAddress(insideThermometer, 0)) Serial.println(“Unable to find address for Device 0”);

// method 2: search()
// search() looks for the next device. Returns 1 if a new address has been
// returned. A zero might mean that the bus is shorted, there are no devices,
// or you have already retrieved all of them. It might be a good idea to
// check the CRC to make sure you didn’t get garbage. The order is
// deterministic. You will always get the same devices in the same order
//
// Must be called before search()
//oneWire.reset_search();
// assigns the first address found to insideThermometer
//if (!oneWire.search(insideThermometer)) Serial.println(“Unable to find address for insideThermometer”);

// show the addresses we found on the bus
Serial.print("Device 0 Address: ");
printAddress(insideThermometer);
Serial.println();

// set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
sensors.setResolution(insideThermometer, 9);

Serial.print("Device 0 Resolution: ");
Serial.print(sensors.getResolution(insideThermometer), DEC);
Serial.println();
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
// method 1 - slower
//Serial.print("Temp C: “);
//Serial.print(sensors.getTempC(deviceAddress));
//Serial.print(” Temp F: ");
//Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

// method 2 - faster
float tempC = sensors.getTempC(deviceAddress);
Serial.print("Temp C: “);
Serial.print(tempC);
Serial.print(” Temp F: ");
Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit

lcd.setCursor(0, 1);
lcd.print(“C:”); // Start Print Test to Line 2
lcd.print (tempC);

lcd.setCursor(8,1);
lcd.print(“F:”);
lcd.print (DallasTemperature::toFahrenheit(tempC));

}
/*

  • Main function. It will request the tempC from the sensors and display on Serial.
    */
    void loop(void)
    {
    // call sensors.requestTemperatures() to issue a global temperature
    // request to all devices on the bus
    Serial.print(“Requesting temperatures…”);
    sensors.requestTemperatures(); // Send the command to get temperatures
    Serial.println(“DONE”);

// It responds almost immediately. Let’s print out the data
printTemperature(insideThermometer); // Use a simple function to print out the data
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
lcd.setCursor(0, 0);

for (uint8_t i = 0; i < 8; i++)
{
if (deviceAddress < 16)

  • {*
  • Serial.print(“0”);*
  • lcd.print(“0”);*
    _ Serial.print(deviceAddress*, HEX);_
    _lcd.print(deviceAddress, HEX);
    lcd.setCursor((i+1)*2, 0);
    }
    else
    {
    Serial.print(deviceAddress, HEX);_

    _lcd.print(deviceAddress, HEX);
    lcd.setCursor((i+1)2, 0);
    }

    * }
    //28FFD5AA73160504*

    // Start Print Test to Line 2_

//}
* delay (1000);*
}

In the OP you used code tags; in #1 not. Bad idea, the code gets mangled and I don't know which of the two is the correct.

Then your question:

Kaniiisek: I need to do a project with DS18B20. I need to view the display Adresse sensor. I have yet only temperature on displey. How to make a depicted of the sensor, the display?

I also really don't understand what you're trying to do. The address of the sensor? That's a many(40?)-bit number, usually as hex number. Not meant for use by humans so quite meaningless and impossible to remember.

Dunno but .....Maybe he just wants to print “ sensor 1: 30.5C” ?? . Personally I’d just want to name them “ kitchen : 20C” or whatever ??

In which case on of the library examples might help in how you identify a particular sensor??

Can the OP clarify ?

hammy: Can the OP clarify ?

Probably not. I believe he disappeared a couple of years ago and, with a bit of luck realised his "need" was as pointless as wvmarle says, even before I wrote reply #2.

Huh... Love those resurrected threads...

Ha ha ... been working off my phone and hadn’t noticed the dates . Ho hum etc