Page 1 of 1

episode #12 Building a Home automation controller sketch

Posted: Tue Oct 13, 2015 8:07 pm
by Fred57
I have a couple of ether ten R3 boards but they don't have the MAC address chip on them and I am having trouble getting the sketch to work by applying a MAC address manually. Does someone have a version of the sketch configured for manual MAC address that works that i can copy and run.

Thanks

Re: episode #12 Building a Home automation controller sketch

Posted: Sun Apr 17, 2016 5:56 pm
by bigd003
I got this from superhouse.tv I think. It came from a link by Jon Oxer somewhere...


/*
* Retrieve the MAC address from a Microchip 24AA125E48 I2C ROM, and report it
* to the serial console at 57600bps. The I2C address of the ROM is set to 0x50,
* which assumes both the address pins are tied to 0V.
*/

#define I2C_ADDRESS 0x50
#include <Wire.h>

static uint8_t mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

void setup()
{
Wire.begin(); // Join i2c bus (I2C address is optional for the master)
Serial.begin(57600);
for(int i = 0; i < 30; i++)
{
Serial.println(" ");
}
Serial.println("Starting test for MAC address ROM");
Serial.print("Getting MAC: ");

mac[0] = readRegister(0xFA);
mac[1] = readRegister(0xFB);
mac[2] = readRegister(0xFC);
mac[3] = readRegister(0xFD);
mac[4] = readRegister(0xFE);
mac[5] = readRegister(0xFF);

char tmpBuf[17];
sprintf(tmpBuf, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
Serial.println(tmpBuf);
Serial.println(" TEST OK");
}

void loop()
{
// Do nothing
}

byte readRegister(byte r)
{
unsigned char v;
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(r); // Register to read
Wire.endTransmission();

Wire.requestFrom(I2C_ADDRESS, 1); // Read a byte
while(!Wire.available())
{
// Wait
}
v = Wire.read();
return v;
}

Re: episode #12 Building a Home automation controller sketch

Posted: Tue May 03, 2016 6:12 am
by angusgr
Hi Darren,

If you don't have the MAC chip then you can just leave all this code out. Your code will still work, only you can't preset the MAC address to a known value.

Angus