I am building some sensors with Arduinos, which each have a unique integer address from 1-9 (This address is an int variable stored in a struct 'Matrix', the variable name is Matrix.Address). The sensors will all be connected to a PLC via SoftwareSerial (BitBanging) through an RS232 converter. Since all of the Sensors will be connected to the same RX & TX ports on the PLC, I need a way to address each sensor through a unique string.
My plan is the following:
*If the PLC wants a reading from sensor #1, it will send the string: "1,read" All of the sensors should receive this string, but I only want the sensor with address '1' to respond.
*What I am trying to do is come up with a line of code similar to the following:
if (plcCommand == (Matrix.Address + ",read<CR>")) {
mySerial.print(GenerateEquation());
Basically, I need to insert that 'Matrix.Address' variable into a string which will be compared to the incoming string.
It seems like a very simple thing to do, but I am having trouble coming up with a solution.
Any help would be appreciated!