Testing ChatGPT

Mods, feel free to move this if there is a better place for it.

I was curious how, if any, ChatGPT had progressed in building a working software/hardware project. I have recently gotten interested in Home Assistant and building ESPHome devices to work with it.

I installed HA on a Raspberry Pi 5 that wasn't doing anything useful and played around with it and its integration with Apple Home. It works as expected even if the UI is not particularly slick. There may be a fix for that.

Since I know basically nothing about how to set up an ESPHome device using YAML I decided that would be a good test for ChatGPT to help out a rank newbie. I gave it this prompt:
First I gave it some background info:

Me:
I have programmed and enabled the Home Assistant app on a Raspberry Pi 5. I successfully added two commercially available Matter devices.

ChatGPT:
Excellent — you’re well on your way! Setting up Home Assistant with Matter devices on a Raspberry Pi 5 is a strong foundation.

Can you tell me what you’d like to do next? For example:
• Are you having trouble pairing additional Matter devices?
• Do you want to integrate non-Matter devices (e.g., Zigbee, Z-Wave, Wi-Fi plugs, etc.)?
• Are you interested in controlling your Matter devices through Apple Home / Google Home / Alexa bridges?
• Or would you like to optimize your Home Assistant setup on the Pi 5 (performance, backups, dashboards, etc.)?
Once I know your next goal, I can walk you through the exact steps or configuration details.

Me:
I would like to make my own devices. I can start with something simple that flashes an onboard LED for example just to demonstrate success. I have an ESP32-c3 dev kit, an ESP32-s3 dev kit and a Raspberry Pi Pico 2W module that I can use for the project. I also Use Apple Home and if the new devices were usable with that it would be a bonus but my initial goal is to get something working with Home assistant. I have programmed the ESP devices with Arduino IDE and the Pico 2W in microPython using Thonny REPL. I also have the Raspberry Pi C++ SDK available to use. I'm looking for a pre-made project for one of those devices that just works and that I can study and modify.

ChatGPT gave me several suggestions about how I could use each of my Hardware platforms that I won't go into here unless someone is interested. It gave extensive code samples for each which I may test later. I picked one using the ESP32-C3 dev kit board.
I asked this question before starting, maybe giving away that I'm not a complete idiot:

Me:
One question before I try the ESP32-c3 example. My ESP has been programmed with an Arduino app. Do I need to return it to some initial condition before trying the example?

ChatGPT:
Good question — and an important one before you flash ESPHome.

The short answer is: no special “factory reset” is needed, but there are a few practical steps to make sure the transition from Arduino to ESPHome goes smoothly.

It proceeded to go into quite some detail about special cases that I won't reproduce here. I decided to just go ahead.
Then it provided the YAML.

esphome:
  name: c3-blinker
  friendly_name: C3 Blinker

esp32:
  board: esp32-c3-devkitm-1
  variant: ESP32C3

wifi:
  ssid: "YOUR_SSID"
  password: "YOUR_PASSWORD"

api:
ota:
logger:

output:
  - platform: gpio
    pin: GPIO8
    id: led_out

light:
  - platform: binary
    name: "C3 Onboard LED"
    output: led_out
    id: c3_led

interval:
  - interval: 1s
    then:
      - light.toggle: c3_led

which I loaded into the ESP32-C3 from the ESPHome Builder function in HA.

I got a couple of errors. I fed ChatGPT the errors and it gave me the corrections. That allowed HA to build the app and flash the board. I purposely left out configuring SSID and PASSWORD like a newbie might have done and told ChatGPT that the installation had been successful but the board remained offline. It correctly suggested that I might have left out SSID and PASSWORD.

Long story short, the board flashed the onboard LED on and off at a 1 second interval as promised. It appeared as a device in HA and allowed me to install it and put it in the dashboard.

The complete working YAML

esphome:
  name: c3-blinker
  friendly_name: C3 Blinker

esp32:
  board: esp32-c3-devkitm-1
  variant: ESP32C3
  framework:
    type: arduino


# Your Wi-Fi
wifi:
  ssid: "SSID"
  password: "PASSWORD"

api:
ota:
  platform: esphome
logger:

# On-board RGB LED is a single WS2812 on GPIO8
light:
  - platform: esp32_rmt_led_strip
    name: "C3 RGB LED"
    id: c3_rgb
    chipset: ws2812
    pin: GPIO8
    num_leds: 1
    rgb_order: GRB
    default_transition_length: 0s
    # optional new-style block if you want to specify channel:
    # rmt:
    #   channel: 0
    effects:
      - strobe:
          name: "Blink"
          colors:
            - state: true
              brightness: 60%
              red: 100%
              green: 10%
              blue: 10%
              duration: 500ms
            - state: false
              duration: 500ms

interval:
  - interval: 1s
    then:
      - if:
          condition:
            light.is_on: c3_rgb
          then:
            - light.turn_off: c3_rgb
          else:
            - light.turn_on:
                id: c3_rgb
                brightness: 60%
                red: 100%
                green: 10%
                blue: 10%

Thanks for the information. I use ChatGPT as a formatting and English style corrector. It can find some problems in code but you need to understand what is there. My problems are missed punctuation which it usually finds.

Possibly my ability to troubleshoot effectively helps me guide it to guiding me. I know a properly styled promo is crucial to good results.

Your WiFi credentials should be in a "Secrets" Yaml.
So you can use that as a rubber stamp for all sensors.
Top/right of the ESPHome page.


My first project was a temp/humidity sensor with a Wemos D1 mini (ESP8266) and htu21d I had lying around. Prepared with ESPHome.

