Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 4,982
» Latest member: kamermcw
» Forum threads: 2,429
» Forum posts: 12,559

Full Statistics

Online Users
There are currently 49 online users.
» 2 Member(s) | 29 Guest(s)
Bytespider, Crawl, Google, PetalBot, Semrush, Yandex, bot, owler, drandle1, ironbill

Latest Threads
Submit your suggestions a...
Forum: Suggestions and feedback on KinCony's products
Last Post: kamermcw
4 hours ago
» Replies: 7
» Views: 3,463
Help whit update Cold CPU...
Forum: KC868-HxB series Smart Controller
Last Post: itzek
8 hours ago
» Replies: 0
» Views: 4
KC868-AIO connecting to E...
Forum: KC868-AIO
Last Post: slava
10 hours ago
» Replies: 0
» Views: 0
DI8
Forum: Development
Last Post: Vaughan2024
Yesterday, 10:24 PM
» Replies: 0
» Views: 16
Clarification on CT Clamp...
Forum: KC868-M16 / M1 / MB / M30
Last Post: ironbill
Yesterday, 09:27 PM
» Replies: 0
» Views: 11
AS ESPHome yaml for home ...
Forum: KinCony AS
Last Post: admin
Yesterday, 12:29 PM
» Replies: 4
» Views: 278
KCS firmware - MQTT LWT?
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
Yesterday, 12:02 PM
» Replies: 34
» Views: 3,314
H32W Firmware
Forum: KC868-HxB series Smart Controller
Last Post: admin
Yesterday, 10:32 AM
» Replies: 5
» Views: 1,607
"KCS" v3.0.2 firmware for...
Forum: "KCS" firmware system
Last Post: admin
Yesterday, 12:00 AM
» Replies: 0
» Views: 42
What makes the ESP32 chip...
Forum: KC868-A series and Uair Smart Controller
Last Post: alice_amira
11-08-2024, 04:38 PM
» Replies: 0
» Views: 4

  KC868-AIO configure yaml for ESPhome
Posted by: admin - 03-24-2023, 12:11 AM - Forum: KC868-AIO - Replies (12)

   

.txt   KC868-AIO-ESPHome.txt (Size: 20.73 KB / Downloads: 1236)

Print this item

  KC868-AIO ESP32 I/O pin define
Posted by: admin - 03-24-2023, 12:09 AM - Forum: KC868-AIO - No Replies

ESP32 ANALOG_A1 GPIO36 For (Analog Multiplexer: cd74hc4067) to extend "analog input" 1-16

ESP32 ANALOG_A2  GPIO39  analog input 17
ESP32 ANALOG_A3  GPIO34  analog input 18
ESP32 ANALOG_A4  GPIO35  analog input 19

IIC Bus:A

SDA-A:GPIO4
SCL-A:GPIO16

PCF8575:U40 (output 1-16): 100 100 = 0x24
PCF8575:U41 (output 17-32): 100 101 = 0x25

PCF8575:U42 (output 33-38): 100 110 = 0x26

cd74hc4067
S0-A: PCF8575->U42->P10 (output 33)
S1-B: PCF8575->U42->P11 (output 34)
S2-C: PCF8575->U42->P12 (output 35)
S3-D: PCF8575->U42->P13 (output 36)

free LEDs:

LED-D7: PCF8575->U42->P14 (output 37)
LED-D8: PCF8575->U42->P15 (output 38)
-----------------------------------------------------------------------------------

PCF8575:U35 (input 1-16): 100 001 = 0x21
PCF8575:U37 (input 17-32): 100 010 = 0x22

PCF8575:U38 (input 33-48): 100 011 = 0x23
PCF8575:U42 (input 49-58): 100 110 = 0x26

PCF8575->U42->P0 (input 49)
PCF8575->U42->P1 (input 50)
PCF8575->U42->P2 (input 51)
PCF8575->U42->P3 (input 52)
PCF8575->U42->P4 (input 53)
PCF8575->U42->P5 (input 54)
PCF8575->U42->P6 (input 55)
PCF8575->U42->P7 (input 56)
PCF8575->U42->P14 (input 57)
PCF8575->U42->P15 (input 58)

-----------------------------------------------------------------------------------------

PCA9685: address 0x00
-----------------------------------------------------------------------------------------

Button-S1: reset
Button-S2: GPIO0
Button-S3: PCF8575->U42->P14 (input 57)
Button-S4: PCF8575->U42->P15 (input 58)

