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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 9,731
» Latest member: georgeoliver123
» Forum threads: 4,200
» Forum posts: 20,868

Full Statistics

Online Users
There are currently 53 online users.
» 0 Member(s) | 43 Guest(s)
Amazonbot, Applebot, Baidu, Crawl, PetalBot, bot

Latest Threads
CR battery
Forum: KC868-A2v3
Last Post: apps4check
1 hour ago
» Replies: 0
» Views: 2
T32M issue with Output 1
Forum: DIY Project
Last Post: marktuan
Today, 04:38 AM
» Replies: 5
» Views: 963
N60 Loss of kWh on reset
Forum: N60
Last Post: admin
Today, 01:17 AM
» Replies: 3
» Views: 22
KinCony F24 ESP32-S3 16A ...
Forum: News
Last Post: admin
08-27-2026, 11:58 AM
» Replies: 2
» Views: 884
kc868-A16S3 v3.2
Forum: Development
Last Post: admin
08-27-2026, 02:02 AM
» Replies: 3
» Views: 22
SSD1306 with case
Forum: KC868-A16v3
Last Post: admin
08-26-2026, 10:41 AM
» Replies: 3
» Views: 30
N60 power supply - power ...
Forum: N60
Last Post: admin
08-25-2026, 11:26 PM
» Replies: 1
» Views: 17
KC868-meter-7pv-rs485
Forum: Development
Last Post: admin
08-25-2026, 10:20 AM
» Replies: 7
» Views: 3,780
N60 configure yaml for ES...
Forum: N60
Last Post: admin
08-23-2026, 01:42 AM
» Replies: 7
» Views: 1,975
KCS VERSUS ESPHOME
Forum: "KCS" v3 firmware
Last Post: EDVALDO DE MARINGA
08-22-2026, 01:31 PM
» Replies: 2
» Views: 81

  [arduino code examples for AS]-06 how to play MP3 file by SD Card
Posted by: admin - 10-22-2024, 01:12 AM - Forum: KinCony AS - No Replies

Code:
/*
  ESP32 SD I2S Music Player
  esp32-i2s-sd-player.ino
  Plays MP3 file from microSD card
  Uses MAX98357 I2S Amplifier Module
  Uses ESP32-audioI2S Library - https://github.com/schreibfaul1/ESP32-audioI2S
*/

// Include required libraries
#include "Arduino.h"
#include "Audio.h"
#include "SD.h"
#include "FS.h"

// microSD Card Reader connections
#define SD_CS         13
#define SPI_MOSI      12
#define SPI_MISO      10
#define SPI_SCK       11

// I2S Connections
#define I2S_DOUT      8
#define I2S_BCLK      7
#define I2S_LRC       6

// Create Audio object
Audio audio;

void setup() {
   
    // Set microSD Card CS as OUTPUT and set HIGH
    pinMode(SD_CS, OUTPUT);     
    digitalWrite(SD_CS, HIGH);
   
    // Initialize SPI bus for microSD Card
    SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
   
    // Start Serial Port
    Serial.begin(115200);
   
    // Start microSD Card
    if(!SD.begin(SD_CS))
    {
      Serial.println("Error accessing microSD card!");
      while(true);
    }
   
    // Setup I2S
    audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
   
    // Set Volume
    audio.setVolume(50);
   
    // Open music file
    audio.connecttoFS(SD,"/music.mp3");
   
}

void loop()
{
    audio.loop();   
}
place music.mp3 file on your SD card, make sure SD card is FAT32 format. when board power on, will auto play the MP3 file.
arduino ino file download:
.zip   AS-mp3.zip (Size: 760 bytes / Downloads: 753)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   AS-mp3.ino.merged.zip (Size: 878.75 KB / Downloads: 740)
arduino IDE compile setting:    

Print this item

  [arduino code examples for AS]-05 how to use SD Card
Posted by: admin - 10-22-2024, 01:01 AM - Forum: KinCony AS - No Replies

Code:
#include "FS.h"
#include "SD.h"
#include "SPI.h"

#define SCK  11
#define MISO  10
#define MOSI  12
#define CS  13

void readFile(fs::FS &fs, const char * path){
  Serial.printf("Reading file: %s\n", path);

  File file = fs.open(path);
  if(!file){
    Serial.println("Failed to open file for reading");
    return;
  }

  Serial.print("Read from file: ");
  while(file.available()){
    Serial.print((char)file.read());
  }
  file.close();
}

