Gavin
Published

ChatGPT Recorder & Monitor

Record all chatgpt conversations, store them in the SD card, and display them on the screen.

AdvancedFull instructions provided1,770
ChatGPT Recorder & Monitor

Things used in this project

Hardware components

WizFi360-EVB-Pico
WIZnet WizFi360-EVB-Pico
×1
RP2040
Raspberry Pi RP2040
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

ChatGPT Recorder & MonitorChatGPT_Recorder_&_Monitor_schmatic.pdf

ChatGPT_Recorder_&_Monitor_schmatic.pdf

Code

ChatGPT Recorder & Monitor_Arduino_Code

Arduino
Todolist Sync Monitor_Arduino_Code
/*
 WizFi360 example: Cloud_Printer_ChatGPT
*/

#include "WizFi360.h"
#include "html_page.h"
#include <LittleFS.h>
#include <SD.h>

#include <Arduino_GFX_Library.h>
Arduino_GFX *tft = create_default_Arduino_GFX();

File myFile;

#include <PNGdec.h>
PNG png;
uint8_t image_x;
uint8_t image_y;

//#define debug_msg
#define buttonPin 14
#define ledPin    12
#define backLightPin 22
#define sdCsPin 17

typedef enum 
{
  do_chatgpt_display = 0,
  do_webserver_index,
  do_webserver_js,
  send_chatgpt_request,
  get_chatgpt_list,
}STATE_;
STATE_ currentState;

/* Wi-Fi info */
char ssid[] = "wiznet";       // your network SSID (name)
char pass[] = "*******";   // your network password
IPAddress ip;

char chatgpt_server[] = "api.openai.com"; 
char chatgpt_token[] = "sk**********SfTy0anqEt9dluD2";

uint8_t data_now = 0; 
String json_String; 
uint16_t dataStart = 0;
uint16_t dataEnd = 0;
String dataStr;
uint16_t dataLen = 0;

String SD_str;
String chatgpt_Q;
String chatgpt_A;
uint16_t chatgpt_num = 0;

// variables will change:
bool buttonState = false;

int status = WL_IDLE_STATUS;  // the Wifi radio's status

WiFiClient client1;
WiFiClient client2;
WiFiServer server(80);
    
void setup() {
  // initialize serial for debugging  
  Serial.begin(115200);

  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT); 
  digitalWrite(ledPin, LOW); 
           
  tft->begin();
  tft->fillScreen(WHITE);
  pinMode(backLightPin, OUTPUT); 
  digitalWrite(backLightPin, HIGH); 

  display_logo(240,120,BLACK);
  image_x = 217;
  image_y = 165;
  display_chatgpt_icon(1);
  display_wifi_status(240,250);
  
  // initialize serial for WizFi360 module
  Serial2.setFIFOSize(4096);
  Serial2.begin(2000000);
  WiFi.init(&Serial2);
  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }
  display_wifi_status(240,250);

  SD.begin(sdCsPin);
  SD_str = read_from_sd("chatgpt_record.txt");
  
  dataStart = json_String.lastIndexOf("[N]{") + strlen("[N]{");
  dataEnd = json_String.indexOf("}\r\n", dataStart); 
  chatgpt_num = (json_String.substring(dataStart+4, dataEnd)).toInt()+1;
  Serial.println(chatgpt_num); 
  
  //SD.remove("chatgpt_record.txt");
  
  // print your WiFi shield's IP address
  ip = WiFi.localIP();
  currentState = do_chatgpt_display;
  attachInterrupt(digitalPinToInterrupt(buttonPin), onChange, CHANGE); 
  // start the web server on port 80
  server.begin();
}

void loop(){

}

Credits

Gavin

Gavin

24 projects • 23 followers
Make it Funny.

Comments