Skip to content

Week 9


Assignment - Input Devices

  • Group assignment:

    • Probe an input device(s)’s analog levels and digital signals (As a minimum, you should demonstrate the use of a multimeter and an oscilloscope.)
    • Document your work on the group work page and reflect on your individual page what you learned
  • Individual assignment:

    • Measure something: add a sensor to a microcontroller board that you have designed and read it.

From Assignment Details.


Hero Shot of Board

Same as the Week 8 assignment board.

Group Assignment

I used an oscilliscope and a multimeter on the board I prepared the week before. And then I added a BME280 sensor and tested that. I used the Serial Monitor at the same time to see the code’s feedback.

Test Something (Multimeter/Osciliscope)

Used:

  • own-designed Input Board,
  • oled screen (i2c),
  • bme280 board from DFRobot (i2c),
  • Multimeter and Oscilloscope and Probes,

Using a Multimeter. Multimeter continuity/voltage checks on the week 8 board (sped up). Measured: 3.3v on VCC, continuity from the XIAO to the SDA/SCL pads, etc.

oscilloscope

SCL pin vs ground. The output was the waveform/function at that point.

What I learned

The multimeter told me the board was connected correctly, but can’t tell a signal, like PWN or another waveform The oscilloscope can measure points that aren’t a steady voltage; SCL, CLK, etc. Probing the BME280 directly was kinda hard because it’s surface mounted, but I could use connected pins at the other side of the traces. (confirmed continuous with the multimeter!).

Individual Assignment

What to expect

The BME280 is an environmental sensor (humidity, pressure, and temperature). The SEN0236 is an implementation of it by DFRobot with a I2C connector and pins for an SPI connection.

BME280 Pins

BME280 Dimensions

Because the component is surface mounted, it is kinda hard to probe, but based on the schematic of the SEN0236, the SCL and SDA connections are available at the “P1” connector.

SEN0236 schematic

Connected:

Temp Image

  • temp image
  • green is SDA, and blue is SCL

oscilloscope

Measure Something/Working with I2C

I2C (I-two-C, or I-Squared-C) is a protocol for connecting a number of different devices to a microcontroller. Each device receives a clock line (SCL), and a data line (SDA), as well as VCC (3.3 volts) and GND (common). Using the clock line, a signal line can be split to many different devices according to their addresses. This is usually something like 0x00. With a device connected to a microcontroller, the microcontroller can scan the I2C bus and return the addresses. Sometimes a library written for a device, presumes the default address, set by the manufacturer, and so you can use these devices often without interacting with addresses, but I wanted to find them:

So, I wrote an I2C scanner example sketch (by Adafruit Industries, 2023 by Carter Nelson): writeup. The following is from the Serial Monitor:

Message (Enter to send message to 'XIAO_ESP32C3' on '/dev/cu.usbmodem145401')
New Line
115200 baud
15:54:09.755 -> Scanning...
15:54:09.755 -> I2C device found at address 0x3C  !
15:54:09.786 -> I2C device found at address 0x77  !
15:54:09.786 -> done

Knowing the I2C addresses(0x77 was the BME280, and 0x3C is the SSD1306 oled), I could upload a demo sketch to the board I made in week 8.

oled screen, week 8

The Code

The code uses the OLED (0x3C) and the BME280 (0x77), and every 2 seconds reads temperature, humidity and pressure. It draws them on the OLED and prints to the Serial Monitor. If either device isn’t found, it prints an error and stops, which made wiring problems easy to spot. The bme280_touch_ai.ino: is the same. It adds a simple menu driven by three capacitive touch inputs on the board to go through a sort-of menu UI.

I used ChatGPT to try to make the code (log linked in the Files section).

I designed the boards in week 8 to make it easy to connect i2c devices. Unfortunately, the order of the pins didn’t match either. For speed, I solved this with the cable. This patch board was a short term fix, but as they say, “There’s nothing more permanent than a short term fix”.

Little Patch Board I made

Reflection

In this case, I was measuring to verify proper continuity and isolation, as designed. I measured the pins and board with a multimeter to test what logic level the board was operating at, and used the oscilloscope to view the waveform of the CLK line of the i2c. I verified that each device was correctly connected to SDA and SCL, and that the board was sending the appropriate signals.

Files