-------------------------------------------------------------------------------------------


DS18B20/DHT11/DHT21/LED strip -(TP1): GPIO14
DS18B20/DHT11/DHT21/LED strip -(TP2): GPIO5

-------------------------------------------------------------------------------------------

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

-------------------------------------------------------------------------------------------

RS485:
RXD(A): GPIO32
TXD(B): GPIO33

------------------------------------------------------------------------------------------

4G GSM Module / Extend serial port:

RXD: GPIO13
TXD: GPIO15

---------------------------------------------------------------------------------------------

DS3231 RTC module: IIC address 0x68
EEPROM's default I2C address is 0x57

Print this item

  KC868-AIO datasheet PDF
Posted by: admin - 03-24-2023, 12:08 AM - Forum: KC868-AIO - No Replies


.pdf   KC868-AIO.pdf (Size: 18.41 MB / Downloads: 2195)

Print this item

  Interruptions from PCF8574
Posted by: istopnic - 03-23-2023, 02:06 PM - Forum: KC868-A16 - Replies (1)

Is it possible to use interruptions on the I2C bus. As I understand, the pins of interruptions from PCF8574 is not connect anywhere.
Which ESP pin can be used to interrupt?

Print this item

  [Arduino source code for KC868-AIO]-08 DIGITAL_INPUT
Posted by: KinCony Support - 03-23-2023, 01:24 AM - Forum: KC868-AIO - No Replies

[Arduino source code for KC868-AIO]-08 DIGITAL_INPUT

Code:
#include "Arduino.h"
#include "PCF8575.h"

// Set i2c address

PCF8575 pcf8575_IN1(0x21,4,16);
PCF8575 pcf8575_IN2(0x22,4,16);
PCF8575 pcf8575_IN3(0x23,4,16);
PCF8575 pcf8575_IN4(0x26,4,16);

unsigned long timeElapsed;
void setup()
{
    Serial.begin(115200);
  pcf8575_IN1.begin();
  pcf8575_IN2.begin();
  pcf8575_IN3.begin();
  pcf8575_IN4.begin();
   
  pcf8575_IN1.pinMode(P0,INPUT);
  pcf8575_IN1.pinMode(P1,INPUT);
  pcf8575_IN1.pinMode(P2,INPUT);
  pcf8575_IN1.pinMode(P3,INPUT);
  pcf8575_IN1.pinMode(P4,INPUT);
  pcf8575_IN1.pinMode(P5,INPUT);
  pcf8575_IN1.pinMode(P6,INPUT);
  pcf8575_IN1.pinMode(P7,INPUT);
  pcf8575_IN1.pinMode(P8,INPUT);
  pcf8575_IN1.pinMode(P9,INPUT);
  pcf8575_IN1.pinMode(P10,INPUT);
  pcf8575_IN1.pinMode(P11,INPUT);
  pcf8575_IN1.pinMode(P12,INPUT);
  pcf8575_IN1.pinMode(P13,INPUT);
  pcf8575_IN1.pinMode(P14,INPUT);
  pcf8575_IN1.pinMode(P15,INPUT);

  pcf8575_IN2.pinMode(P0,INPUT);
  pcf8575_IN2.pinMode(P1,INPUT);
  pcf8575_IN2.pinMode(P2,INPUT);
  pcf8575_IN2.pinMode(P3,INPUT);
  pcf8575_IN2.pinMode(P4,INPUT);
  pcf8575_IN2.pinMode(P5,INPUT);
  pcf8575_IN2.pinMode(P6,INPUT);
  pcf8575_IN2.pinMode(P7,INPUT);
  pcf8575_IN2.pinMode(P8,INPUT);
  pcf8575_IN2.pinMode(P9,INPUT);
  pcf8575_IN2.pinMode(P10,INPUT);
  pcf8575_IN2.pinMode(P11,INPUT);
  pcf8575_IN2.pinMode(P12,INPUT);
  pcf8575_IN2.pinMode(P13,INPUT);
  pcf8575_IN2.pinMode(P14,INPUT);
  pcf8575_IN2.pinMode(P15,INPUT);
 
  pcf8575_IN3.pinMode(P0,INPUT);
  pcf8575_IN3.pinMode(P1,INPUT);
  pcf8575_IN3.pinMode(P2,INPUT);
  pcf8575_IN3.pinMode(P3,INPUT);
  pcf8575_IN3.pinMode(P4,INPUT);
  pcf8575_IN3.pinMode(P5,INPUT);
  pcf8575_IN3.pinMode(P6,INPUT);
  pcf8575_IN3.pinMode(P7,INPUT);
  pcf8575_IN3.pinMode(P8,INPUT);
  pcf8575_IN3.pinMode(P9,INPUT);
  pcf8575_IN3.pinMode(P10,INPUT);
  pcf8575_IN3.pinMode(P11,INPUT);
  pcf8575_IN3.pinMode(P12,INPUT);
  pcf8575_IN3.pinMode(P13,INPUT);
  pcf8575_IN3.pinMode(P14,INPUT);
  pcf8575_IN3.pinMode(P15,INPUT);

  pcf8575_IN4.pinMode(P0,INPUT);
  pcf8575_IN4.pinMode(P1,INPUT);
  pcf8575_IN4.pinMode(P2,INPUT);
  pcf8575_IN4.pinMode(P3,INPUT);
  pcf8575_IN4.pinMode(P4,INPUT);
  pcf8575_IN4.pinMode(P5,INPUT);
  pcf8575_IN4.pinMode(P6,INPUT);
  pcf8575_IN4.pinMode(P7,INPUT);
 
  pcf8575_IN4.pinMode(P8,OUTPUT);
  pcf8575_IN4.pinMode(P9,OUTPUT);
  pcf8575_IN4.pinMode(P10,OUTPUT);
  pcf8575_IN4.pinMode(P11,OUTPUT);
  pcf8575_IN4.pinMode(P12,OUTPUT);
  pcf8575_IN4.pinMode(P13,OUTPUT);
 
  pcf8575_IN4.pinMode(P14,INPUT);
  pcf8575_IN4.pinMode(P15,INPUT);
}

