So simply, I'm reading the registers of a 32-input(digital) Modbus module, for the off/on state.
As shown in my code, I am receiving the 0s and 1s from the module, and needing to create a List that will be displayed on the largest small display screen I can get for Arduino, and may be emailed using an ESP8266. (without cloud data storage)
When an input goes on(1) it needs to be added to the Display List, and going off(0) the item will be removed from the Display List. These are not rapid on/off changes, usually 2-15 minutes duration each.
(The below array would not display within the code tags)
const char* arInput[]={"Bin 1", "Bin 2", "Bin 3", "Bin 4", "Bin 5", "Bin 6", "Bin 7", "Bin 8", "Bin 9", "Bin 10", "Bin 11", "Bin 12", "Bin 13", "Bin 14", "Bin 15", "Bin 16", "Bin 17",Bin 18", "Bin 19", "Bin 20", "Bin 21", "Bin 22", "Bin 23", "Bin 24", "Bin 25", "Bin 26", "Bin 27", "Bin 28", "Bin 29", "Bin 30", "Bin 31", "Bin 32"};
String onList[10];
void loop()
{
uint8_t result;
uint8_t j;
uint16_t data[32];
for (int s = 1; s < 2; ++s) // Modbus Slave selector starting at 1
{
node.begin(s, mySerial); //slaveID s
delay(100);
result = node.readHoldingRegisters(128, 32); // Read 32 registers starting at 0x0080(128)
if (result == node.ku8MBSuccess)
{
for (int i = 0; i < 32; ++i)
{
if (node.getResponseBuffer(i)== 0)// -----------If Input Off ------------
{
// Compare to onList items & delete if found ?
Serial.print("Input ");
Serial.print(i);
Serial.println(" off");
/* //not working
if (onList[i] = arInput[i]){
onList[i] != arInput[i];
Serial.print("onList updated");
delay(100);
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.print("Polling Inputs");
}
*/
//Serial.println(onInt);
// lcd.setCursor(0, 1);
//lcd.print(" ");
//lcd.print("Polling Inputs");
} else // ------------- Input is ON ------------
{
// Compare to onList, add to onList if not already --- Use a Function -----
// Serial.print (arInput[i]); // Lookup bin/Input name & display, could be a function to lookup in data file, etc.
lcd.setCursor(0, 1);
Serial.print(arInput[i]);
onList[i] = arInput[i];
Serial.println(" is ON, ");
Serial.print("onList entry: "); //(onInt);
Serial.println(onList[i]);
lcd.print("Now ON: ");
lcd.print(onList[i]);
}
}
delay(1000);
}
}
}
My onList really needs to be in an array or table or editable text file so it can be used for multiple purposes, like sending an email list and displaying.