-
Notifications
You must be signed in to change notification settings - Fork 8
Code
- TFT_eSPI
- DHT sensor
- Adafruit PWM Servo Driver Library
- Adafruit Zero I2S library
- PubSubClient
- SimpleTimer
- WiFiManager
- Adafruit_Sensor
- ArduinoJson
-
server_ip
: IP address of the camera server. -
server_port
: Port number of the camera server. -
ota_host_name
: Hostname for OTA updates. -
SERVOMIN
: Minimum pulse length count for servo control. -
SERVOMAX
: Maximum pulse length count for servo control. -
USMIN
: Minimum pulse length in microseconds. -
USMAX
: Maximum pulse length in microseconds. -
SERVO_FREQ
: Frequency of PWM signals for servo control. -
temperaturaCritica
: Critical threshold temperature for temperature sensor task.
-
preferences
: Object for managing preferences using EEPROM. -
address
: Index in EEPROM for storing a value. -
touchPadThreshold
: Threshold value for touchpad sensitivity. - Task handles for various tasks in the project.
-
setup()
: Initializes components such as temperature sensor, camera, SD card, WiFi connection, and servo motor. -
StreamVideoTask()
: Streams video from the camera. -
AnimationTask()
: Handles animation sequences. -
TouchTask()
: Handles touchpad input. -
temp_sensorTask()
: Monitors temperature. -
EmotionTask()
: Manages emotional states. -
loop()
: Handles OTA updates. -
configModeCallback()
: Callback for WiFiManager when failing to connect to a network.
- Utilizes libraries for MQTT communication (PubSubClient), WiFi management (WiFiManager), and EEPROM storage.
- Includes UI interactions for displaying text on the screen.
Defines a class Emotion
and a struct Activity
for managing emotional states and activities.
-
Emotion()
: Constructor for initializing emotional parameters. -
void begin(uint8_t happiness, uint8_t tiredness, uint8_t anger, uint8_t sadness, uint8_t fear)
: Initializes emotional parameters. -
void addActivity(uint8_t emotion, int points, void (*function)())
: Adds an activity associated with a specific emotion. -
std::vector<uint8_t> calculatePriority()
: Calculates and returns prioritized emotions based on current emotional states.
-
uint8_t emotion
: Emotion associated with the activity. -
int points
: Points associated with the activity. -
void (*function)()
: Function pointer associated with the activity.
Implements methods of the Emotion
class for managing emotional states and activities.
-
Emotion::Emotion()
: Constructor implementation. -
void Emotion::begin(uint8_t happiness, uint8_t tiredness, uint8_t anger, uint8_t sadness, uint8_t fear)
: Initializes emotional parameters. -
std::vector<uint8_t> Emotion::calculatePriority()
: Calculates prioritized emotions based on emotional states.
- Provides structured management of emotional states and activities.
- Allows dynamic adjustments based on emotional states.
Defines a class Weather
and a struct WeatherData
for fetching weather data from an API.
-
Weather(String apiKey)
: Constructor for initializing with an API key. -
WeatherData getWeather(int units)
: Fetches weather data based on specified units.
-
float temperature
: Temperature data. -
int units
: Units of temperature (0 for standard, 1 for metric, 2 for imperial). -
String weatherMain
: Main weather condition. -
String weatherIcon
: Weather icon.
Implements methods of the Weather
class for fetching weather data from an API.
-
Weather::Weather(String apiKey)
: Constructor implementation. -
String Weather::getCoordinates()
: Fetches location coordinates. -
WeatherData Weather::getWeather(int units)
: Fetches weather data based on location and specified units.
- Provides a convenient interface for accessing weather data from an API.
- Supports different units for temperature measurement.
Defines a class MqttHandler
for MQTT communication.
-
MqttHandler()
: Constructor for initializing MQTT handler. -
void begin(const char* mqtt_server)
: Initializes MQTT handler with specified MQTT server. -
void loop()
: Handles MQTT connection and message processing. -
void publish(const char* topic, const char* payload)
: Publishes a message to the specified MQTT topic. -
void setCallback(MQTT_CALLBACK_SIGNATURE)
: Sets the callback function for incoming MQTT messages.
-
WiFiManager wifiManager
: Manages WiFi connections. -
WiFiClient espClient
: Manages MQTT server connection. -
PubSubClient mqttClient
: Facilitates MQTT communication. -
SimpleTimer timer
: Timer for internal use. -
const char* mqtt_server
: MQTT server address. -
long lastReconnectAttempt
: Timestamp of last reconnect attempt. -
bool shouldSaveConfig
: Flag for saving WiFi configuration.
-
void setupWiFi()
: Sets up WiFi connection. -
void reconnect()
: Reconnects to MQTT server. -
void saveConfigCallback()
: Callback for saving WiFi configuration.
Implements methods of the MqttHandler
class for MQTT communication.
-
MqttHandler::MqttHandler()
: Constructor implementation. -
void MqttHandler::begin(const char* mqtt_server)
: Initializes MQTT handler with specified MQTT server. -
void MqttHandler::loop()
: Handles MQTT connection and message processing. -
void MqttHandler::publish(const char* topic, const char* payload)
: Publishes a message to the specified MQTT topic. -
void MqttHandler::setCallback(MQTT_CALLBACK_SIGNATURE)
: Sets the callback function for incoming MQTT messages. -
void MqttHandler::setupWiFi()
: Sets up WiFi connection. -
void MqttHandler::reconnect()
: Reconnects to MQTT server. -
void MqttHandler::saveConfigCallback()
: Callback for saving WiFi configuration.
- Provides an easy-to-use interface for integrating MQTT communication into ESP32 projects.
- Handles MQTT connection and message processing efficiently.
Defines various animations for a graphical display using the TFT_eSPI
library.
-
idle_eyes()
: Animation function for idle eyes. -
close_eyes()
: Animation function for closing eyes. -
wink_eyes()
: Animation function for winking eyes. -
sleep_eyes()
: Animation function for sleeping eyes. -
high_temperature_anim()
: Animation function for displaying high temperature. -
alarm_anim()
: Animation function for displaying an alarm.
-
extern TFT_eSPI tft
: External declaration of the TFT display object. -
extern TFT_eSprite eyes
: External declaration of the TFT sprite object for eyes animation. -
extern const unsigned int sreenW
: Constant for screen width. -
extern const unsigned int sreenH
: Constant for screen height. - `extern
int w_eyes`: Width of eyes.
-
extern int h_eyes
: Height of eyes. -
extern int close_h_eyes
: Height of closed eyes. -
extern int eyes_distance
: Distance between eyes. -
extern int x_eyeL
: X-coordinate of the left eye. -
extern int y_eyeL
: Y-coordinate of the left eye. -
extern int x_eyeR
: X-coordinate of the right eye. -
extern int y_eyeR
: Y-coordinate of the right eye. -
#define AA_FONT_SMALL NotoSansBold15
: Definition for small font. -
#define AA_FONT_LARGE NotoSansBold36
: Definition for large font.
This file contains implementations of animation functions declared in Animation.h
.
-
idle_eyes()
: Implements animation for idle eyes. -
close_eyes()
: Implements animation for closing eyes. -
wink_eyes()
: Implements animation for winking eyes. -
sleep_eyes()
: Implements animation for sleeping eyes. -
high_temperature_anim()
: Implements animation for displaying high temperature. -
alarm_anim()
: Implements animation for displaying an alarm.
- These functions manipulate the TFT sprite object
eyes
and the TFT display objecttft
to achieve visual effects. - Constants and variables declared in
Animation.h
are used to define positions and dimensions of graphical elements on the screen.
Defines configurations and functions related to the microphone module.
-
I2S_PORT
: I2S port number. -
I2S_SAMPLE_RATE
: Sample rate for I2S. -
I2S_SAMPLE_BITS
: Sample bits for I2S. -
I2S_READ_LEN
: Length of data read from I2S. -
RECORD_TIME
: Recording time in seconds. -
I2S_CHANNEL_NUM
: Number of I2S channels. -
FLASH_RECORD_SIZE
: Size of flash record. -
filename
: Name of the recording file. -
headerSize
: Size of WAV header.
-
extern File file
: External declaration of SPIFFS file object. -
extern bool isWIFIConnected
: External declaration of WiFi connection status.
-
SPIFFSInit()
: Initializes SPIFFS and opens the recording file. -
i2sInit()
: Initializes I2S configuration. -
i2s_adc_data_scale()
: Scales ADC data. -
i2s_adc()
: Task function for reading ADC data. -
example_disp_buf()
: Displays buffer content (for debugging). -
wavHeader()
: Generates WAV header. -
listSPIFFS()
: Lists files in SPIFFS. -
uploadFile()
: Uploads recording file to server.
Implements functions declared in Microphone_h.h
.
-
SPIFFSInit()
: Initializes SPIFFS, opens recording file, and writes WAV header. -
i2sInit()
: Initializes I2S configuration. -
i2s_adc_data_scale()
: Scales ADC data for writing to file. -
i2s_adc()
: Task function for reading ADC data and writing to file. -
example_disp_buf()
: Displays buffer content for debugging. -
wavHeader()
: Generates WAV header. -
listSPIFFS()
: Lists files in SPIFFS. -
uploadFile()
: Uploads recording file to server using HTTP POST request.
- Error handling is included for file operations and HTTP requests.
- WAV header generation ensures proper formatting for WAV files.
-
uploadFile()
sends recording file to server using Wit.ai API for speech recognition.
Defines a class SDManager
and declares functions for reading from and writing to an SD card using the SD_MMC
library.
-
SD_MMC_CMD
,SD_MMC_CLK
,SD_MMC_D0
: Pins for SD_MMC communication.
-
initSD()
: Initializes SD card and creates file if it doesn't exist. -
listDir()
: Lists contents of directory on SD card. -
createDir()
: Creates new directory on SD card. -
removeDir()
: Removes directory from SD card. -
readFile()
: Reads content of file from SD card. -
writeFile()
: Writes data to file on SD card. -
appendFile()
: Appends data to existing file on SD card. -
renameFile()
: Renames file on SD card. -
deleteFile()
: Deletes file from SD card. -
testFileIO()
: Performs file I/O operations for testing. -
findSSIDInFile()
: Searches for specific SSID in file on SD card. -
existFile()
: Checks if file exists on SD card.
Implements functions declared in SD_READ_WRITE_H
.
-
DEBUG_TAG
: Debug tag for logging.
- Each function defined in the header file is implemented here, handling various file operations such as reading, writing, listing directories, creating directories, removing directories, renaming files, appending data to files, and more.
- Error handling and logging are included for feedback on success or failure of each operation.
-
SDManager
class provides interface for interacting with SD card. - Error handling ensures robustness when accessing SD card.
- Code is well-commented for easy understanding of functionality and usage.
Defines a class CameraUploader
for uploading images captured from a camera module to a server over Wi-Fi.
-
Arduino.h
: Arduino core library. -
esp_camera.h
: ESP32 camera library. -
WiFiManager.h
: Library for handling Wi-Fi connection.
-
Constructor: Initializes a
CameraUploader
object with server IP address and port.- Parameters:
-
serverIp
: Server IP address. -
serverPort
: Server port number.
-
- Parameters:
-
begin()
: Initializes serial communication and connects to Wi-Fi usingWiFiManager
. -
uploadImage()
: Uploads image to server if client is connected. -
Private Members:
-
serverIp
: Server IP address. -
serverPort
: Server port number. -
client
:WiFiClient
object for handling Wi-Fi client connection.
-
-
Private Methods:
-
cameraSetup()
: Sets up camera module with specified configurations.
-
-
CameraUploader
class manages process of capturing images from camera module and uploading to server over Wi-Fi. -
begin()
method initiates Wi-Fi connection usingWiFiManager
, allowing device to connect to Wi-Fi network. -
uploadImage()
method attempts to upload image to server if client connection is available. -
cameraSetup()
method configures various parameters of camera module such as brightness, contrast, saturation, special effects, white balance, exposure control, etc. - Error handling is included for cases where HTTP request fails, returning appropriate error message.
Defines a class ChatGPT
for interacting with OpenAI GPT (Generative Pre-trained Transformer) model for generating text-based responses.
-
Arduino.h
: Arduino core library. -
WiFiManager.h
: Library for handling Wi-Fi connection. -
HTTPClient.h
: Library for making HTTP requests.
-
Constructor: Initializes a
ChatGPT
object. -
begin()
: Begins Wi-Fi connection usingWiFiManager
. -
setApiKey(String apiKey)
: Sets API key required for accessing OpenAI API. -
setModel(String modelName)
: Sets model to be used for generating responses. -
generateResponse(String input)
: Generates response
based on input text.
-
Private Members:
-
apiKey
: API key for accessing OpenAI API. -
selectedModel
: Selected model for generating responses.
-
-
Private Methods:
-
sendRequest(String input)
: Sends HTTP request to OpenAI API with input text and retrieves response.
-
-
ChatGPT
class provides interface for interacting with OpenAI GPT model to generate text responses based on user input. -
begin()
method initiates Wi-Fi connection usingWiFiManager
. -
setApiKey()
method allows user to set API key required for accessing OpenAI API. -
setModel()
method allows user to specify model to be used for generating responses (e.g.,MODEL_DAVINCI
orMODEL_CURIE
). -
generateResponse()
method takes user input as prompt and sends HTTP request to OpenAI API to generate response based on selected model. - Error handling is included to handle cases where HTTP request fails, returning appropriate error message.
- Users can use provided example code to integrate
ChatGPT
class into their Arduino projects and interact with GPT model to generate text responses.
ImageConverter565 is a tool used for converting images to a format suitable for display on a screen.
- Download ImageConverter565.
- Open the tool.
- Select the image you want to convert.
- Choose "Save As" and select ".c" as the file format.
- Set the target board to "chipKIT / Arduino Due".
- Adjust the name and resize the image as needed.
- Save the image.
- Change the file extension to ".h" to use it in your project.
To convert a font vlw file to a byte array, follow these steps:
-
Use the online tool File to Hex Converter.
-
Paste the contents of the font vlw file into the converter.
-
Copy the generated byte array.
-
In your Arduino sketch, create a new tab and paste the byte array.
-
Add two lines at the beginning of the byte array with a unique font name:
const uint8_t fontName[] PROGMEM = {
-
At the end of the byte array, add:
};
-
Include the tab in your main sketch using
#include "FileName.h"
.