void writeFile(fs::FS &fs, const char * path, const char * message){
  Serial.printf("Writing file: %s\n", path);

  File file = fs.open(path, FILE_WRITE);
  if(!file){
    Serial.println("Failed to open file for writing");
    return;
  }
  if(file.print(message)){
    Serial.println("File written");
  } else {
    Serial.println("Write failed");
  }
  file.close();
}

void appendFile(fs::FS &fs, const char * path, const char * message){
  Serial.printf("Appending to file: %s\n", path);

  File file = fs.open(path, FILE_APPEND);
  if(!file){
    Serial.println("Failed to open file for appending");
    return;
  }
  if(file.print(message)){
    Serial.println("Message appended");
  } else {
    Serial.println("Append failed");
  }
  file.close();
}

void deleteFile(fs::FS &fs, const char * path){
  Serial.printf("Deleting file: %s\n", path);
  if(fs.remove(path)){
    Serial.println("File deleted");
  } else {
    Serial.println("Delete failed");
  }
}

void testFileIO(fs::FS &fs, const char * path){
  File file = fs.open(path);
  static uint8_t buf[512];
  size_t len = 0;
  uint32_t start = millis();
  uint32_t end = start;
  if(file){
    len = file.size();
    size_t flen = len;
    start = millis();
    while(len){
      size_t toRead = len;
      if(toRead > 512){
        toRead = 512;
      }
      file.read(buf, toRead);
      len -= toRead;
    }
    end = millis() - start;
    Serial.printf("%u bytes read for %u ms\n", flen, end);
    file.close();
  } else {
    Serial.println("Failed to open file for reading");
  }


  file = fs.open(path, FILE_WRITE);
  if(!file){
    Serial.println("Failed to open file for writing");
    return;
  }

  size_t i;
  start = millis();
  for(i=0; i<2048; i++){
    file.write(buf, 512);
  }
  end = millis() - start;
  Serial.printf("%u bytes written for %u ms\n", 2048 * 512, end);
  file.close();
}

void setup(){
  Serial.begin(115200);
  SPIClass spi = SPIClass(HSPI);
  spi.begin(SCK, MISO, MOSI, CS);

  if (!SD.begin(CS,spi,80000000)) {
    Serial.println("Card Mount Failed");
    return;
  }
  uint8_t cardType = SD.cardType();

  if(cardType == CARD_NONE){
    Serial.println("No SD card attached");
    return;
  }

  Serial.print("SD Card Type: ");
  if(cardType == CARD_MMC){
    Serial.println("MMC");
  } else if(cardType == CARD_SD){
    Serial.println("SDSC");
  } else if(cardType == CARD_SDHC){
    Serial.println("SDHC");
  } else {
    Serial.println("UNKNOWN");
  }

  uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  Serial.printf("SD Card Size: %lluMB\n", cardSize);
  delay(2000);

  deleteFile(SD, "/hello.txt");
  writeFile(SD, "/hello.txt", "Hello ");
  appendFile(SD, "/hello.txt", "World!\n");
  readFile(SD, "/hello.txt");
  testFileIO(SD, "/test.txt");
  Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024));
  Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024));
}

void loop(){

}
make sure your SC Card is FAT32 format.
arduino ino file download:
.zip   AS-SD.zip (Size: 1.1 KB / Downloads: 720)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   AS-SD.ino.merged.zip (Size: 221.37 KB / Downloads: 772)

Print this item

  [arduino code examples for AS]-04 how to output dynamic wave to speaker by MAX98357A
Posted by: admin - 10-22-2024, 12:57 AM - Forum: KinCony AS - No Replies

Code:
/*
  ESP32 I2S Audio Test with Dynamic Frequency and Amplitude
  This code generates a sine wave with changing frequency and amplitude
  to test the MAX98357A amplifier output.
*/

// Include I2S driver
#include <driver/i2s.h>
#include <math.h>

// Connections to MAX98357A amplifier
#define I2S_DOUT  8
#define I2S_BCLK  7
#define I2S_LRC   6

// Use I2S Processor 0
#define I2S_PORT I2S_NUM_0

// Sample rate and initial parameters
const int sampleRate = 44100;
const float baseFrequency = 440.0;  // Base frequency (A4 note)
const int baseAmplitude = 3000;     // Base amplitude
const float frequencyStep = 5.0;    // Frequency change rate
const int amplitudeStep = 50;       // Amplitude change rate

