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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,409
» Latest member: danielrio
» Forum threads: 3,660
» Forum posts: 18,959

Full Statistics

Online Users
There are currently 54 online users.
» 0 Member(s) | 37 Guest(s)
AhrefsBot, Amazonbot, Bing, Bytespider, Google, PetalBot, Yandex, bot

Latest Threads
N30 Energy entry not work...
Forum: N30
Last Post: admin
6 hours ago
» Replies: 30
» Views: 544
flash Kincony software to...
Forum: DIY Project
Last Post: admin
6 hours ago
» Replies: 11
» Views: 60
KC868-A6 - how to connect...
Forum: KC868-A6
Last Post: admin
8 hours ago
» Replies: 8
» Views: 133
KC868-A16 v1 with KCS v2....
Forum: "KCS" v2 firmware system
Last Post: admin
8 hours ago
» Replies: 7
» Views: 46
Separate +12V to Kincony,...
Forum: T128M
Last Post: admin
8 hours ago
» Replies: 1
» Views: 14
linux command line / bash...
Forum: TA
Last Post: almman
8 hours ago
» Replies: 2
» Views: 28
KC868-A16 ethernet work w...
Forum: KC868-A16
Last Post: admin
Yesterday, 12:53 PM
» Replies: 14
» Views: 15,949
KC868-M16v2 configure yam...
Forum: KC868-M16 / M1 / MB / M30
Last Post: admin
Yesterday, 11:24 AM
» Replies: 145
» Views: 26,568
KC868-HAv2 work with F24 ...
Forum: KC868-HA /HA v2
Last Post: admin
Yesterday, 11:19 AM
» Replies: 9
» Views: 682
how to compile new tasmot...
Forum: KC868-A series and Uair Smart Controller
Last Post: admin
Yesterday, 11:16 AM
» Replies: 5
» Views: 3,835

Question M30
Posted by: Antonioc - 04-12-2024, 07:48 AM - Forum: KC868-M16 / M1 / MB / M30 - Replies (1)

Hola quisiera saber que tipo de esp32 lleva, para poder seleccionarlo en el ide de Arduino.
 y El código necesario para ESPHOME.

Print this item

  Control defaults to TCP after power cut
Posted by: Steve@ctrl - 04-12-2024, 06:54 AM - Forum: KC868-HxB series Smart Controller - Replies (3)

Hi there 

I have an issues with the KC868-Server unit. The unit is set to MQTT work mode, but sometimes after a power cut the controller reverts back to TCP mode. How can I set it to always start in MQTT mode?

Print this item

  [Arduino code for KC868-A32 Pro]-04 dubug 4G module AT command using serial port
Posted by: admin - 04-12-2024, 06:39 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200);
}

void loop() {
  while (Serial.available()) {
    //  delay(1);
      Serial2.write(Serial.read());
  }
  while (Serial2.available()) {
       Serial.write(Serial2.read());
  }
}
   

Print this item

  how to use ESP32-S3 USB port as common serial port in arduino IDE
Posted by: admin - 04-12-2024, 06:37 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
Serial.print("Test with KinCony A32B Pro Serail");
}
make sure your setting as these image:
   
   

Print this item

  [Arduino code for KC868-A32 Pro]-03 read / write by RS485
Posted by: admin - 04-12-2024, 06:34 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
#include <arduino.h>
#include "HardwareSerial.h"
String comdata1,comdata2;
HardwareSerial my485Serial(1);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  my485Serial.begin(9600,SERIAL_8N1,8,9);///rx:32  tx:33
  Serial.println("UsbSerial say hello");
  my485Serial.println("R485 say hello");
}

void loop() {
  // put your main code here, to run repeatedly:
 
    while (my485Serial.available() > 0) {
      delay(100);
      comdata1 = my485Serial.readString();
      my485Serial.print("R485.readString:");
      my485Serial.println(comdata1);
    }
    while (Serial.available() > 0) {
        delay(100);
      comdata1 = Serial.readString();
      Serial.print("UsbSerial.readString:");
      Serial.println(comdata1);
    }
}
source code download:

.zip   RS485.zip (Size: 475 bytes / Downloads: 437)

