Week 09 - Output Devices

Output Devices #

For this week’s assignment, we were tasked with adding an output device to a microcontroller aand programming it to do something. Using the same PCB as last week (the one I created in Week 6), I programmed a Waveshare E-paper screen to display text. With the support of ChatGPT to program and troubleshoot, I was succesfully able to display text.

The Output Device Design and Programming Process

Designing for an Output Device #

Fortunately, I was able to continue building off of of my board from Week 6. This board was designed with 8 pins broken out for an e-paper screen. As was the hope, the 2.9" e-paper screen I acquired from Anthony came with 8 jumper cables that I paired in the following arrangement:

BUSY –> D6/GPIO43 RST –> D3/GPIO4 DC –> D2/GPIO3 CS –> D1/GPIO2 CLK –> D8/GPIO7 DIN –> D10/GPIO9/MOSI GND –> GND VCC –> 3V3

Prior to attaching the cables, however, I removed the 8 pin and 4 pin headers that were previously installed. I noticed last week that the way the pins were soldered to the board did not allow for a solid connection with the jumper cables to I wanted to rule this out as a problem this week.

Programming for an Output Device #

Similar to last week, and many weeks for that matter, I had no idea how to go about the process of programming an output device. With new headers installed, I connected the cables, opened up Arduino IDE, and started a conversation with ChatGPT in order to have the screen display ‘Hello ePaper.’ The process of programming the e-paper display first involved installing two libraries including: GxEPD2 and Adafruit ADXL343. The next step was figuring out the correct display driver. I was able to get some indication that the screen was working (it went from white to black then ended with a black border) and was getting this output from the Serial Monitor:

ESP-ROM: esp32s3-20210327 SPI OK Initializing ePaper... _PowerOn : 8 _Update_Full : 2 _PowerOff : 2 _PowerOff : 2 Initializing ePaper... _Update_Full : 3941001 _Update_Full : 3941000

Coding

Through some back and forth with ChatGPT I eventually determined that the driver wasGxEPD2_BW<GxEPD2_290_T94 and that that code needed to an include a SPI (serial periphery interface) library that allowed for communication with certain pins:

SPI.begin(7, -1, 9, EPD_CS); // SCK=7, MOSI=9

When I first got the screen to display ‘Hello ePaper’ the screen was streaky. It turned out I needed to full clear the screen and include a slower refresh rate:

Streaky Screen

void loop() { display.setFullWindow(); display.firstPage(); do { display.fillScreen(GxEPD_WHITE); display.setCursor(10, 50); display.print("Hello ePaper"); } while (display.nextPage()); display.hibernate(); // power down between updates delay(10000); }

Clean screen

Combining the ePaper Screen and Accelerometer: #

Because I was able to make progress fairly quickly with the ePaper screen, I decided to see if I could make my input and output devices work in coordination.

This process involved sharing my code from last week with ChatGPT and combining it with the progress I had made this week. Fortunately, this proved to be fairly simple. I worked with ChatGPT to make it so that the screen would refresh after the accelerometer was touch, and I modified the screen display.

The Final Product: #

Click Here to download ePaper/Accelerometer Code

Notes and Resources

Recitation Notes: #

  • A machine is like a musical instrument that needs to be tuned.

Group Assignment Notes: #

For this week’s group assignment, we worked on measuring the power consumption of a motor. We played around with how the voltage and current would change based on how much you interfered with the rotation of the motor.

Group Assignment

https://chatgpt.com/share/690b9722-8d80-800b-903d-652a61a857b0