I used a atmega1284 to create a DS18B20 thermometer. The thermometer is working fine but when the search command(0x0F) is send my familiy code and ROM is totally different as when the match command (0x55) is send. Does someone know what the problem is here?
void loop()
{
ds18b20.scratchpad[2] = 0x96;
ds18b20.scratchpad[3] = 0x81;
// following function must be called periodically
hub.poll();
// this part is just for debugging (USE_mySerial_DEBUG in OneWire.h must be enabled for output)
if (hub.hasError()) hub.printError();
// Blink triggers the state-change
if (blinking())
{
// Set temp
static float temperature = 20.0;
temperature += 0.1;
if (temperature > 30.0) temperature = 20.0;
ds18b20.setTemperature(temperature);
}
}
bool blinking(void)
{
constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds)
static uint32_t nextMillis = millis(); // will store next time LED will updated
if (millis() > nextMillis)
{
nextMillis += interval; // save the next time you blinked the LED
static uint8_t ledState = LOW; // ledState used to set the LED
if (ledState == LOW) ledState = HIGH;
else ledState = LOW;
digitalWrite(pin_led, ledState);
return 1;
}
return 0;
Hi,
I used a atmega1284 to create a DS18B20 thermometer. The thermometer is working fine but when the search command(0x0F) is send my familiy code and ROM is totally different as when the match command (0x55) is send. Does someone know what the problem is here?
I used the example to emulate the DS18B20.
/*
include "OneWireHub.h"
include "DS18B20.h" // Digital Thermometer, 12bit
include
constexpr uint8_t pin_led { 5 }; constexpr uint8_t pin_onewire { 3 };
auto hub = OneWireHub(pin_onewire);
auto ds18b20 = DS18B20(DS18B20::family_code, 0x00, 0x00, 0xB2, 0x18, 0xDA, 0x00); // DS18B20: 9-12bit, -55 - +85 degC //auto ds18s20 = DS18B20(0x10, 0x00, 0x00, 0xA2, 0x18, 0xDA, 0x00); // DS18S20: 9 bit, -55 - +85 degC //auto ds1822 = DS18B20(0x22, 0x00, 0x00, 0x22, 0x18, 0xDA, 0x00); // DS1822: 9-12bit, -55 - +125 degC
bool blinking(void);
SoftwareSerial mySerial(2, 4); // RX, TX
void setup() { mySerial.begin(9600); mySerial.println("OneWire-Hub DS18B20 Temperature-Sensor"); mySerial.flush();
}
void loop() { ds18b20.scratchpad[2] = 0x96; ds18b20.scratchpad[3] = 0x81; // following function must be called periodically hub.poll(); // this part is just for debugging (USE_mySerial_DEBUG in OneWire.h must be enabled for output) if (hub.hasError()) hub.printError();
}
bool blinking(void) { constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds) static uint32_t nextMillis = millis(); // will store next time LED will updated
}