Edited.
added the ability to select "I²C-address of Ethernet PHY" between 0 and 1.
paste the "esp32eth.h" library to your Supla library "\src\supla\network" https://github.com/SUPLA/supla-arduino/tree/develop
Code: Select all
// LAN8720 Pin 10 connected to + 3.3v
#include <supla/network/esp32eth.h>
Supla::ESPETH Eth(1); // uint_t ETH_ADDR = I²C-address of Ethernet PHY (1)
Code: Select all
// LAN8720 Pin 10 connected to GND
#include <supla/network/esp32eth.h>
Supla::ESPETH Eth(0); // uint_t ETH_ADDR = I²C-address of Ethernet PHY (0)
the connections are:
------ESP32----------LAN8720
GPIO22 - EMAC_TXD1 : TX1
GPIO19 - EMAC_TXD0 : TX0
GPIO21 - EMAC_TX_EN : TX_EN
GPIO26 - EMAC_RXD1 : RX1
GPIO25 - EMAC_RXD0 : RX0
GPIO27 - EMAC_RX_DV : CRS
GPIO17 - EMAC_TX_CLK : nINT/REFCLK (50MHz)
GPIO23 - SMI_MDC : MDC
GPIO18 - SMI_MDIO : MDIO
GND : GND
3V3 : VCC code example:
Code: Select all
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
-(50MHz) Osc. Enable to GND -
GPIO22 - EMAC_TXD1 : TX1
GPIO19 - EMAC_TXD0 : TX0
GPIO21 - EMAC_TX_EN : TX_EN
GPIO26 - EMAC_RXD1 : RX1
GPIO25 - EMAC_RXD0 : RX0
GPIO27 - EMAC_RX_DV : CRS
GPIO17 - EMAC_TX_CLK : nINT/REFCLK (50MHz)
GPIO23 - SMI_MDC : MDC
GPIO18 - SMI_MDIO : MDIO
GND : GND
3V3 : VCC
*/
#define supla_lib_config_h_ // silences debug messages
#include <SuplaDevice.h>
#include <supla/control/rgbw_leds.h>
#include <supla/control/button.h>
#include <supla/network/esp32eth.h>
Supla::ESPETH Eth(1); // uint_t ETH_ADDR = I²C-address of Ethernet PHY (0 or 1)
/*
Youtube: https://youtu.be/FE9tqzTjmA4
Youtube example was done on older version of SuplaDevice library
*/
#define RED_PIN 4
#define GREEN_PIN 5
#define BLUE_PIN 12
#define BRIGHTNESS_PIN 13
#define BUTTON_PIN 0
void setup() {
Serial.begin(115200);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF};
/*
Having your device already registered at cloud.supla.org,
you want to change CHANNEL sequence or remove any of them,
then you must also remove the device itself from cloud.supla.org.
Otherwise you will get "Channel conflict!" error.
*/
// CHANNEL0 - RGB controller and dimmer (RGBW)
auto rgbw = new Supla::Control::RGBWLeds(
RED_PIN, GREEN_PIN, BLUE_PIN, BRIGHTNESS_PIN);
auto button = new Supla::Control::Button(BUTTON_PIN, true, true);
button->setMulticlickTime(200);
button->setHoldTime(400);
button->repeatOnHoldEvery(200);
button->addAction(Supla::ITERATE_DIM_ALL, rgbw, Supla::ON_HOLD);
button->addAction(Supla::TOGGLE, rgbw, Supla::ON_CLICK_1);
/*
SuplaDevice Initialization.
Server address is available at https://cloud.supla.org
If you do not have an account, you can create it at
https://cloud.supla.org/account/create SUPLA and SUPLA CLOUD are free of
charge
*/
SuplaDevice.begin(
GUID, // Global Unique Identifier
"svr1.supla.org", // SUPLA server address
"email@address", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();
}