0

I had my sketch up and running with a NodeMCU and a Leonardo Pro Micro and decided I wanted to minimize the footprint of the project and use the smaller ESP-01S board instead.

The ESP-01S is programmed to send a push notification to Pushover and my old code works - the only problem is that I don't know how to trigger it from the Pro Micro.

With the NodeMCU I just setup it up to listen on Pin 2 and I triggered a high/low from my Pro Micro and it sent the push notification - at the moment as soon as I power the ESP-01S up it just sends the push notification over and over and doesn't see the connection from the Pro Micro to stop it doing this.

Here is my current code on the ESP-01S

#include <ESP8266WiFi.h>
// Wifi Settings
const char* ssid = "Redacted";
const char* password = "Redacted";
// Pushover settings
char pushoversite[] = "api.pushover.net";
char apitoken[] = "Redacted";
char userkey [] = "Redacted";
int length;
WiFiClient client;
void setup() {
 pinMode(0, OUTPUT);
 digitalWrite(0, LOW);
 pinMode(2, INPUT);
 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()
{
if(digitalRead(5) == 1) pushover("Deployment Completed");
}
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("&user=");
 client.print(userkey);
 client.print("&message=");
 client.print(message);
 while(client.connected()) 
 {
 while(client.available())
 {
 char ch = client.read();
 Serial.write(ch);
 }
 }
 client.stop();
 } 
}

and my Leonardo Pro Micro code is as follows

#include <HID-Project.h>
#include <HID-Settings.h>
int buttonPin;
int buttonPin2;
char chr; // for incoming serial data, type char is signed 8-bit, -128 to 127, ASCII is char codes. Save 1 byte over type int.
void setup() {
 pinMode(5, OUTPUT);
 pinMode(7, OUTPUT);
 BootKeyboard.begin();
 Keyboard.begin();
 Mouse.begin();
 Serial.begin(115200);
 buttonPin = 4; //White Button
 buttonPin2 = 6; //Black Button
 pinMode(buttonPin, INPUT_PULLUP);
 pinMode(buttonPin2, INPUT_PULLUP);
}
void loop() {
 delay(5000);
 digitalWrite(5, HIGH);
 delay(100); //short wait time
 digitalWrite(5, LOW);
 }

Obviously I want the digital pin 5 of the Pro Micro to trigger the ESP-01 to send a push notification when it's trigger.

Just for the record I'm using a 3.3v Pro Micro btw so there's no issue with the voltage here, before I was using a Logic Converter with a 5v board.

I have the ESP-O1S setup with the 3V3 and EN are connected to the 3v VCC on the Pro Micro, the GND to GND and I tried IO0 and IO2 to Digital Pin 5 on the Pro Micro.

Could someone point me in the right direction?

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked Jun 5, 2019 at 20:51
1
  • why do you read pin 5 in esp8266? Commented Jun 6, 2019 at 11:28

1 Answer 1

1

Use io 0 as the esp-01S pin wired to Micro, but change the logic for pull-up, because esp-01S has a pull-up resistor on io 0 of the esp8266. Use LOW to trigger the action and HIGH as normal state.

On Arduino Micro side set the output pin HIGH before you set it as OUTPUT. This will avoid the LOW state. While the Micro pin is in INPUT state after power-up, the pull-up resistor on esp-01S will pull io 0 HIGH.

answered Jun 6, 2019 at 5:22
4
  • Gotcha, so do I need to change any of this code on the ESP-01S? void setup() { pinMode(0, OUTPUT); digitalWrite(0, LOW); pinMode(2, INPUT); Serial.begin(9600); delay(10); Commented Jun 6, 2019 at 10:50
  • in esp8266 pinMode(0, INPUT); and if (digitalRead(0) == LOW) pushover("Deployment Completed"); Commented Jun 6, 2019 at 11:25
  • Just to double check, the correct way on the Leonardo to change the logic is to just set the pin write as HIGH in setup right? There's no way to flip it when you set it out as a Output (that I can see) Commented Jun 6, 2019 at 11:36
  • 1
    yes set it HIGH before setting it as output, to avoid the LOW state which would trigger the action Commented Jun 6, 2019 at 12:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.