Hi all
I've just got a 1-wire 8-relay switch and I'm just testing it out but I'm not getting any luck. The example I'm using code from Paul Stoffregen as base for my testing. I just want to switch on/off a relay but I'm not even getting connected to the device.
OneWire net(10);
byte addr[8];
BUT
net.search(addr) // returns false
I've got my UNO Pin #10 and GND connected to the 1-wire relay board.
I have not connected the 12V power supply as the guide said it is not needed.
Any ideas why the device won't pick-up?
Here's the setup:
The OneWire bus requires a pull-up resistor. Does the circuit have one?
Do you have a ground wire between the Arduino and the OneWire device? It's called "OneWire" but it requires a common ground.
Make it easy for people who might want to help you (for free):
- Nobody want to visit random dropbox sites. Post your setup picture as described here.
*Post your complete code using Code Tags as described Item #6 of Read this before posting a programming question ...
@Johnwasser
I'm not using a pull-up. That might be it. Let me go see.
@gfvalvo
Thanks for the formatting advice.I was wondering why the image upload only gave me a URL option. Hence the use of dropbox as it wasn't obvious how to manage images. Anyway here's the image.
I'm using a 1-wire Wirecom8 relay control board (sorry, no product serial is on the board)
Also here's the code (copy and paste from original example)
#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(10); // on pin 10
void PrintBytes(const uint8_t* addr, uint8_t count, bool newline=false) {
for (uint8_t i = 0; i < count; i++) {
Serial.print(addr*>>4, HEX);*
_ Serial.print(addr*&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);_
_}_
_
*_
OK, here's the image as I requested it be posted in-line:
Now please re-post the code using Code Tags as requested.
And, how about links to the relay board and 1-wire device?
I also wouldn't attempt to use parasite power mode for the 1-wire bus until you get the hardware and firmware working.