// Variables to control dynamic frequency and amplitude
float currentFrequency = baseFrequency;
int currentAmplitude = baseAmplitude;
int direction = 1;  // To control increase or decrease of frequency and amplitude

void i2s_install() {
  // Set up I2S Processor configuration for TX only
  const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_TX),
    .sample_rate = sampleRate,
    .bits_per_sample = i2s_bits_per_sample_t(16),
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
    .intr_alloc_flags = 0,
    .dma_buf_count = 8,
    .dma_buf_len = 64,
    .use_apll = false
  };

  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin() {
  // Set I2S pin configuration for output (amp)
  const i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_BCLK,
    .ws_io_num = I2S_LRC,
    .data_out_num = I2S_DOUT,
    .data_in_num = I2S_PIN_NO_CHANGE
  };

  i2s_set_pin(I2S_PORT, &pin_config);
}

void setup() {
  // Set up Serial Monitor
  Serial.begin(115200);
  Serial.println("Generating dynamic sine wave on MAX98357A amplifier");

  // Set up I2S
  i2s_install();
  i2s_setpin();
  i2s_start(I2S_PORT);
}

void loop() {
  // Buffer to hold the audio data
  int16_t buffer[64];

  // Generate dynamic sine wave (with changing frequency and amplitude)
  for (int i = 0; i < 64; i++) {
    // Generate sine wave with current frequency and amplitude
    float sample = sinf(2.0f * M_PI * currentFrequency * i / sampleRate);
    buffer[i] = (int16_t)(sample * currentAmplitude);  // Convert float to 16-bit integer
  }

  // Send the buffer to the I2S amplifier
  size_t bytesWritten;
  i2s_write(I2S_PORT, &buffer, sizeof(buffer), &bytesWritten, portMAX_DELAY);

  // Adjust frequency and amplitude for the next loop iteration
  currentFrequency += frequencyStep * direction;
  currentAmplitude += amplitudeStep * direction;

  // Change direction of frequency and amplitude when reaching limits
  if (currentFrequency > 880.0 || currentFrequency < 220.0) {
    direction = -direction;  // Reverse direction when frequency reaches upper or lower limit
  }
  if (currentAmplitude > 5000 || currentAmplitude < 1000) {
    direction = -direction;  // Reverse direction when amplitude reaches upper or lower limit
  }
}
arduino ino file download:
.zip   AS-Speaker-Dynamic-wave.zip (Size: 1.38 KB / Downloads: 783)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   AS-Speaker-Dynamic-wave.ino.merged.zip (Size: 192.38 KB / Downloads: 700)

Print this item

  [arduino code examples for AS]-03 how to output simple wave to speaker by MAX98357A
Posted by: admin - 10-22-2024, 12:54 AM - Forum: KinCony AS - No Replies

Code:
/*
  ESP32 I2S Audio Test
  This code generates a simple sine wave to test the MAX98357A amplifier output.
*/

// Include I2S driver
#include <driver/i2s.h>
#include <math.h>

// Connections to MAX98357A amplifier
#define I2S_DOUT  8
#define I2S_BCLK  7
#define I2S_LRC   6

// Use I2S Processor 0
#define I2S_PORT I2S_NUM_0

// Sample rate and wave parameters
const int sampleRate = 44100;
const float frequency = 440.0; // Frequency of the sine wave (A4 note)
const int amplitude = 3000;    // Amplitude of the sine wave

void i2s_install() {
  // Set up I2S Processor configuration for TX only
  const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_TX),
    .sample_rate = sampleRate,
    .bits_per_sample = i2s_bits_per_sample_t(16),
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
    .intr_alloc_flags = 0,
    .dma_buf_count = 8,
    .dma_buf_len = 64,
    .use_apll = false
  };

  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin() {
  // Set I2S pin configuration for output (amp)
  const i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_BCLK,
    .ws_io_num = I2S_LRC,
    .data_out_num = I2S_DOUT,
    .data_in_num = I2S_PIN_NO_CHANGE
  };

  i2s_set_pin(I2S_PORT, &pin_config);
}

void setup() {
  // Set up Serial Monitor
  Serial.begin(115200);
  Serial.println("Generating sine wave on MAX98357A amplifier");

  // Set up I2S
  i2s_install();
  i2s_setpin();
  i2s_start(I2S_PORT);
}

