ESP32-POE Keypad not working on POE only

Started by lrbouchard, October 16, 2023, 11:08:16 PM

Previous topic - Next topic

lrbouchard

Hi,

I did a small program to send 12 key keypad value via OSC. All is working quite well untill I unplug the USB cable to use the ESP32-POE only with a CAT5 cable, then the keypad stop working and just sends random value on some keys. If I replug the USB cable, the keypad start working as it should again...


Anyone knows what is happening here?


Here is my code :

#include <Arduino.h>
#include <Keypad.h>
#include <ETH.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
#include <OSCData.h>

#define ROW_NUM     4 // four rows
#define COLUMN_NUM  3 // three columns

char keys[ROW_NUM][COLUMN_NUM] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte pin_rows[ROW_NUM] = {2, 3, 5, 4}; // GPIO18, GPIO5, GPIO17, GPIO16 connect to the row pins
byte pin_column[COLUMN_NUM] = {13, 14, 15};  // GPIO4, GPIO0, GPIO2 connect to the column pins

Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

const IPAddress ipEth(192, 168, 1, 202);
const IPAddress gateway(192, 168, 1, 1);
const IPAddress subnet(255, 255, 255, 0);

static bool eth_connected = false;

WiFiUDP Udp;

// for OSC
unsigned int receivePort = 8888;
IPAddress outIp(192, 168, 1, 255);
unsigned int outPort = 7001;


void setup() {
  Serial.begin(115200);

  // ETH
  WiFi.onEvent(WiFiEvent);
  ETH.begin();
  ETH.config(ipEth, gateway, subnet);

}

void loop() {
  char key = keypad.getKey();
  int keyNum = (int) key;

  if (key) {
   // Serial.println(key);

    OSCMessage msg("/phoneButton");
    msg.add(keyNum);
    Udp.beginPacket(outIp, outPort);
    msg.send(Udp);
    Udp.endPacket();
    msg.empty();
  }
}



void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {
    case SYSTEM_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case SYSTEM_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");
      break;
    case SYSTEM_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case SYSTEM_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case SYSTEM_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default:
      break;
  }
}

lrbouchard

Ok, it is weirder than I tought, here is a video :

https://drive.google.com/file/d/19lbP3uCYpN4fLu4IGxkn7U0b2nVhIEXh/view?usp=sharing

It seems to be kind of a ground problem, but is there a way to solve this?

LubOlimex

It appears only first row is not working or? GPIO18 is used for the Ethernet, I wouldn't use that one.

I think it is combination of issues - pins that you used are not free and maybe grounding issue too.

The board is ESP32-POE right? What about the USB splitter or USB hub that you use - is it optically isolated?

If it is not optically isolated, it is not safe to have PoE and USB attached to the ESP32-POE at the same time. This might damage the ESP32-POE board, it might damage your laptop, it might damage your PoE switch.

If you wish to have PoE and USB attached at the same time to an ESP32 board, use ESP32-POE-ISO.
Technical support and documentation manager at Olimex

lrbouchard

Hi,

Thanks for the reply and the info. I don't use GPIO 18.

I don't think the USB hub is optically isolated.

To be clear, everything is working when both are plugged (even if it is not safe) and nothing is working when I unplug USB from the BOARD side first. If I unplug USB from the COMPUTER side first, then the program is working A1 until I reboot the ESP32.


LubOlimex

I got tricked by the comment:

// GPIO18, GPIO5, GPIO17, GPIO16 connect to the row pins

Still GPIO2, try to use another pin instead of GPIO2 and see if the behavior changes.

GPIO2 is also a pin I wouldn't use since it is boot pin. Maybe some of the scenarios cause the board to restart after which GPIO2 is stuck. First try to use another pin for the first row instead of GPIO2. Even experiment with different GPIOs.

You should disconnect the USB from ESP32-POE then measure the voltage between the GNDs of the USB and the ESP32-POE.

And most importantly:

It is not safe to have PoE and USB at the same time. It is mentioned on a lot of places in the product page and documentation. The reason is the potential difference between the grounds of two different power sources. This might damage anything in the setup (there is good chance ESP32-POE is damaged already). It is not a joke, it is 50V DC+. Try how it goes with ESP32-PoE-ISO instead which has isolated grounds.
Technical support and documentation manager at Olimex

lrbouchard

I usually don't plug both at the same time, but in my troubleshooting why it was working via serial but not via OSC I tried it and it make it worked as described before. I also tested with the USB power and Ethernet without POE and it worked well too. So there is something missing in the POE that the USB gives (or the other way around) that makes it work only on USB power...

I don't know where to check for the voltage between the two GND, aren't they supposed to be the same?

I tried changing different pins (starting by changing GPIO2) and it was just doing the same problem, most of the time worse in the sense that it wasn't even working in serial alone with USB power only.

I plugged back as it was, for now I will use it with a USB power supply + normal Ethernet without POE, which remove the goal of POE but for this project it is OK.

Just ordered some ESP32-POE-ISO to check if there is a difference.

Thanks!


LubOlimex

I am surprised that changing GPIO2 didn't make a difference, I thought only the first row stops working.

QuoteI don't know where to check for the voltage between the two GND...

Disconnect the USB from ESP32-POE (keep Ethernet cable and PoE powering enabled) then measure the voltage between the GNDs of the USB and the ESP32-POE. E.g. the voltmeter between the ESP32-POE and the USB cable.

ESP32-POE has a lot of pins named GND, just place the voltage meter on one of them. The GND of the USB is the big metal on the connector, hold the second probe there.

Maybe check here, there was similar thing we demonstrated years ago, when HDMI and power supply were attached to the same board, we measured 100V between the GNDs:

https://olimex.wordpress.com/2014/01/22/bevare-non-grounded-tv-monitors-can-damage-your-olinuxino/


Quote... aren't they supposed to be the same?

Ummm... There is a lot of info online about potential difference between different grounds, ground loops, and so on. It is usually not a huge problem for 3.3V or 5V or even 12V circuits but remember that PoE is 50V DC+, it is much high voltage and this makes multiple grounds dangerous.
Technical support and documentation manager at Olimex