0

I'm actually trying to connect a DS18B20 sensor to a homemade board build with a ATmega328P processor running with a power of 3.3V and at 8 Mhz.

In order to get the address I wired the board as the following schematic on the pin 5 of my board. wire diagram (edited)

To power the sensor and the pull up resistor I use the VDD output of my board which provides 3.3V.

For the code part I uploaded this:

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial: 
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
#include <OneWire.h>
OneWire ds(5); // Connect your 1-wire device to pin 5
void setup(void) {
 Serial.begin(9600);
 discoverOneWireDevices();
}
void discoverOneWireDevices(void) {
 byte i;
 byte present = 0;
 byte data[12];
 byte addr[8];
 Serial.print("Looking for 1-Wire devices...\n\r");
 while(ds.search(addr)) {
 Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
 for( i = 0; i < 8; i++) {
 Serial.print("0x");
 if (addr[i] < 16) {
 Serial.print('0');
 }
 Serial.print(addr[i], HEX);
 if (i < 7) {
 Serial.print(", ");
 }
 }
 if ( OneWire::crc8( addr, 7) != addr[7]) {
 Serial.print("CRC is not valid!\n");
 return;
 }
 }
 Serial.print("\n\r\n\rThat's it.\r\n");
 ds.reset_search();
 return;
}
void loop(void) {
 // nothing to see here
}

When I make it run on an Arduino Uno card I can get the address of the sensor but when I make it run on my card I only obtain this:

Looking for 1-Wire devices...

That's it.

Anyone got a idea why it's working on an Arduino Uno but not on my card?

hardware schematic

asked Apr 30, 2019 at 9:07
7
  • On schematic two pins are connected, in question description and code, there's only one pin. Commented Apr 30, 2019 at 10:45
  • Is that a mosfet? Is it used to shortcut the data to 3.3v? why? Commented Apr 30, 2019 at 12:33
  • Sorry @domen i had put the wrong diagram in my post, i edited my post Commented Apr 30, 2019 at 14:36
  • You're saying it's same chip (and similar surrounding hardware) and same software? Is there a schematic for your own hardware, because you've probably made some mistake there. Include the details of all differences to working setup. Commented Apr 30, 2019 at 15:19
  • @domen i added in the post a hardware shematic around the chip , we use the PD5 (D5 ) Commented May 2, 2019 at 7:09

1 Answer 1

1

I finally made it work, thx @domen.

I looked at the other part of the schematic and found I was using the wrong pin - I have two LDO and the one I was using was deactivated for sensor.

Thanks all for your help.

Greenonline
3,1527 gold badges36 silver badges48 bronze badges
answered May 7, 2019 at 7:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.