void loop() {
  // Buffer to hold the audio data
  int16_t buffer[64];

  // Generate sine wave and write it to I2S buffer
  for (int i = 0; i < 64; i++) {
    float sample = sinf(2.0f * M_PI * frequency * i / sampleRate);
    buffer[i] = (int16_t)(sample * amplitude); // Convert float to 16-bit integer
  }

  // Send the buffer to the I2S amplifier
  size_t bytesWritten;
  i2s_write(I2S_PORT, &buffer, sizeof(buffer), &bytesWritten, portMAX_DELAY);
}
arduino ino file download:
.zip   AS-Speaker-Simple-wave.zip (Size: 1.09 KB / Downloads: 853)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   AS-Speaker-Simple-wave.ino.merged.zip (Size: 192.24 KB / Downloads: 774)

Print this item

  [arduino code examples for AS]-02 how to use INMP441 Microphone
Posted by: admin - 10-22-2024, 12:50 AM - Forum: KinCony AS - No Replies

Code:
/*
  ESP32 I2S Microphone Sample
  esp32-i2s-mic-sample.ino
  Sample sound from I2S microphone, display on Serial Plotter
  Requires INMP441 I2S microphone
*/

// Include I2S driver
#include <driver/i2s.h>

// Connections to INMP441 I2S microphone
#define I2S_WS 3
#define I2S_SD 4
#define I2S_SCK 2

// Use I2S Processor 0
#define I2S_PORT I2S_NUM_0

// Define input buffer length
#define bufferLen 64
int16_t sBuffer[bufferLen];

void i2s_install() {
  // Set up I2S Processor configuration
  const i2s_config_t i2s_config = {
    .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
    .sample_rate = 44100,
    .bits_per_sample = i2s_bits_per_sample_t(16),
    .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
    .communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_I2S),
    .intr_alloc_flags = 0,
    .dma_buf_count = 8,
    .dma_buf_len = bufferLen,
    .use_apll = false
  };

  i2s_driver_install(I2S_PORT, &i2s_config, 0, NULL);
}

void i2s_setpin() {
  // Set I2S pin configuration
  const i2s_pin_config_t pin_config = {
    .bck_io_num = I2S_SCK,
    .ws_io_num = I2S_WS,
    .data_out_num = -1,
    .data_in_num = I2S_SD
  };

  i2s_set_pin(I2S_PORT, &pin_config);
}

void setup() {

  // Set up Serial Monitor
  Serial.begin(115200);
  Serial.println(" ");

  delay(1000);

  // Set up I2S
  i2s_install();
  i2s_setpin();
  i2s_start(I2S_PORT);


  delay(500);
}

void loop() {

  // False print statements to "lock range" on serial plotter display
  // Change rangelimit value to adjust "sensitivity"
  int rangelimit = 3000;
  Serial.print(rangelimit * -1);
  Serial.print(" ");
  Serial.print(rangelimit);
  Serial.print(" ");

  // Get I2S data and place in data buffer
  size_t bytesIn = 0;
  esp_err_t result = i2s_read(I2S_PORT, &sBuffer, bufferLen, &bytesIn, portMAX_DELAY);

  if (result == ESP_OK)
  {
    // Read I2S data buffer
    int16_t samples_read = bytesIn / 8;
    if (samples_read > 0) {
      float mean = 0;
      for (int16_t i = 0; i < samples_read; ++i) {
        mean += (sBuffer[i]);
      }

      // Average the data reading
      mean /= samples_read;

      // Print to serial plotter
      Serial.println(mean);
 
    }
  }
}
arduino ino file download:
.zip   INMP441.zip (Size: 1.1 KB / Downloads: 953)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   INMP441.ino.merged.zip (Size: 187.09 KB / Downloads: 907)
demo use arduino serial plotter tool to detect microphone sound.
   

Print this item

  [arduino code examples for AS]-01 internet radio
Posted by: admin - 10-22-2024, 12:39 AM - Forum: KinCony AS - No Replies

Code:
/*
  Simple Internet Radio Demo
  esp32-i2s-simple-radio.ino
  Simple ESP32 I2S radio
  Uses MAX98357 I2S Amplifier Module
  Uses ESP32-audioI2S Library - https://github.com/schreibfaul1/ESP32-audioI2S
*/

// Include required libraries
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"

// Define I2S connections AS
#define I2S_DOUT  8
#define I2S_BCLK  7
#define I2S_LRC   6

// Create audio object
Audio audio;

// Wifi Credentials
String ssid =    "KinCony";
String password = "a12345678";