Print this item

  [Arduino code for KC868-A32 Pro]-02 read digital input by XL9535
Posted by: admin - 04-12-2024, 06:32 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
#include <PCA95x5.h>

PCA9555 ioex;

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

    Wire.begin(11,10,40000);
    ioex.attach(Wire,0x24);
    ioex.polarity(PCA95x5::Polarity::ORIGINAL_ALL);
    ioex.direction(PCA95x5::Direction::IN_ALL);
}

void loop() {
    Serial.println(ioex.read(), BIN);
    delay(1000);
}

source code download:

.zip   XL9535_input.zip (Size: 372 bytes / Downloads: 399)
before use XL9535 chip, you need to install PCA95x5 arduino library:
[Image: attachment.php?aid=5044]

Print this item

  [Arduino code for KC868-A32 Pro]-01 Control relay by XL9535
Posted by: admin - 04-12-2024, 06:28 AM - Forum: KC868-A32/A32 Pro - No Replies

Code:
#include <PCA95x5.h>

PCA9555 ioex;

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

    Wire.begin(11,10,100000);
    ioex.attach(Wire,0x21);
    ioex.polarity(PCA95x5::Polarity::ORIGINAL_ALL);
    ioex.direction(PCA95x5::Direction::OUT_ALL);
    ioex.write(PCA95x5::Level::H_ALL);
    delay(2000);
}

void loop() {
    for (size_t i = 0; i < 16; ++i) {
        Serial.print("set port low: ");  //turn ON relay
        Serial.println(i);

        ioex.write((PCA95x5::Port::Port)i, PCA95x5::Level::L);
        Serial.println(ioex.read(), BIN);
        delay(500);
    }

    for (size_t i = 0; i < 16; ++i) {
        Serial.print("set port high: "); //turn OFF relay
        Serial.println(i);

        ioex.write((PCA95x5::Port::Port)i, PCA95x5::Level::H);
        Serial.println(ioex.read(), BIN);
        delay(500);
    }
}
source code download:

.zip   XL9535_output.zip (Size: 492 bytes / Downloads: 469)

before use XL9535 chip, you need to install PCA95x5 arduino library:
   

Print this item

  A32 Pro ESPHome yaml for home assistant
Posted by: admin - 04-12-2024, 06:21 AM - Forum: KC868-A32/A32 Pro - Replies (1)

   

Code:
esphome:
  name: a32-pro
  friendly_name: a32-Pro
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:
  hardware_uart: USB_SERIAL_JTAG

# Enable Home Assistant API
api:

# ota:
#   password: "5f17bccba50c65f60200db69f1b1ebbe"

# wifi:
#   ssid: KinCony
#   password: a12345678

#   # Enable fallback hotspot (captive portal) in case wifi connection fails
#   ap:
#     ssid: "A32-Pro Fallback Hotspot"
#     password: "25JYfblp8QJP"

# captive_portal:

ethernet:
  type: W5500
  clk_pin: GPIO42
  mosi_pin: GPIO44
  miso_pin: GPIO40
  cs_pin: GPIO39
  interrupt_pin: GPIO41
  reset_pin: GPIO43

i2c:
   - id: bus_a
     sda: 11
     scl: 10
     scan: true
     frequency: 400kHz

xl9535:
  - id: xl9535_hub_out1 # for output channel 1-16
    address: 0x21
  - id: xl9535_hub_out2 # for output channel 17-32
    address: 0x22
  - id: xl9535_hub_in1 # for input channel 1-16
    address: 0x24
  - id: xl9535_hub_in2 # for input channel 17-32
    address: 0x25

pcf8574:
  - id: 'pcf8574_in_3'  # for input channel 33-40
    address: 0x23

uart:
  - id: uart_1
    baud_rate: 9600
    debug:
      direction: BOTH
      dummy_receiver: true
      after:
        timeout: 10ms
    tx_pin: 9
    rx_pin: 8

  - id: uart_tuya
    baud_rate: 115200
    debug:
      direction: BOTH
      dummy_receiver: true
      after:
        timeout: 10ms
    tx_pin: 15
    rx_pin: 16

  - id: uart_sim7600
    baud_rate: 115200
    debug:
      direction: BOTH
      dummy_receiver: true
      after:
        timeout: 10ms
      sequence:
        - lambda: UARTDebug::log_string(direction, bytes);
    tx_pin: 18
    rx_pin: 17

