Input Devices #
For this week’s assignment, we were tasked with adding a sensor to a microcontroller and reading the data. In Week 6, I created a PCB that was compatible with a AXDL343 Accelerometer, so for this week I wanted to see if I could indeed get my microcontroller work with this input device. With lots of help and luck, I attached an ADXL343 breakout board to my PCB using jumper cables, and was succesfully able to read data. I also went ahead and modified the code so that my LED blinked whenever my accelerometer moved beyond a certain threshold.
The Input Device Design and Programing Process
Designing for an Input Device #
For this week’s assignment, I was building off of the board I made during Week 6, which has four pins broken out for an ADXL343 Accelerometer and eight pins broken out for an epaper screen.
I was a bit worried when I aquired the ADXL343 accelerometer as it was very tiny, and though my board was broken our for the necessary pins, my board did not have the approapriate routing footprint. Fortunately, Anthony had a board made for just this instance that is compatible with the ADXL343.
I showed up during office hours and Anthony walked me through the process of soldering this tiny little guy onto the premilled board. This included hot air soldering, and testing the circuit with a multimeter to see if there were any short circuits.
To my surprise, hot air soldering was fairly simply. It involved squeezing a small amount of soldering paste across all of the pads, then placing the accelerometer on top of the paste. With the hot air gun warm, I heated around the input device about 1" above the board. The paste went through three phases – normal, bubbling, and metal. At the bubbling stage I pressed down on the accelerometer with a pair of tweezers so it would bond with the board. While the soldering was successful, I accidently had the acceleometer too low so it wasn’t matching up with the correct pins and I overcooked my board a bit by not moving the hot air around enough. Anthony helped me correct the board and uses a soldering iron to clean up the excess solder.
With the ADXL343 in place, I proceeded to solder on a zero ohm resistors, two 10k resistors, and a four pin header using a soldering iron. This time I used leaded solder, which made the process much easier. Once this tiny board was complete, we check the connections using the resistance setting on the multimeter, and everything checked out. Later in the day, following the group assignment, I acquired a set of jumper cables to connect the new board and I soldered on the four pin and eight pin header on to my week 6 board.
Programming an Input Device #
Because all of this is new to me, I worked with ChatGPT this week to learn how to program my microcontroller so that the LED would light up when I tapped the accelerometer. Before I could begin programming my board, I had to connect the pins on my personal board to the the pins on the ADXL343 breakout board. This was straightforward but I did notice how unsecure the jumper cables were on my board due to how low the pins were.
In order to begin programming, I prompted ChatGPT to walk me through the process of using an “I2C Scanner,” which started by downloading the Adafruit Unified Sensor and the Adafruit ADXL343 libraries, as well as changing the following settings:
USB CDC On Boot -> Enabled Upload Speed -> 921600 (or 460800 if issues) USB Mode -> Hardware CDC and JTAG Flash Mode -> QIO Flash Size -> 8MB (PSRAM) (since your output said 8MB PSRAM) Partition Scheme -> Default 4MB with spiffs or similar Baud Rate -> 115200
I then connected by board and went through some troubleshooting. This included needing to name the pins on the code (which in my case for the ESP32 S3 were GPIO5 and GPIO6), and fiddling with the cables. The connection from the cable was spotty and it took me a little while to notice that the I2C scanner had picked up on a location:
Scanning... I2C device found at address 0x1D ! Scan complete
This was incredibly good news and allowed me to proceed to the next step of reading the accelerometer rather that just recognizing it was there. I got a new error - “Compilation error: ‘I2CBus’ was not declared in this scope” - and continued to have complications due to the unstable connnections from the jumper cables but finally got a reading that looked like this:
X: -3.18 Y: 0.27 Z: 10.47
X: -2.67 Y: 0.24 Z: 9.49
X: -2.24 Y: 0.59 Z: 9.45
X: -2.55 Y: 0.39 Z: 9.85
X: -2.55 Y: 0.78 Z: 10.00
X: -2.82 Y: 0.67 Z: 10.04
After this, I asked ChatGPT to walk me through how to make the LED blink and I shared my blinking code from the other week. Fortunately, this worked and I was able to get the LED to blink when I tapped on the accelerometer. I adjusted threshold so that the accelerometer wouldn’t blink so often, as seen in the video below.

The Final Product: #
Click Here to Download the ADXL343 Blinking Code
Notes and Resources
AI Conversation Link: #
https://chatgpt.com/share/69012d2e-0e8c-800b-b4be-93834bd9835b