esphome:
  name: temphum-sensor
  friendly_name: Temp/Hum Sensor

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "itBUNbIaGMprAmZRGUn4Wh1XOK0Qc3NiIOSy6rRhWYQ="

ota:
  - platform: esphome
    password: "f682baf44befc0bb14cc02af10fe0407"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Temphum-Sensor Fallback Hotspot"
    password: "DUT8u7GTEzyM"

captive_portal:

i2c:
  sda: 4
  scl: 5
  scan: true
  frequency: 400000

sensor:
  - platform: htu21d
    model: htu21d
    temperature:
      name: "Living Room Temperature"
    humidity:
      name: "Living Room Humidity"    

Then I made a weather station with BME280 an a Seeed Xiao ESP32C3.
Soldered a 3Ah LiPo battery to it and powered it with a 4volt/2W solar panel, directly on the USB-C jack. Battery hasn't been below 3.9V yet. Let me know if you want the Yaml.

Thanks for the tip. I have lots to learn about YAML.

Also thanks for posting your code. That will give me another example to study and learn from.

Making a design with circuitry and code often calls for maintenance, development, later. Using an unknown, given code You’ll stand flat there.

Being a code designer, help desk, since long, free given code by anybody else, dead friend or AI, will put You in trouble.

Of course. My goal was not to depend on ChatGPT for designs but to see what some well crafted prompts could get out of it.

Did your application use ESP-IDF instead of the Arduino platform? I understand the applications are much smaller.

Test and see is okey. However nearly all member posts from using AI ends up not working.

Computing is a growing field. Learning coding and exploring it leads forward. If nobody creates the future AI will not do it. AI rests on the past.

The simple Yaml code in HomeAssistant is basically asking ESPHome's Ai to write the code for you. I am sceptical regarding Ai, but I must say it works very well with the HA projects I have done.
This is the full code you give to ESPHome, to write the full code for a BME280 sensor.
Leo..

sensor:
  - platform: bme280_i2c
    temperature:
      name: "BME280 Temperature"
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x76

Of course AI doesn’t produce like bla bla in the wrong language all the time but still, no AI for me.

Once being the help desk in a media business matter I got an urgent phone call, a transmission of urgent data had halted. By phone the calling person, not an engineer, not a programmer, had to be instructed to very special things.

Get hold of a bread knife, unscrew port 2 DIN9 connector, move the connector to port 3. Then type Ctrl Q and then put the connector back to port 2 and do…..

AI might manage some small things, sometimes, but it’s not the future in programming, building systems.

Look, ChatGPT did his training several years ago. Esphome has ~12 updates per year with many breaking changes.
If you want any reasonable help from AI, you need to insist to verify every reply for your actual esphome/ha version. Otherwise you get just crap that doesn't compile.


This is what I get.

I tried a similar experiment with MicroPython and asked ChatGPT to give me the code to be able to display 7-segment style characters on a matrix display for a project that I am working on. I told it which controller I was using, which matrix display and that I wanted MicroPython code and it did a decent job of providing me with a working code example. I added it to my project it did allow me to display numeric characters on the matrix display. It allowed only a single fixed character size but it worked. I could ask the AI to generate smaller or larger characters and it would re-calculate within certain limits and present a new code example for another character size, but I didn't want to be adding several variants of the code to my project to get different character sizes.

I also wanted to be able to display segment style alphanumeric characters as well, so I asked the AI to generate code for a 13 or 16-segment display but it failed dismally. I tried several permutations of the prompt but nada. It stubbornly refused or kept providing me with 7-segment code. I guess that there are probably plenty of 7-segment examples online, but perhaps not so many 13-segment or 16-segment examples so perhaps it didn't have the "training" to fall back on.

As it happens, once I had studied and understood how the 7-segment code worked, I was able to expand on it and use it as the basis to develop functions that could display 13-segment style characters on the matrix, both numbers and upper case letters as well as in 5 character sizes by specifying a size parameter.

I think the experiment as useful and arguably the AI did give me a head start, but it could not be relied upon to do the whole job. An understanding of how the code works was still required in order to tailor and enhance the example to arrive at the final result, as well as to integrate it into the existing project. As a tool it seems that it AI can be used to augment a development effort, but it cannot replace the human developer nor eliminate the need for understanding programming techniques, verification and testing, or creative thinking.

Haven't done anything with HA or ESPHome yet although i have been thinking of integrating some Zigbee or Shelly type devices, but that's another project for another day.

HA and esphome are separate projects even if tightly integrated. Shelly Gen4 (C6) has zigbee and HA supports that, but esphome doesn't.

I enjoy not knowing how to complete a project. I enjoy discovering what each component needs. I enjoy trying, failing and learning. I enjoy thinking and dreaming about logic and algorithms. I enjoy simplifying redundancies. I enjoy the time "lost" by failing, learning and dreaming. A.I. is an unnecessary shortcut. Imagination is all you need.

I do actually agree with that. There is a certain sense of achievement in figuring out and developing a solution yourself and ending up with something that works and does what you were aiming for. Before AI existed, it would have been necessary to do all of those things by oneself and as you rightly point out bring into it experience and imagination. Using AI looses something of that. In my case, yes, I did produce a much more complex version of the example it gave me that actually did everything that I needed it to do. While that did take quite some time and effort and gave me a certain sense of accomplishment, AI also took something away from that, because it left me with a sense of having "cheated" a bit. It was no longer 100% my idea and my effort and I did loose something of that trying, failing and learning.

So yes, you make some valid points.