I am told with AI's help this week is gonna be one easy week. Hope so!
How the week ended
Well the tool we use is as good as the person who uses it, except some tools. After many conversations with each Ai. I found a method that works with less errors. Never underestimate the time taken to document.!
Week 15’s Assignment
Interface and Application Programming
Group assignment:
Compare as many tool options as possible.
Document your work on the group work page and reflect on your individual page what you learned.
Write an application for the embedded board that you made that interfaces a user with input and/or output device(s).
My final project requires an app through which the user can choose their friends's location and set time based on that timezone.
I am using my Input sensor week's
board which has RTC and Attiny connected with UART pins. Since ATtiny1614 does not have bluetooth or wifi I am pairing it with the breakout
board I created in Embedded Networking
and Communications week I am using Xiao esp32s3 in that so I can use wifi or bluetooth
This is how I did this week. I used ChatGPT and communicated my idea on what I want.
I told the basic flow of how I wanted the communications.
"I have an RTC DS1307 connected to ATtiny1614 with UART pins. On another board, I got a XIAO ESP32S3 which has UART pins and an LED. I need the RTC to
send time to the XIAO. I need this to be connected to a web application via Bluetooth. When I select a timezone in that, it should change the time in the
RTC to that location."
I mostly used conversations like these and shared KiCad schematic images of the boards, then asked for complete code.
That approach did not work well. The code had issues, did not run properly, and it became overwhelming because I could not track which AI generated which part.
So I decided to work only with ChatGPT to better understand what it handles well and where I need more clarity. I will use Gemini or Claude only when ChatGPT
cannot provide a better solution.
I have an attiny 1614 with rtc DS1307 with coin cell.
these are connected.
now i need the rtc to be programmed that i can get the real time. it should give out the region:time: date>
I want the attiny to connect to xiao esp32s3 and give the time.
All the timezones have to be added.
Now the attiny is connected to xiao via the uart pins.
connec the xiao over ble to a webpage which can be opened in phone or mobile.
and I get the list of the cities, countires and timezones so i can either type and search for the city, region or time zone, and it shows a dropdown of these options.
i need the xiao get get the correct curretn time of the timezone it is in an dhten change to the timezone set.
attiny:
PA1:LED
PA0:UPDI
PB2:TXD
PB3:RXD
PB0:SCL
PB1:SDA
XIAO ESP32S3
D6:TXD
D7:RXD
D9:LED
tell me what you understood from this, what are the places IN WHICH clarity is need.
keep it short , simple and clear.
I discussed this further and shared my preferences based on the questions it asked. This gave me clarity on my choices rather than blindly trusting AI. It helped customize the responses and code, leaving less room for error. I learned this the hard way after trying many code versions without understanding what I was missing while creating prompts.
- Source of correct time is from the web application, sent over Bluetooth
- DS1307 is the primary time source after initial sync
- The timezone is handled by the web application (recommended)
- Data format over UART (this was missing earlier)
- ATtiny responsibility: only read/write RTC or also apply timezone offsets (I chose whichever is better)
- BLE communication includes full timestamp + timezone (to verify if the change is applied)
- Initial setup: runs on first power. After the first connection with XIAO, it gets the current time and runs on it. After that, it continues based on the set timezone
- Accuracy concerns: when connected to XIAO, it should get time from the internet
- When XIAO and ESP32-S3 are connected, I need that connection over BLE. The connection can last for 2 minutes when powered on or when code is uploaded in Arduino
- During that time, the webpage should fetch live time from an online source
Is this possible? I need the serial monitor to show these updates when connected to BLE and when BLE is active
Decisions
Based on the clarified approach, the system logic was refined. The ATtiny maintains time in UTC, and timezone adjustments are applied based on the selected region. Since only Bluetooth is used, the phone sends the correct time to the XIAO, which then passes it to the ATtiny. This avoids relying on WiFi for online time access.
1 / 3
2 / 3
3 / 3
Final Workflow
1 / 3
2 / 3
3 / 3
After confirming the workflow of the boards, I requested the code in stages. Earlier, when I asked for all the code together, an error
in one part meant I had to modify the others as well. So I am now isolating errors and fixing them incrementally, editing as I go.
ATtiny full firmware (RTC + EEPROM + UART)
ATtiny1614 Board Setup
While setting up the board, I selected the ATtiny1614 without Optiboot. The port was chosen based on the connection being used. In the Tools menu, I set the programmer to SerialUPDI with a baud rate of 57600. However, the Serial Monitor was running at 9600 baud.
After uploading the Arduino code to ATTiny.I prompted ChatGPT for "XIAO-esp32s3 Arduino code," which I got, and the code worked.
Issue pointed out:
At the same time, ChatGPT pointed out that ATtiny wants the local time. What was happening was that the web will
already be sending the local time; e.g., it is 10:00 AM now. The ESP receives this and then it thinks it got the UTC,
so it converts to IST (10:00 AM will become 3:30 PM). This step shouldn't happen. Because of this, ATtiny receives the wrong time.
ChatGPT fix:
Web will send UTC + offset.
XIAO-ESP32S3: will forward the UTC.
ATtiny will convert it.
XIAO-esp32s3 Arduino code
By now, ChatGPT did give the Arduino code for XIAO ESP32S3.
I was unable to follow the instructions ChatGPT gave me on where to change and delete the code in ATtiny's Arduino code and XIAO ESP32S3's Arduino code.
It gave me the choice to fix both codes. So I prompted it to "Fix both sides cleanly."
I wanted to add more locations and I wanted to know if the time was updated after the sync. so I added the below promt.
“upgrade web app”
i also want the serial monitor of xiao esp32s3 to show the time updated based on the timezones elected. and show the time for every 5 seconds
I didnt notice an issue which was right in front of me. The pins were named
#define TX_PIN 6
#define RX_PIN 7
#define LED_PIN 9
and therefore there were no data being send. then I remembered and changed the pins to
#define TX_PIN D6
#define RX_PIN D7
#define LED_PIN D9