void loop()
{

uint16_t var_rcv = 0;

var_rcv = pcf8575_IN1.digitalReadAll();
if (var_rcv!=65535)
  {
    Serial.print("input16-input1 state:");
    Serial.println(var_rcv,BIN);
  }

var_rcv = pcf8575_IN2.digitalReadAll();
if (var_rcv!=65535)
  {
    Serial.print("input32-input17 state:");
    Serial.println(var_rcv,BIN);
  }

var_rcv = pcf8575_IN3.digitalReadAll();
if (var_rcv!=65535)
  {
    Serial.print("input48-input33 state:");
    Serial.println(var_rcv,BIN);
  }

var_rcv = pcf8575_IN4.digitalReadAll();
if (var_rcv!=65535)
  {
    Serial.print("input64-input49 state:");
    Serial.println(var_rcv,BIN);
  }
   delay(500);
}



Attached Files
.zip   KC868-AIO-PCF8575_DI_XU.zip (Size: 940 bytes / Downloads: 327)
Print this item

  [Arduino source code for KC868-AIO]-07 PWM_ALL_ON AND OFF
Posted by: KinCony Support - 03-23-2023, 01:24 AM - Forum: KC868-AIO - Replies (2)

[Arduino source code for KC868-AIO]-07 PWM_ALL_ON AND OFF

Code:
/* KC868-AIO_PWM OUTPUT AO_O01----AO_O016*/

#include "PCA9685.h"
PCA9685 pwmController;                 

void setup() {
    Serial.begin(115200);               
    Wire.begin(4,16);                   
    pwmController.resetDevices();     
    pwmController.init();               
}

void loop() {
    pwmController.setPWMFrequency(100);       
          for(int j=0;j<=15;j++){
              pwmController.setChannelPWM(j, 0);
              Serial.println(pwmController.getChannelPWM(j));
           }
           delay(1000);
         for(int j=0;j<=15;j++){
              pwmController.setChannelPWM(j, 4096);
              Serial.println(pwmController.getChannelPWM(j));
           }
           delay(3000);

   
}



Attached Files
.zip   KC868-AIO-PWM_ALL_ON_OFF.zip (Size: 687 bytes / Downloads: 285)
Print this item

  [Arduino source code for KC868-AIO]-06 RS485
Posted by: KinCony Support - 03-23-2023, 01:24 AM - Forum: KC868-AIO - No Replies

[Arduino source code for KC868-AIO]-06 RS485