switch:

  - platform: gpio
    pin: 45
    name: "LED"

  - platform: uart
    uart_id: uart_1
    name: "RS485 Button"
    data: [0x11, 0x22, 0x33, 0x44, 0x55]

  - platform: uart
    uart_id: uart_sim7600
    name: "UART 4G"
    data: "AT+CGSN\r\n" # read 4G SIM7600 ID

  # - platform: uart
  #   uart_id: uart_tuya
  #   name: "UART TUYA2"
  #   data: [0x55, 0xaa, 0x03, 0x00, 0x00, 0x01, 0x01, 0x04]

  - platform: gpio
    name: A32 Pro Switch01
    pin:
      xl9535: xl9535_hub_out1
      number: 0
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch02
    pin:
      xl9535: xl9535_hub_out1
      number: 1
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch03
    pin:
      xl9535: xl9535_hub_out1
      number: 2
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch04
    pin:
      xl9535: xl9535_hub_out1
      number: 3
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch05
    pin:
      xl9535: xl9535_hub_out1
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch06
    pin:
      xl9535: xl9535_hub_out1
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch07
    pin:
      xl9535: xl9535_hub_out1
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch08
    pin:
      xl9535: xl9535_hub_out1
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch09
    pin:
      xl9535: xl9535_hub_out1
      number: 10
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch10
    pin:
      xl9535: xl9535_hub_out1
      number: 11
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch11
    pin:
      xl9535: xl9535_hub_out1
      number: 12
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch12
    pin:
      xl9535: xl9535_hub_out1
      number: 13
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch13
    pin:
      xl9535: xl9535_hub_out1
      number: 14
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch14
    pin:
      xl9535: xl9535_hub_out1
      number: 15
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch15
    pin:
      xl9535: xl9535_hub_out1
      number: 16
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch16
    pin:
      xl9535: xl9535_hub_out1
      number: 17
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: A32 Pro Switch17
    pin:
      xl9535: xl9535_hub_out2
      number: 0
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch18
    pin:
      xl9535: xl9535_hub_out2
      number: 1
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch19
    pin:
      xl9535: xl9535_hub_out2
      number: 2
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch20
    pin:
      xl9535: xl9535_hub_out2
      number: 3
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch21
    pin:
      xl9535: xl9535_hub_out2
      number: 4
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch22
    pin:
      xl9535: xl9535_hub_out2
      number: 5
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch23
    pin:
      xl9535: xl9535_hub_out2
      number: 6
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch24
    pin:
      xl9535: xl9535_hub_out2
      number: 7
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch25
    pin:
      xl9535: xl9535_hub_out2
      number: 10
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch26
    pin:
      xl9535: xl9535_hub_out2
      number: 11
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch27
    pin:
      xl9535: xl9535_hub_out2
      number: 12
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch28
    pin:
      xl9535: xl9535_hub_out2
      number: 13
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch29
    pin:
      xl9535: xl9535_hub_out2
      number: 14
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch30
    pin:
      xl9535: xl9535_hub_out2
      number: 15
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch31
    pin:
      xl9535: xl9535_hub_out2
      number: 16
      mode: OUTPUT
      inverted: true
  - platform: gpio
    name: A32 Pro Switch32
    pin:
      xl9535: xl9535_hub_out2
      number: 17
      mode: OUTPUT
      inverted: true

