Hello,
I have a problem wanting to retrieve the address of a DS18B20 temperature sensor and then use this address to retrieve the temperature …
I tested the assembly on an arduino nano, everything works (assembly and program) but when I test it on a Seeeduino Xiao and nothing else … (data pin of the DS18B20 on pin n ° 2 of the XIAO)
//*************************************************************
//**********Get address
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// variable to hold device addresses
DeviceAddress Thermometer;
int deviceCount = 0;
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// locate devices on the bus
Serial.println("Locating devices...");
Serial.print("Found ");
deviceCount = sensors.getDeviceCount();
Serial.print(deviceCount, DEC);
Serial.println(" devices.");
Serial.println("");
Serial.println("Printing addresses...");
for (int i = 0; i < deviceCount; i++)
{
Serial.print("Sensor ");
Serial.print(i+1);
Serial.print(" : ");
sensors.getAddress(Thermometer, i);
printAddress(Thermometer);
}
}
void loop(void)
{}
void printAddress(DeviceAddress deviceAddress)
{
for (uint8_t i = 0; i < 8; i++)
{
Serial.print("0x");
if (deviceAddress[i] < 0x10) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
if (i < 7) Serial.print(", ");
}
Serial.println("");
}
//*************************************************************
So I started to search the internet and found this very informative message:https://forum.seeedstudio.com/t/xiao-problems-with-wire-library/253101 and in particular this explanation: https://wiki.seeedstudio.com/Arduino_Software_I2C_user_guide/#i2c-scanner-for-arduino
But alas even when loading the SoftwareI2C library there is a bizard behavior: in the serial console I find:
- when no DS18B20 is connected - or - when a DS18B20 is connected on pin 1, or 2, or 3, or 4, or 5 …:
—I2C Scanner—
Scanning…
I2C device found at address 0x01!
done
== >> ** How do I query my DS18B20 using their addresses? **
(addresse ie: { 0x28, 0xEE, 0xD5, 0x64, 0x1A, 0x16, 0x02, 0xEC })
please! please! please! shall you help me???