Welcome to the forum…Thanks 
Why do you have the pull-down from the IO pin (4)? The circuitry on page 31 of the datasheet doesn’t have such a pull-down.
No that is correct it doesn’t. My diagram is also wrong, see updated one. The 4k7 resistor is connected to +5v and IO (4). Without the resistor the sketch returns:- “No more addresses”.
EDIT I don’t seem to be able to attach an updated schematic drawing **
That example connects the IO pin to D10 of the Arduino. If you modified it, post your actual test code!
#include <OneWire.h>
/*
* DS2408 8-Channel Addressable Switch
*
* Writte by Glenn Trewitt, glenn at trewitt dot org
*
* Some notes about the DS2408:
* - Unlike most input/output ports, the DS2408 doesn't have mode bits to
* set whether the pins are input or output. If you issue a read command,
* they're inputs. If you write to them, they're outputs.
* - For reading from a switch, you should use 10K pull-up resisters.
*/
OneWire net(2); // on pin 2
void PrintBytes(const uint8_t* addr, uint8_t count, bool newline=false) {
for (uint8_t i = 0; i < count; i++) {
Serial.print(addr[i]>>4, HEX);
Serial.print(addr[i]&0x0f, HEX);
}
if (newline)
Serial.println();
}
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
byte addr[8];
if (!net.search(addr)) {
Serial.print("No more addresses.\n");
net.reset_search();
delay(1000);
return;
}
if (OneWire::crc8(addr, 7) != addr[7]) {
Serial.print("CRC is not valid!\n");
return;
}
if (addr[0] != 0x29) {
PrintBytes(addr, 8);
Serial.print(" is not a DS2408.\n");
return;
}
Serial.print(" Reading DS2408 ");
PrintBytes(addr, 8);
Serial.println();
uint8_t buf[13]; // Put everything in the buffer so we can compute CRC easily.
buf[0] = 0xF0; // Read PIO Registers
buf[1] = 0x88; // LSB address
buf[2] = 0x00; // MSB address
net.write_bytes(buf, 3);
net.read_bytes(buf+3, 10); // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16
net.reset();
if (!OneWire::check_crc16(buf, 11, &buf[11])) {
Serial.print("CRC failure in DS2408 at ");
PrintBytes(addr, 8, true);
return;
}
Serial.print(" DS2408 data = ");
// First 3 bytes contain command, register address.
Serial.println(buf[3], BIN);
}
Serial monitor result, with 4k7 resistor, then with resistor removed:-
813BE3D422001C5 is not a DS2408.
Reading DS2408 29D98D05000000D7
DS2408 data = 11100
No more addresses.
2813BE3D422001C5 is not a DS2408.
Reading DS2408 29D98D05000000D7
DS2408 data = 11101
No more addresses.
2813BE3D422001C5 is not a DS2408.
Reading DS2408 29D98D05000000D7
DS2408 data = 11101
No more addresses.
2813BE3D422001C5 is not a DS2408.
Reading DS2408 29D98D05000000D7
DS2408 data = 11111
No more addresses.
2813BE3D422001C5 is not a DS2408.
Reading DS2408 29D98D05000000D7
DS2408 data = 11111
No more addresses.
2813BE3D422001C5 is not a DS2408.
Reading DS2408 29D98D05000000D7
DS2408 data = 11111
No more addresses.
No more addresses.
No more addresses.
No more addresses.
No more addresses.
This would imply that I need the pullup resistor for the onewire devices to be found.
Again, you test code using the wrong hardware. Very strange.
Extract from Tester sketch found in Dallas Temperature example folder:-
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9 // Lower resolution
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
I used this to to find the address of my DS2408 devices and prove (to me) that they might work.
So reading the notes: -
* Some notes about the DS2408:
* - Unlike most input/output ports, the DS2408 doesn't have mode bits to
* set whether the pins are input or output. If you issue a read command,
* they're inputs. If you write to them, they're outputs.
* - For reading from a switch, you should use 10K pull-up resisters.
Do I actually need the 10k pullup as shown in data sheet or not, bearing in mind I want to switch the IO pins “on” or “off”.
Many thanks for your time, I really do appreciate any help.
I’m starting to go bald and that’s not a good look for me!