Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICSC as repeater and Save Address in EEPROM #8

Open
tasosstr opened this issue Aug 5, 2017 · 3 comments
Open

ICSC as repeater and Save Address in EEPROM #8

tasosstr opened this issue Aug 5, 2017 · 3 comments

Comments

@tasosstr
Copy link

tasosstr commented Aug 5, 2017

Hello dear,

I need you're light (if i am in wrong place i apologize).

If i use MAX485 i can have until 32 device's to talk each other,but with you're lovely library we can have much more devices ...
How can i use it as a repeater ( in case if i want to expand it in the middle of loop (with an arduino MEGA ) eg, in address 20 i want to create a new loop and send the address range 33 - 40 ...

And a second question please, how can i address each device and store it to EEPROM and when power up ? with the previous version i have done

LocalID = EEPROM.read(EEPROM_ID_Address);
ICSC.begin(LocalID, 19200, 2);

and was working ok, with new version i can't do this :-(

Thank you in Advance...

Best Regards,
Tasos

@tasosstr
Copy link
Author

tasosstr commented Aug 13, 2017

ok for the address read from the eeprom and change it in setup, i found the solution, for the relay not yet ...

for people has the same issue this is what i did in this beautiful library :-)

in file ICSC.h

public:
	ICSC(Stream *d, uint8_t station) : _dev(d), _station(station), _dePin(255) {}
    ICSC(Stream &d, uint8_t station) : _dev(&d), _station(station), _dePin(255) {}
    ICSC(Stream *d, uint8_t station, int depin) : _dev(d), _station(station), _dePin(depin) {}
    ICSC(Stream &d, uint8_t station, int depin) : _dev(&d), _station(station), _dePin(depin) {}
	
	
    ~ICSC();

    void begin();
	void setAddress(uint8_t address);  // <- Add this

and on file ICSC.cpp

add the follow
void ICSC::setAddress(uint8_t address) {
_station = address;
}

so in the example

ICSC icsc(Serial, 2 ,2); // last argument specifies DE pin on ChainDuino

void pressed(unsigned char src, char command, unsigned char len, char *data)
{
digitalWrite(13, HIGH);
}

void released(unsigned char src, char command, unsigned char len, char *data)
{
digitalWrite(13, LOW);
}

void setup()
{
Serial.begin(115200);
// so here can read the eeprom
// and on next line we can have the eeprom value ;-)
//e.g.
//LocalID = EEPROM.read(EEPROM_ID_Address);
// icsc.setAddress(LocalID);
icsc.setAddress(2); // <- When i change this it does the trick :-)
icsc.begin();
icsc.registerCommand('P', &pressed);
icsc.registerCommand('R', &released);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}

void loop()
{
icsc.process();
}

have fun :-)

@tasosstr
Copy link
Author

icsc.setAddress(2); // <- When i change this it does the trick :-)

this can also use it in void loop() in some case ;-)

@tasosstr
Copy link
Author

I think the #define ICSC_SYS_RELAY 0x09 could be what i looking for repeat the message .. can someone please help me ? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant