Now I am trying to use the ESP8266 Wifi to send data that will do the same thing. I have the Wifi working on a browser to click on and off the devices and return to the screen that they are on or off. Then I tried to send the data to the Mega. It shows up on the ESP Serial monitor using Arduino IDE 1.8.7 The '1', '2', '3' all show on the serial monitor of the ESP but they do not go to the Mega's switch. So I know the data is there but I don't know how to transfer it to a data that works the same switch.
I have the pin TX 14 and RX 15 on the mega hooked through a HiLetgo 10pcs 4 Channels IIC I2C Logic Level Converter Bi-Directional 3.3V-5V Shifter Module for Arduino, and the TX RX pins on the NodeMcu 12E Tx to RX and RX to TX
I tried Serial.print('1'); (etc) to send data but it does not work to send to the Mega. Unplugged the USB to my computer on the ESP hoping that was the problem. I must not have the data in the correct format for the Mega to use as a 'char'. This works perfectly with the normal serial monitor input on the Mega alone. Changing from just Serial.available as shown below works.
How do I format the "send" data from the ESP to the Mega to work the switch?
Set up fro the serial is: (along with the rest of the programs pinModes that all work find)
Serial.begin(9600);
delay(20);
Serial.println(F("Started..."));
sensors.begin();
Serial3.begin(9600);
delay(20);
pinMode(14, OUTPUT);//serial 3 on Mega
pinMode(15, INPUT);
void (loop)
if(Serial3.available()>0)
//if(Serial.available()>0)
{
Serial.print("We are here");
char ch=Serial3.read();
//char ch=Serial.read();
Serial.print(ch);
switch(ch)
{
case '1': All_Off_Set_Pilot();break;
case 'J': All_Off_Set_Pilot();break;
case '2': LeftValveOpenRightClosed(); break;
case '3': RightValveOpenLeftClosed();break;
case '4': RightValveOpenLeftOPEN();break;
case '5': Pump1LOW_ON(); break;
case '6': Pump1HIGH_ON(); break;
case '7': Pump1_OFF(); break;
case '8': TURBO_ON(); break;
case '9': LIGHT_ON(); break;
case '0': LIGHT_OFF(); break;
case 'a': Pump3LOW_ON(); break;
case 'b': Pump3HIGH_ON(); break;
case 'c': Pump3_OFF(); break;
case 'd': BLOWER_ON(); break;
case 'e': BLOWER_OFF(); break;
case 'f': ONE_DRMV_Slow();break;
case 'g': ONE_DRMV_Medium(); break;
case 'h': ONE_DRMV_FAST(); break;
case 'i': ChainStop();break;
case 'j': checkTempAdjust(); break;
case 'k': TA_ONE_ON(); break;
case 'l': TA_ONE_OFF(); break;
case 'm': TA_TWO_ON(); break;
case 'n': TA_TWO_OFF(); break;
case 'o': TA_THREE_ON(); break;
case 'p': TA_THREE_OFF(); break;
case 'q': TA_FOUR_ON(); break;
case 'r': TA_FOUR_OFF(); break;
case 's': VA_ONE_ON(); break;
case 't': VA_ONE_OFF(); break;
case 'u': VA_TWO_ON(); break;
case 'v': VA_TWO_OFF(); break;
case 'w': VA_THREE_ON(); break;
case 'x': VA_THREE_OFF(); break;
case 'y': VA_FOUR_ON(); break;
case 'z': VA_FOUR_OFF(); break;
case 'A': HOT_WATER_ON(); break;
case 'B': HOT_WATER_OFF(); break;
case 'C': DRAIN_ON(); break;
case 'D': DRAIN_OFF(); break;
case 'E': HEATER_ON(); break;
case 'F': HEATER_OFF(); break;
case 'G': CIRC_PUMP_ON(); break;
case 'H': CIRC_PUMP_OFF(); break;
case 'I': TURBO_OFF(); break;
}
}
}