Reference

Last revision 2026/01/26

This guide offers a complete reference for ESP32's I2S mode, detailing audio and camera control APIs, including initialization, SD card operations, and media management.

API Description


  /**
   * @fn init
   * @brief Init function
   * @details Initialize I2S mode, I2S can be used as audio and camera controller in esp32
   * @param mode I2S mode, AUDIO or CAMERA 
   * @return Data of bool type
   * @retval true Init succeeded
   * @retval false Init failed
   */
  bool init(uint8_t mode);

  /**
   * @fn SDCardInit
   * @brief Mount SD card
   * @return Data of bool type
   * @retval true Init succeeded
   * @retval false Init failed
   */
  bool SDCardInit(void);

  /**
   * @fn sendPhoto
   * @brief Send out the photo obtained from the camera via network
   */
  void sendPhoto(void);

  /**
   * @fn setSpeakersVolume
   * @brief Set speakers volume
   * @param volume Volume, range 0-99
   */
  void setSpeakersVolume(uint8_t volume);
  
  /**
   * @fn muteSpeakers
   * @brief Mute speakers
   */
  void muteSpeakers(void);

  /**
   * @fn setHeadphonesVolume
   * @brief Set headphones volume
   * @param volume Volume, range 0-99
   */
  void setHeadphonesVolume(uint8_t volume);
  
  /**
   * @fn muteHeadphones
   * @brief Mute headphones
   */
  void muteHeadphones(void);
  
  /**
   * @fn setFreamsize
   * @brief Set camera pixel
   * @param photoSize  optional (QQVGA,QQVGA2,QICF,HQVGA,QVGA,RGB555,GRAYSCALE)
   * @return Return the set pixel
   */
  uint8_t setFreamsize(uint8_t photoSize);

  /**
   * @fn setPixformat
   * @brief Set color depth
   * @param pixelFormat  RGB555(RGB565 true color), GRAYSCALE(grayscale image)
   * @return Return the set color depth
   */
  uint8_t setPixformat(uint8_t pixelFormat);

  /**
   * @fn snapshot
   * @brief Take photo
   * @param pictureFilename The name of the file to save picture
   */ 
  void snapshot(const char *pictureFilename);
  
  /**
   * @fn connectNet
   * @brief Connect to WIFI
   * @param ssid     WIFI name
   * @param password WIFI password
   */ 
  void connectNet(const char* ssid,const char* password);

  /**
   * @fn initPlayer
   * @brief init music player
   */
  void initPlayer();
  
  /**
   * @fn initRecorder
   * @brief Init recorder
   */
  void initRecorder();

  /**
   * @fn playMusic
   * @brief Play music
   * @param filename The name of the file used to play
   */
  void playMusic(const char *Filename);

  /**
   * @fn record
   * @brief record sound
   * @param filename he name of the file to save record
   */
  void record(const char *Filename);

  /**
   * @fn playerControl
   * @brief Control the music player
   * @param cmd Command to control music player
   * @n    PLAY   Begin or continue play music
   * @n    PAUSE  Pause play music
   * @n    STOP   Stop play music
   */
  void playerControl(uint8_t cmd);

  /**
   * @fn recorderControl
   * @brief Control the recorder
   * @param cmd Command to control recorder
   * @n   BEGIN  Begin recording
   * @n   STOP   Stop recording
   */
  void recorderControl(uint8_t cmd);
  
  /**
   * @fn SDcard_Init
   * @brief Initialize SD card
   * @param mountpoint SD card name
   */
  bool SDcard_Init(const char* mountpoint="/sdcard");

Compatibility Test:

MCU Support Not Support
FireBeetle-Board328P
FireBeetle-ESP32
FireBeetle-ESP8266

Was this article helpful?

TOP