How to trigger NodeMCU sketch from Arduino Leonardo Micro Pro? So this is probably a very simple question. I have my NodeMCU set up and working where it connects to wifi and sends a push notification. Currently it does that automatically when connected to power.

What I want to do is connect it to my Leonardo Micro so that at a part in the Leonardo sketch it sends a signal to the NodeMCU to run the sketch to trigger the push notification. So simply, which ports should I connect and what code should I change.

Here is my working NodeMCU code.

    #include &lt;ESP8266WiFi.h&gt;

// Wifi Settings
const char* ssid = "MySSID";
const char* password = "MyPassword";
// Pushover settings
char pushoversite[] = "api.pushover.net";
char apitoken[] = "MyAPIToken";
char userkey [] = "MyUserKey";
int length;
WiFiClient client;
void setup() {
  Serial.begin(9600);
  delay(10);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Print the IP address
  Serial.print(WiFi.localIP());

}

void loop()
{
 pushover("OMG, Yes it works!!!");  
 delay(60000); 
}

byte pushover(char *pushovermessage)
{
 String message = pushovermessage;

 length = 81 + message.length();

if(client.connect(pushoversite,80))
 {
   client.println("POST /1/messages.json HTTP/1.1");
   client.println("Host: api.pushover.net");
   client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded");
   client.print("Content-Length: ");
   client.print(length);
   client.println("\r\n");;
   client.print("token=");
   client.print(apitoken);
   client.print("&amp;user=");
   client.print(userkey);
   client.print("&amp;message=");
   client.print(message);
   while(client.connected())  
   {
     while(client.available())
     {
       char ch = client.read();
       Serial.write(ch);
     }
   }
   client.stop();
 }  
}


And my Leonardo code

#include &lt;Keyboard.h&gt;
#include &lt;Mouse.h&gt;
char returnKey = KEY_RETURN;
char tabKey = KEY_TAB;
void setup() {
  Keyboard.begin();
  Mouse.begin();

  delay(4000); //Testing Delay
// Language Select Screen
  Keyboard.write(returnKey);
  delay(30000);
// Welcome Screen 
  Mouse.click(MOUSE_LEFT);
  delay(100);
  Keyboard.write(tabKey);
  delay(100);
  Keyboard.write(tabKey);
  delay(100);
  Keyboard.write(' ');
  delay(2000);
// Select Keyboard 
  Keyboard.write(tabKey);
  delay(100);
  Keyboard.write(tabKey);
  delay(100);
  Keyboard.write(tabKey);
  delay(100);
  Keyboard.write(' ');
  delay(2000);
  TELL NODEMCU TO SEND PUSH NOTIFICATION HERE
}

void loop() {
}


As a reminder the pinout on my boards are as follows.

Leonardo:



NodeMCU:
HW part:
It's like button, simply connect arduino micro pin to nodeMCU pin and GND of arduino to GND of nodeMCU.
It's also good idea to use two resistors as voltage divider because arduino micro works with 5V and ESP8266 (nodeMCU) with 3V3. 5V can destroy ESP8266 but this thing is still not really clear.
Resistor divider connect as in this link link about resistor divider for uart but instead of TX put arduino micro and instead of RX nodeMCU.
resistor divider schematic

Code part:
On the arduino micro part use:

In void setup():
pinMode(PIN, OUTPUT);

In your marked place:


digitalWrite(PIN, HIGH);
delay(100);   //short wait time
digitalWrite(PIN, LOW);

nodeMCU part:

In void setup():
pinMode(PIN, INPUT);

Remove everything from void loop() and put there this:


if(digitalRead(PIN) == 1) pushover(&quot;OMG, Yes it works!!!&quot;);

In both codes select the PIN according to your choice.