Code:
/*/*WWW.KINCONY.COM*/
/*KC868-AIO code of RS485 */

void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,32,33);//AIO
   Serial2.println("KC868-AIO RS485 SEND is OK!!");
   Serial2.println("******************");
 
}

void loop() {
  /*print the received data of RS485 port*/
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//Read rs485 receive data  and print it
   }
  delay(200);
}



Attached Files
.zip   KC868-AIO_RS485.zip (Size: 614 bytes / Downloads: 265)
Print this item

  [Arduino source code for KC868-AIO]-05 DIGITAL_OUTPUT
Posted by: KinCony Support - 03-23-2023, 01:23 AM - Forum: KC868-AIO - No Replies

[Arduino source code for KC868-AIO]-05 DIGITAL_OUTPUT

Code:
/*KC868-AIO OUTPUT 32 RELAYS*/
#include "Arduino.h"
#include "PCF8575.h"

#define SDA 4
#define SCL 16
#define delaytime 50
// Set i2c address
PCF8575 pcf8575_R1(0x24,SDA,SCL);
PCF8575 pcf8575_R2(0x25,SDA,SCL);
PCF8575 pcf8575_R3(0x26,SDA,SCL);

void setup()
{
  Serial.begin(115200);
for(int j=1;j<=3;j++){
   if(j==1){
        for(int i=0;i<=15;i++){
          pcf8575_R1.pinMode(i,OUTPUT);
    }
   }
   if(j==2){
        for(int i=0;i<=15;i++){
          pcf8575_R2.pinMode(i,OUTPUT);
    }
   }
   if(j==3){
        for(int i=0;i<=7;i++){
               pcf8575_R3.pinMode(i,INPUT);//0-7 input
            }
        for(int i=8;i<=13;i++){
               pcf8575_R3.pinMode(i,OUTPUT);//8-13 OUTPUT
            }
        for(int i=14;i<=15;i++){
               pcf8575_R3.pinMode(i,INPUT);//14-15 INPUT
            }   
    }
   }
  pcf8575_R1.begin();
  pcf8575_R2.begin();
  pcf8575_R3.begin();
}
void loop()
{
for(int j=1;j<=3;j++){
  if(j==1){
      for(int i=0;i<=15;i++){
      pcf8575_R1.digitalWrite(i,LOW);
      delay(delaytime);
      }
  }
  if(j==2){
    for(int i=0;i<=15;i++){
      pcf8575_R2.digitalWrite(i,LOW);
      delay(delaytime);
      }
   }
  if(j==3){
    for(int i=12;i<=13;i++){
      pcf8575_R3.digitalWrite(i,LOW);
      delay(delaytime);
    }
  }
}

for(int j=1;j<=3;j++){
  if(j==1){
      for(int i=0;i<=15;i++){
      pcf8575_R1.digitalWrite(i,HIGH);
      delay(delaytime);
      }
  }
  if(j==2){
    for(int i=0;i<=15;i++){
      pcf8575_R2.digitalWrite(i,HIGH);
      delay(delaytime);
      }
   }
  if(j==3){
    for(int i=12;i<=13;i++){
      pcf8575_R3.digitalWrite(i,HIGH);
      delay(delaytime);
    }
  }
}
}



Attached Files
.zip   KC868-AIO_PCF8575_DO.zip (Size: 832 bytes / Downloads: 254)
Print this item

  [Arduino source code for KC868-AIO]-04 ADC
Posted by: KinCony Support - 03-23-2023, 01:23 AM - Forum: KC868-AIO - No Replies

[Arduino source code for KC868-AIO]-04 ADC

Code:
/*KC868-AIO ADC output*/

#include "Arduino.h"
#include "PCF8575.h"

#define ANALOG_A1   36        // IO36 
#define ANALOG_A2   39        // IO39   
#define ANALOG_A3   34        // IO34   
#define ANALOG_A4   35        // IO35
#define SDA 4
#define SCL 16
#define delaytime 50
// Set i2c address

PCF8575 pcf8575_R3(0x26,SDA,SCL);