void setup() {

  // Start Serial Monitor
  Serial.begin(115200);

  // Setup WiFi in Station mode
  WiFi.disconnect();
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid.c_str(), password.c_str());

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  // WiFi Connected, print IP to serial monitor
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println("");

  // Connect MAX98357 I2S Amplifier Module
  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);

  // Set thevolume (0-100)
  audio.setVolume(10);

  // Connect to an Internet radio station (select one as desired)
  audio.connecttohost("http://vis.media-ice.musicradio.com/CapitalMP3");
  //audio.connecttohost("mediaserv30.live-nect MAX98357 I2S Amplifier Module
  //audio.connecttohost("www.surfmusic.de/m3u/100-5-das-hitradio,4529.m3u");
  //audio.connecttohost("stream.1a-webradio.de/deutsch/mp3-128/vtuner-1a");
  //audio.connecttohost("www.antenne.de/webradio/antenne.m3u");
  //audio.connecttohost("0n-80s.radionetz.de:8000/0n-70s.mp3");

}

void loop()

{
  // Run audio player
  audio.loop();

}

// Audio status functions

void audio_info(const char *info) {
  Serial.print("info        "); Serial.println(info);
}
void audio_id3data(const char *info) { //id3 metadata
  Serial.print("id3data     "); Serial.println(info);
}
void audio_eof_mp3(const char *info) { //end of file
  Serial.print("eof_mp3     "); Serial.println(info);
}
void audio_showstation(const char *info) {
  Serial.print("station     "); Serial.println(info);
}
void audio_showstreaminfo(const char *info) {
  Serial.print("streaminfo  "); Serial.println(info);
}
void audio_showstreamtitle(const char *info) {
  Serial.print("streamtitle "); Serial.println(info);
}
void audio_bitrate(const char *info) {
  Serial.print("bitrate     "); Serial.println(info);
}
void audio_commercial(const char *info) { //duration in sec
  Serial.print("commercial  "); Serial.println(info);
}
void audio_icyurl(const char *info) { //homepage
  Serial.print("icyurl      "); Serial.println(info);
}
void audio_lasthost(const char *info) { //stream URL played
  Serial.print("lasthost    "); Serial.println(info);
}
void audio_eof_speech(const char *info) {
  Serial.print("eof_speech  "); Serial.println(info);
}
arduino ino file download:
.zip   internet-radio.zip (Size: 1.15 KB / Downloads: 854)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   internet-radio.ino.merged.zip (Size: 849.07 KB / Downloads: 822)
just make sure replace wifi router's ssid and password by yourself.

Print this item

  Server16 raspberry pi
Posted by: Saif Kitany - 10-21-2024, 06:28 PM - Forum: KinCony Server-Mini / Server-16 Raspberry Pi4 relay module - Replies (4)

Hello kincony technical team support ,

I Have H32b controller, my question is like this:

If I purchase server16 raspberry pi iot getway, then can i by node red to control h32b with a diagram that stand on my requirements?

For example:

My h32b is to control electrical windows in my home. So i want for example to open:

1. Window number 1at 5%
2. Window number 2 at 10%
3window number 3 at 100%
.
.
.
Etc…

Print this item

  Like the A6 but more 0-10V outputs
Posted by: tarajas - 10-21-2024, 04:45 PM - Forum: Extender module - Replies (6)

Hi,

Basically none of the dev boards offerred by Kincony have more 0-10V outputs than 2, while also having SSR digital outputs, instead of mechanical relays right?

So the only way is to buy at least minimum an A6 board (it has the I2C port needed for the extenders), then use an extender right? Which extender should I go for?

For the the SSR outputs are the main focus and multiple 0-10V outputs as well.

Print this item

  How to control RGBW 5pin led strip with A16 controller
Posted by: Karnek - 10-21-2024, 08:12 AM - Forum: KC868-A16 - Replies (18)

Hi!

Can someone guide me how can I controll 5pin RGBW SMD 5050 led strip ( not addressable LEDs, total of ~25meters long, 5pcs x 5meters, 12v )

using A16 board & Home assistant ideally?




Attached Files Thumbnail(s)
   
Print this item

  Max PWM frequency
Posted by: kepten - 10-19-2024, 07:49 PM - Forum: B16M - Replies (16)

Hi, does the B16M board support dimming LEDs with 20kHz PWM (up to 10A/channel load)? If not, what is the maximum PWM frequency that can be used without overheating/burning the MOSFET/driver/microcontroller/etc?
Regards,
Robert

Print this item