I want to communicate with an RS485 Bus consisting of 5 Arduino Pro Minis as slaves and one Arduino Mega 2560 as Master. I found a great library for this.
According to the documentation provided by the author of library I can use:
ICSC icsc(1, 9600, 7); //ID, BaudRate, DEpin
But I also have to define a Serial port for ICSC to work with:
ICSC icsc(1, 9600, Serial1);
I cannot mix these two sentences. I mean I cannot define both DEpin and Serial port for the ICSC in one sentence. But I need it to be defined. I don't want to use Serial for that, which I need for Serial Monitor. I want to use Serial1 for this. What can I do? I couldn't find any updated documentation about this.
UPDATE:
I found out how to define Serial port and DEpin for ICSC. The problem is I cannot get an answer!
Here is Master code:
#include <ICSC.h>
ICSC icsc(Serial1, 1, 7); //Stream, ID, DEpin
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
icsc.begin();
icsc.registerCommand('R', &showTemperature);
}
void loop() {
icsc.send(2, 'T', 0, NULL);
icsc.process();
}
void showTemperature() {
Serial.println("ACK");
}
And here is the Slave code:
#include <ICSC.h>
ICSC icsc(Serial, 2, 7); //Stream, ID, DEpin
String strAck = "ProMini2:ACK";
void setup() {
Serial.begin(9600);
icsc.begin();
icsc.registerCommand('T', &sendTemperature);
}
void loop() {
icsc.process();
}
void sendTemperature() {
icsc.send(1, 'R', sizeof(strAck) + 1, (char*)&strAck);
}
Assume that there is just one slave and one master. I tried this code but got no answer. Where is the error?
char *. – Majenko Dec 15 '17 at 09:08