void setup()
{
   Serial.begin(115200);
  pinMode(ANALOG_A1,INPUT);
  pinMode(ANALOG_A2,INPUT);
  pinMode(ANALOG_A3,INPUT);
  pinMode(ANALOG_A4,INPUT);
  pcf8575_R3.pinMode(8,OUTPUT);
  pcf8575_R3.pinMode(9,OUTPUT);
  pcf8575_R3.pinMode(10,OUTPUT);
  pcf8575_R3.pinMode(11,OUTPUT);

  pcf8575_R3.begin();
}
void loop()
{
  for(int j=1;j<17;j++){
     if(j==1){
         truth_table01();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH1=%d\n",analogRead(ANALOG_A1));
         }
     }
    if(j==2){
         truth_table02();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH2=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==3){
          truth_table03();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH3=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==4){
         truth_table04();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH4=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==5){
         truth_table05();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH5=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==6){
          truth_table06();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH6=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==7){
          truth_table07();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH7=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==8){
          truth_table08();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH8=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==9){
          truth_table09();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH9=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==10){
          truth_table10();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH10=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==11){
          truth_table11();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH11=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==12){
          truth_table12();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH12=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==13){
          truth_table13();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH13=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==14){
          truth_table14();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH14=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==15){
          truth_table15();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH15=%d\n",analogRead(ANALOG_A1));
         }
    }
    if(j==16){
          truth_table16();
         if(analogRead(ANALOG_A1)!=0){
            Serial.printf("A1 on CH16=%d\n",analogRead(ANALOG_A1));
         }
    }
  }
  if(analogRead(ANALOG_A2)!=0){Serial.printf("A2 on CH17=%d\n",analogRead(ANALOG_A2));}
  if(analogRead(ANALOG_A3)!=0){Serial.printf("A2 on CH18=%d\n",analogRead(ANALOG_A3));}
  if(analogRead(ANALOG_A4)!=0){Serial.printf("A2 on CH19=%d\n",analogRead(ANALOG_A4));}
  delay(100);
}
void truth_table01()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table02()
{

  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table03()
{

  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table04()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table05()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table06()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table07()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table08()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,LOW);
}
void truth_table09()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table10()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table11()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table12()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,LOW);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table13()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table14()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,LOW);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table15()
{
  pcf8575_R3.digitalWrite(8,LOW);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,HIGH);
}
void truth_table16()
{
  pcf8575_R3.digitalWrite(8,HIGH);
  pcf8575_R3.digitalWrite(9,HIGH);
  pcf8575_R3.digitalWrite(10,HIGH);
  pcf8575_R3.digitalWrite(11,HIGH);
}



Attached Files
.zip   KC868-AIO_PCF8575_ADC.zip (Size: 1.12 KB / Downloads: 264)
Print this item

  [Arduino source code for KC868-AIO]-03 ETHERNET
Posted by: KinCony Support - 03-23-2023, 01:22 AM - Forum: KC868-AIO - No Replies

[Arduino source code for KC868-AIO]-03 ETHERNET

Code:
#include <ETH.h>
#include <WiFiUdp.h>

#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

WiFiUDP Udp;                      //Create UDP object
unsigned int localUdpPort = 4196; //local port

// Set it based on the IP address of the router
IPAddress local_ip(192, 168, 1, 200);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 168, 1, 1);

void setup()
{
  Serial.begin(115200);
  Serial.println();
   
  ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE); //start with ETH

  // write confir for static IP, gateway,subnet,dns1,dns2
  if (ETH.config(local_ip, gateway, subnet, dns, dns) == false) {
    Serial.println("LAN8720 Configuration failed.");
  }else{Serial.println("LAN8720 Configuration success.");}
 
/* while(!((uint32_t)ETH.localIP())) //wait for IP
  {

  }*/
  Serial.println("Connected");
  Serial.print("IP Address:");
  Serial.println(ETH.localIP());

  Udp.begin(localUdpPort); //begin UDP listener
}

void loop()
{
  int packetSize = Udp.parsePacket(); //get package size
  if (packetSize)                     //if have received data
  {
    char buf[packetSize];
    Udp.read(buf, packetSize); //read current data

    Serial.println();
    Serial.print("Received: ");
    Serial.println(buf);
    Serial.print("From IP: ");
    Serial.println(Udp.remoteIP());
    Serial.print("From Port: ");
    Serial.println(Udp.remotePort());

    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); //ready to send data
    Udp.print("Received: ");   
    Udp.write((const uint8_t*)buf, packetSize); //copy data to sender buffer
    Udp.endPacket();            //send data
  }
}



Attached Files
.zip   KC868-AIO_LAN8720.zip (Size: 1.11 KB / Downloads: 296)
Print this item