binary_sensor:
  - platform: gpio
    name: A32 Pro DI01
    pin:
      xl9535: xl9535_hub_in1
      number: 0
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI02
    pin:
      xl9535: xl9535_hub_in1
      number: 1
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI03
    pin:
      xl9535: xl9535_hub_in1
      number: 2
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI04
    pin:
      xl9535: xl9535_hub_in1
      number: 3
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI05
    pin:
      xl9535: xl9535_hub_in1
      number: 4
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI06
    pin:
      xl9535: xl9535_hub_in1
      number: 5
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI07
    pin:
      xl9535: xl9535_hub_in1
      number: 6
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI08
    pin:
      xl9535: xl9535_hub_in1
      number: 7
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI09
    pin:
      xl9535: xl9535_hub_in1
      number: 10
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI10
    pin:
      xl9535: xl9535_hub_in1
      number: 11
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI11
    pin:
      xl9535: xl9535_hub_in1
      number: 12
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI12
    pin:
      xl9535: xl9535_hub_in1
      number: 13
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI13
    pin:
      xl9535: xl9535_hub_in1
      number: 14
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI14
    pin:
      xl9535: xl9535_hub_in1
      number: 15
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI15
    pin:
      xl9535: xl9535_hub_in1
      number: 16
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI16
    pin:
      xl9535: xl9535_hub_in1
      number: 17
      mode: INPUT
      inverted: true

  - platform: gpio
    name: "A32 Pro TMP1"
    pin:
      number: 1
      inverted: true


  - platform: gpio
    name: "A32 Pro TMP2"
    pin:
      number: 2
      inverted: true

  - platform: gpio
    name: "A32 Pro DL"
    pin:
      number: 0
      inverted: true

  - platform: gpio
    name: "A32 Pro DTUYA"
    pin:
      number: 21
      inverted: true

  - platform: gpio
    name: A32 Pro DI17
    pin:
      xl9535: xl9535_hub_in2
      number: 0
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI18
    pin:
      xl9535: xl9535_hub_in2
      number: 1
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI19
    pin:
      xl9535: xl9535_hub_in2
      number: 2
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI20
    pin:
      xl9535: xl9535_hub_in2
      number: 3
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI21
    pin:
      xl9535: xl9535_hub_in2
      number: 4
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI22
    pin:
      xl9535: xl9535_hub_in2
      number: 5
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI23
    pin:
      xl9535: xl9535_hub_in2
      number: 6
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI24
    pin:
      xl9535: xl9535_hub_in2
      number: 7
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI25
    pin:
      xl9535: xl9535_hub_in2
      number: 10
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI26
    pin:
      xl9535: xl9535_hub_in2
      number: 11
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI27
    pin:
      xl9535: xl9535_hub_in2
      number: 12
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI28
    pin:
      xl9535: xl9535_hub_in2
      number: 13
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI29
    pin:
      xl9535: xl9535_hub_in2
      number: 14
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI30
    pin:
      xl9535: xl9535_hub_in2
      number: 15
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI31
    pin:
      xl9535: xl9535_hub_in2
      number: 16
      mode: INPUT
      inverted: true
  - platform: gpio
    name: A32 Pro DI32
    pin:
      xl9535: xl9535_hub_in2
      number: 17
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI33
    pin:
      pcf8574: pcf8574_in_3
      number: 0
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI34
    pin:
      pcf8574: pcf8574_in_3
      number: 1
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI35
    pin:
      pcf8574: pcf8574_in_3
      number: 2
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI36
    pin:
      pcf8574: pcf8574_in_3
      number: 3
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI37
    pin:
      pcf8574: pcf8574_in_3
      number: 4
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI38
    pin:
      pcf8574: pcf8574_in_3
      number: 5
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI39
    pin:
      pcf8574: pcf8574_in_3
      number: 6
      mode: INPUT
      inverted: true

  - platform: gpio
    name: A32 Pro DI40
    pin:
      pcf8574: pcf8574_in_3
      number: 7
      mode: INPUT
      inverted: true

gp8403:
  id: my_gp8403
  voltage: 10V

output:
  - platform: gp8403
    id: gp8403_output_1
    gp8403_id: my_gp8403
    channel: 0
  - platform: gp8403
    id: gp8403_output_2
    gp8403_id: my_gp8403
    channel: 1

light:
  - platform: monochromatic
    name: "A32 Pro-DAC-0"
    output: gp8403_output_1

  - platform: monochromatic
    name: "A32 Pro-DAC-1"
    output: gp8403_output_2

