Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-A16 - Own Arduino firmware
#11
I already have the PCB Smile I tried to upload the example from ESP32 (it compiles correctly), however, in the serial window there is an error related to the MAC address:

Code:
st:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
E (2007) esp.emac: emac_esp32_init(371): reset timeout
E (2007) esp_eth: esp_eth_driver_install(228): init mac failed
Arduino program code: 
Code:
#define ETH_PHY_TYPE  ETH_PHY_LAN8720
#define ETH_PHY_ADDR  0
#define ETH_PHY_MDC   23
#define ETH_PHY_MDIO  18
#define ETH_PHY_POWER 16
#define ETH_CLK_MODE  ETH_CLOCK_GPIO0_IN
#include <ETH.h>
//IPAddress myIP(10, 1, 10, 111);
//IPAddress myGW(10, 1, 10, 1);
//IPAddress mySN(255, 255, 255, 0);
//IPAddress myDNS(8, 8, 8, 8);

static bool eth_connected = false;

// WARNING: onEvent is called from a separate FreeRTOS task (thread)!
void onEvent(arduino_event_id_t event) {
  switch (event) {
    case ARDUINO_EVENT_ETH_START:
      Serial.println("ETH Started");
      ETH.setHostname("esp32-ethernet");
      break;
    case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break;
    case ARDUINO_EVENT_ETH_GOT_IP:
      Serial.println("ETH Got IP");
      Serial.println(ETH);
      eth_connected = true;
      break;
    case ARDUINO_EVENT_ETH_LOST_IP:
      Serial.println("ETH Lost IP");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;
    default: break;
  }
}

void testClient(const char *host, uint16_t port) {
  Serial.print("\nconnecting to ");
  Serial.println(host);

  NetworkClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    return;
  }
  client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  while (client.connected() && !client.available());
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("closing connection\n");
  client.stop();
}

void setup() {
  Serial.begin(115200);
  Network.onEvent(onEvent);
   delay(1000);
  ETH.begin();
}
I must add that the PCB is functional. I have uploaded the latest firmware to it, i.e. KCS_KC868_A16_V2.2.7.bin, and it correctly starts the network card and reports in the browser. Please help me how to start network support in Arduino.
Reply
#12
your LAN8720 setting wrong. set as mine:
Ethernet (LAN8720) I/O define:

#define ETH_ADDR 0
#define ETH_POWER_PIN -1
#define ETH_MDC_PIN 23
#define ETH_MDIO_PIN 18
#define ETH_TYPE ETH_PHY_LAN8720
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
Reply
#13
I just thought of this a moment ago, thanks for the info (the example compiles and works fine) - but the question is whether these values ​​shouldn't be set somewhere in WebServer_WT32_ETH01. Why so many compiler errors for this example and the fact that it's impossible to compile?
Reply
#14
the settings should be:
#define ETH_PHY_TYPE ETH_PHY_LAN8720
#define ETH_PHY_ADDR 0
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
#define ETH_PHY_POWER -1
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
then works.
Reply
#15
ok, good.
Reply
#16
Generally, launching the mysensors library on KC868-A16 is solved. All you need to do is initialize PHY for ESP32 using the ETH.h library from the Espresiff package in the MyHWESP32 files. Then it's a matter of eliminating WiFI initialization which is automatically launched for ESP32. Interestingly, you can use two IP addresses at the same time, one from PHY and the other from Wifi - of course Mysensors responds to both. If anyone is interested in the solution - I invite you to talk. I'm a bit surprised that PHY support for ESP32 has not been professionally added by the Mysensors team, because it is quite simple and does not require major changes to the code - and it would be easier for everyone - KICONY itself could do it - thanks to which their product would be compatible with this library.
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)