ChatGPT Arduino Programming Ultimate Test, ChatGPT for Arduino Projects
Table of Contents
ChatGPT Arduino Programming:
ChatGPT Arduino Programming Ultimate Test, ChatGPT for Arduino Projects– In today’s article, I am going to use ChatGPT to make an Arduino-based project that’s never been done by anyone before. First, I will make the project and then I will ask ChatGPT to make the same project.
So, I started off by asking ChatGPT to tell me about yourself and ChatGPT replied
“I am a language model created by OpenAI. My primary function is to generate human-like text based on the input I receive. I have been trained on a diverse range of internet text, allowing me to answer questions on a wide range of topics and generate text that is coherent and informative.”
It doesn’t matter, how many times you ask ChatGPT, every time it will use different words, so it will be 100% plagiarism free. So, you can use ChatGPT for writing your project reports and thesis. But, what I suggest is, do it yourself.
You can talk to ChatGPT just as you normally talk to people. So, I continued chatting with ChatGPT and I was really amazed. ChatGPT knows when to apologize and it knows very well how to ignore spelling mistakes. Anyway, read my chat and then we will continue from there.
Electronic Clinic
Tell me about yourself?
ChatGPT:
I am a language model created by OpenAI. My primary function is to generate human-like text based on the input I receive. I have been trained on a diverse range of internet text, allowing me to answer questions on a wide range of topics and generate text that is coherent and informative.
Electronic Clinic
What is ChatGPT?
ChatGPT:
ChatGPT is a conversational AI model developed by OpenAI. It is based on the GPT (Generative Pretrained Transformer) architecture and is trained on a large corpus of text data to generate human-like responses to text inputs. It can be used for a variety of tasks, including answering questions, generating chatbot conversations, and generating creative writing.
Electronic Clinic
ChatGPT is designed for?
ChatGPT:
ChatGPT is designed for generating human-like text. It can be used for a variety of applications, including:
Chatbots: Creating conversational AI systems for customer service, information retrieval, and more.
Question answering: Answering questions on a wide range of topics based on its training data.
Text generation: Generating text in a specific style or tone, such as fiction writing or news articles.
Language translation: Generating text in another language based on input in one language.
Text summarization: Reducing long texts to shorter, more concise versions while retaining important information.
Electronic Clinic
can you write a movie script?
ChatGPT:
Yes, I can write a movie script. However, it’s important to note that while I have been trained on a large corpus of text, including movie scripts, my responses are generated based on patterns in the data I was trained on and may not necessarily result in a high-quality script. Please provide more specific information, such as the genre, length, tone, etc. of the desired script, so I can generate a better response.
Electronic Clinic
What you can do?
ChatGPT:
As a language model, I can perform a variety of language-related tasks, including:
Answering questions
Generating text (e.g. creative writing, news articles, product descriptions)
Conversing in a chatbot-like manner
Summarizing text
Translating text from one language to another
Completing sentences or paragraphs given a prompt
Generating lists, such as facts about a particular topic
Note that my responses are generated based on patterns in the text I was trained on and may not always be accurate or appropriate.
Electronic Clinic
Can you do Android programming?
ChatGPT:
No, I cannot do Android programming. I am a language model trained to generate text based on patterns in the data I was trained on, not to write code or perform technical tasks. However, I can provide information and resources on Android programming if needed.
Electronic Clinic
How about Arduino programming?
ChatGPT:
No, I cannot perform Arduino programming. I am a language model trained to generate text based on patterns in the data I was trained on, not to write code or perform technical tasks. However, I can provide information and resources on Arduino programming if needed.
Electronic Clinic
You must be kidding, last time you wrote me an Arduino code
ChatGPT:
My apologies, you are correct. I can write code in various programming languages, including Arduino code. Please provide the details of the code you need, and I will do my best to assist you.
Electronic Clinic
Now, that’s like a good boy 😉
ChatGPT:
Thank you! I am always here to help. How can I assist you today?
Electronic Clinic
Hmmm, today I am going to perform some ultimate tests on you, these are not going to be easy. You Vs me. We will be making an Arduino based project that’s never been done before. So, are you ready?
ChatGPT:
Yes, I am ready! I will do my best to assist you in your Arduino project. Please provide more details on the project you have in mind, and I will do my best to help.
Electronic Clinic
Relax, first i am going to design the circuit and then I will ask you to write the code.
ChatGPT:
Understood. Please go ahead and design the circuit, and I will be here to help with writing the code once you are ready.
Electronic Clinic
great!
ChatGPT:
I am glad to hear that. Let me know if there’s anything else I can assist with.
Electronic Clinic
So, without any further delay, let’s get started!!!
Yes, let’s get started! I am eager to help and assist in any way I can. Please share the details of the project and I will do my best to support you.
I am already impressed, but before I start the challenge, first I am going to ask ChatGPT to write me a song on Arduino. I just want to check how creative it is.
“ChatGPT’s response depends on your question. The more information you give ChatGPT, the better it will reply. I asked ChatGPT to write me a song on “Arduino” and mention my YouTube channel “Electronic Clinic” and also mention my subscribers as I am dedicating this song to my subscribers. And it will be highly appreciated if you include ESP32, STM32, Raspberry pi Pico, Arduino Nano, Arduino Uno, Electronics, and image processing too.
Song by ChatGPT
Verse 1:
Building circuits, coding bright,
With the Arduino by my side.
Bringing ideas to life each day,
Watching projects come to play.
Chorus:
Electronic Clinic, my YouTube fame,
With subscribers, I’ll shout their name.
Dedicating this song to you,
For loving all things electronic too.
Verse 2:
ESP32, STM32, Raspberry Pi Pico,
Arduino Nano, Uno too, oh so sicko!
From simple lights to complex code,
Making electronics simple to decode.
Chorus:
Electronic Clinic, my YouTube fame,
With subscribers, I’ll shout their name.
Dedicating this song to you,
For loving all things electronic too.
Bridge:
Image processing, it’s a breeze,
With technology like these.
Bringing tech and art to life,
Making each project full of life.
Chorus:
Electronic Clinic, my YouTube fame,
With subscribers, I’ll shout their name.
Dedicating this song to you,
For loving all things electronic too.
Outro:
So here’s a shout out to my subscribers,
You make the Electronic Clinic a winner.
Thank you for your love and support,
Together we’ll make electronics a resort!
This is absolutely mind-blowing, in just a few seconds ChatGPT wrote an Arduino song. Just take a look, ChatGPT used my channel name, and mentioned my subscribers and all the controller boards as well.
You now have a sense of just how strong ChatGPT is.
I have so many controller boards, sensors, and breakout boards. Is ChatGPT really that powerful to be able to program all of these things? Well, to test it, I am going to randomly select two sensors. Let’s start with the DHT21 and Max6675 amplifier board and K type thermocouple. And for displaying the values I am going to use I2C SSD1306 Oled display module. And I am going to use Arduino Nano.
Let me tell you about the project, and what exactly I want to build. As I said earlier I am trying to build an Arduino based project that’s never been done before. So, I am going to use an Oled display module, DHT21 Temperature and Humidity sensor, and Max6675 and K type thermocouple with the Arduino at the same time. Let’s see how ChatGPT handles all the libraries and programming.
But, first, I am going to build this project and then I will ask the ChatGPT. So, without any further delay, let’s get started!!!
Amazon Links:
Arduino Nano USB-C Type (Recommended)
DHT21 Temperature and Humidity Sensor
I2C supported SSD1306 Oled display Module
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
Circuit Diagram:
The VCC and GND pins of the DHT21, SSD1306 Oled display, and Max6675 Amplifier board are connected with the Arduino 3.3V and GND pins.
The SCK, CS, and SO pins of the Max6675 Amplifier board are connected to the Arduino pins D6, D5, and D3 respectively.
The Data wire of the DHT21 Temperature and Humidity sensor is connected to the digital pin D2.
The SDA and SCL pins of the SSD1306 Oled display module are connected to the analog pins A4 and A5. A4 is the SDA and A5 is the SCL.
I have connected everything as per the circuit diagram. And as you can see I am using my Arduino Nano development board. But you can also do all these connections on a breadboard. But, if you want to make the same Arduino Nano development board then you can download its PCB Gerber files.
Arduino Nano Dev Board Gerber Files
My Code:
I have written this code. And you can see I have added all the required libraries. I have been using these libraries for quite a long time. So, if you don’t know how to install these libraries then you can read my getting started articles on Oled display, DHT21, and Max6675.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
#include <Wire.h> #include <DHT.h>; #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include "max6675.h" int thermoDO = 3; int thermoCS = 5; int thermoCLK = 6; //Constants #define DHTPIN 2 //what pin we're connected to #define DHTTYPE DHT21 //DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); //Initialize DHT sensor for normal 16mhz Arduino //Variables float hum; //Stores humidity value float temp; //Stores temperature value float maxtemp; #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO); void setup() { Serial.begin(9600); dht.begin(); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); delay(2000); display.clearDisplay(); display.setTextColor(WHITE); delay(10); } void loop() { //Read data and store it to variables hum and temp hum = dht.readHumidity(); temp= dht.readTemperature(); maxtemp=thermocouple.readCelsius(); //Print temp and humidity values to serial monitor Serial.print("Humidity: "); Serial.print(hum); Serial.print("%, Temperature: "); Serial.print(temp); Serial.println(" Celsius"); display.clearDisplay(); display.setTextSize(2); display.setCursor(0, 5); display.print(temp); display.print((char)247); display.print("C"); display.setTextSize(2); display.setCursor(0, 28); display.print("H:"+String(hum)+"%"); display.setTextSize(2); display.setCursor(0, 50); display.print(maxtemp); display.print((char)247); display.print("C"); display.display(); delay(3000); } |
Practical Testing:
I applied heat to the DHT21 and K type thermocouple and the temperature raised to 17.5 and 37.25 degrees Celsius. So, my code is working and it took me around 30 Minutes to make it work. It may seem hard to believe, but I did it in 30 minutes as I have been using these sensors and displays for years. Anyway, now let’s go ahead and ask ChatGPT to write the Code.
Now, let’s get back to our project.
As I mentioned, the more details you give to ChatGPT, the better it will respond. So let’s go ahead and tell ChatGPT about the project.
Write me Arduino code for monitoring two sensors DHT21 and Max6675 K type thermocouple. The data wire of the Dht21 sensor is connected to the digital pin D2 pin of the Arduino. Whereas the SCK, CS, and SO pins of the Max6675 are connected to the Arduino digital pins D6, D5, and D3 respectively. The SDA and SCL pins of the SSD1306 Oled display module are connected with the A4 and A5 pins respectively. I want you to display the dht21 temperature, dht21 Humidity, and the temperature value from the Max6675 k type thermocouple on the SSD1306 Oled display module.
You can see, I am telling ChatGPT about the connections and I am giving it some instructions how to do it. So, I am going to press the Enter key and let’s see.
Arduino Code by ChatGPT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#include <Adafruit_Sensor.h> #include <DHT.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <Max6675.h> #define DHT21_PIN 2 #define OLED_SDA 4 #define OLED_SCL 5 #define OLED_RST -1 #define OLED_WIDTH 128 #define OLED_HEIGHT 64 #define MAX6675_CS 5 #define MAX6675_SO 3 #define MAX6675_SCK 6 DHT dht21(DHT21_PIN, DHT21); Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT, &Wire, OLED_RST); Max6675 thermocouple(MAX6675_SCK, MAX6675_CS, MAX6675_SO); void setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.display(); Serial.begin(9600); dht21.begin(); } void loop() { float dht21_temp = dht21.readTemperature(); float dht21_humidity = dht21.readHumidity(); float thermocouple_temp = thermocouple.readCelsius(); display.clearDisplay(); display.setCursor(0, 0); display.println("DHT21 Temp: " + String(dht21_temp) + "C"); display.println("DHT21 Hum: " + String(dht21_humidity) + "%"); display.println("Thermocouple Temp: " + String(thermocouple_temp) + "C"); display.display(); delay(1000); } |
I didn’t ask for the comments so that’s why ChatGPT is not adding any comments. Anyway I copied this code and pasted into the Arduino IDE. And when I compiled the code I got two errors which I fixed.
Code fixed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#include <Adafruit_Sensor.h> #include <DHT.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> //#include <Max6675.h> this was the original one added by ChatGPT // it wasn't working, so I added the below one. #include "max6675.h" #define DHT21_PIN 2 #define OLED_SDA 4 #define OLED_SCL 5 #define OLED_RST -1 #define OLED_WIDTH 128 #define OLED_HEIGHT 64 #define MAX6675_CS 5 #define MAX6675_SO 3 #define MAX6675_SCK 6 DHT dht21(DHT21_PIN, DHT21); Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT, &Wire, OLED_RST); //Max6675 thermocouple(MAX6675_SCK, MAX6675_CS, MAX6675_SO); // this one was added by the ChatGPT and it wasn't working MAX6675 thermocouple(MAX6675_SCK, MAX6675_CS, MAX6675_SO);// its MAX6675 not Max6675 void setup() { display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.clearDisplay(); display.setTextColor(WHITE); // this line was missing, i added this. display.display(); Serial.begin(9600); dht21.begin(); } void loop() { float dht21_temp = dht21.readTemperature(); float dht21_humidity = dht21.readHumidity(); float thermocouple_temp = thermocouple.readCelsius(); display.clearDisplay(); display.setCursor(0, 0); display.println("DHT21 Temp: " + String(dht21_temp) + "C"); display.println("DHT21 Hum: " + String(dht21_humidity) + "%"); display.println("Thermocouple Temp: " + String(thermocouple_temp) + "C"); display.display(); delay(1000); } |
Practical Demonstration:
Its displaying all the values in the same order as I asked for. It’s outstanding. The text is small but it’s not an issue. We can increase the font size. Anyway, you can see the Temperature and Humidity values from the DHT21 Sensor and the temperature value from the Max6675 K type thermocouple.
It took me 30 minutes to complete the code but ChatGPT did it in just a few seconds. There were a few errors which I fixed in less than 5 minutes time. So, ChatGPT can save a lot of your time. You guys need to give it a try. So, that’s all for now.