sensor:
  - platform: adc
    pin: 7
    name: "A32 Pro A1 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 6
    name: "A32 Pro A2 Voltage"
    update_interval: 5s
    attenuation: 11db
    filters:
      # - multiply: 1.51515
      - lambda:
          if (x >= 3.11) {
            return x * 1.60256;
          } else if (x <= 0.15) {
            return 0;
          } else {
            return x * 1.51;
          }
  - platform: adc
    pin: 5
    name: "A32 Pro A3 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666
  - platform: adc
    pin: 4
    name: "A32 Pro A4 Current"
    update_interval: 5s
    unit_of_measurement: mA
    attenuation: 11db
    filters:
      - multiply: 6.66666666

web_server:
  port: 80

font:
  - file: "gfonts://Roboto"
    id: roboto
    size: 20

display:
  - platform: ssd1306_i2c
    i2c_id: bus_a
    model: "SSD1306 128x64"
    address: 0x3C
    lambda: |-
      it.printf(0, 0, id(roboto), "A32 Pro");
download yaml:



Attached Files
.txt   A32_Pro-ESPHome.txt (Size: 14.46 KB / Downloads: 680)
Print this item

  A32 Pro ESP32 io pins define
Posted by: admin - 04-12-2024, 06:17 AM - Forum: KC868-A32/A32 Pro - No Replies

#define ANALOG_A1  GPIO7
#define ANALOG_A2  GPIO6
#define ANALOG_A3  GPIO5
#define ANALOG_A4  GPIO4

IIC Bus:

SDA:GPIO11
SCL:GPIO10

XL9535:U57 (relay1-16): address:0x21
XL9535:U60 (relay17-32): address:0x22

XL9535:U58 (input1-16): address:0x24
XL9535:U61 (input17-32): address:0x25

PCF8574:U72(input33-40): address:0x23

GP8403 DAC i2c address: 0x58
SSD1306 display: address:0x3c
-----------------

1-wire:
GPIO1
GPIO2

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

Ethernet (W5500) I/O define:

clk_pin: GPIO42
mosi_pin: GPIO44
miso_pin: GPIO40
cs_pin: GPIO39
interrupt_pin: GPIO41
reset_pin: GPIO43

--------------------
RS485:
RXD:GPIO8
TXD:GPIO9

4G module:
RXD:GPIO17
TXD:GPIO18

Tuya module:
RXD:GPIO16
TXD:GPIO15
--------------------
RF 433M receiver: GPIO38

Print this item

  KinCony ATF (ESP32 SD card module) print information arduino demo code
Posted by: admin - 04-12-2024, 05:32 AM - Forum: Extender module - No Replies

Code:
#include <Arduino.h>
//SD library
#include <SD.h>
#include <FS.h>
#include <SPI.h>
//HSPI or VSPI define
//#define  hspi
#define  vspi
#ifdef vspi
SPIClass sdSPI(VSPI);
#define SD_MISO     19
#define SD_MOSI     23
#define SD_SCLK     18
#define SD_CS       5

#else
SPIClass sdSPI(HSPI);
#define SD_MISO     12
#define SD_MOSI     13
#define SD_SCLK     14
#define SD_CS       15

#endif
void SD_init();

void setup()
{
  Serial.begin(115200);
  delay(500);
#ifdef  hspi
  Serial.println("please insert SD card");
  delay(12000);
#endif
  SD_init();

}

void loop() {
  //print SD card information
  Serial.printf("SD card total size: %lluMB \n", SD.cardSize() / (1024 * 1024));
  Serial.printf("File system whole size: %lluB \n", SD.totalBytes());
  Serial.printf("File system used: %lluB \n", SD.usedBytes());
  delay(5000);
}


void SD_init() {
  //load file system
   sdSPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);
  if (!SD.begin(SD_CS, sdSPI))
  {
    // if(!SD.begin()){
    Serial.println("load SD card error");
    return;
  }
  uint8_t cardType = SD.cardType();

  if (cardType == CARD_NONE)
  {
    Serial.println("not connected SD card");
    return;
  }
  else if (cardType == CARD_MMC)
  {
    Serial.println("MMC card");
  }
  else if (cardType == CARD_SD)
  {
    Serial.println("SDSC card");
  }
  else if (cardType == CARD_SDHC)
  {
    Serial.println("SDHC card");
  }
  else
  {
    Serial.println("unknow card");
  }
}
download:

.zip   ATF-SD-Size.zip (Size: 725 bytes / Downloads: 406)

Print this item