ATtiny3217  SBC Circuits

Circuit (click to enlarge) Gif (click to enlarge) Device & I/O Pins Sketch Description/Comments

Microcontroller Board Pinout

MCU Pins' Assigned Functions

Board pin 5, IDE pin D0, MCU pin PA4, function pin SPI SS

Board pin 8, IDE pin D3, MCU pin PA7, function pin LED

Board pin 13, IDE pin D8, MCU pin PB3, function pin RX

Board pin 14, IDE pin D9, MCU pin PB2, function pin TX

Board pin 15, IDE pin D10, MCU pin PB1, function pin I2C SDA

Board pin 16, IDE pin D11, MCU pin PB0, function pin I2C SCL

Board pin 23, IDE pin D21, MCU pin PA0, function pin Reset/UPDI

Board pin 24, IDE pin D18, MCU pin PA1, function pin SPI MOSI

Board pin 25, IDE pin D19, MCU pin PA2, function pin SPI MISO

Board pin 26, IDE pin D20, MCU pin PA3, function pin SPI SCK




Reset Circuit

Reset Button Pressed


Reset Circuit

 - D21 UPDI/Reset/PA0

N/A Pressing the external reset button that is pulled down through 150 ohms (to limit current) will cause the ATtiny3217 to reset and will illuminate the onboard LED briefly.

MCU pin PA0 is the Reset pin as well as the UPDI pin used for programming the chip.

Quad Switch Module

Serial Monitor Output

Quad Switches Module

- D2, D4, D5, D6


The digital inputs to the ATtiny3217 are normally pulled high through 10K resistors. When any of the 4 switches is pressed, a circuit is completed to ground which will show a low at one of the inputs which is reported in Serial Monitor.

1.3" 128x64 Mono OLED



OLED 128x64

Display Module

 - I2C: D10 (SDA), D11 (SCL)



Changes made to the default file include:

 - comment-out line 21 for SPI

 - change value to -1 in line 30

 - change address to 0x3C in line 59


You will need these libraries to run the sketch:

 - Adafruit_BME280_Library

 - Adafruit_BusIO

 - Adafruit_Sensor

 - Adafruit_SSD1306 (optional)

 - Adafruit-GFX-Library (optional)

 - RTClib

 - U8g2_Arduino


If your Arduino IDE's default path is C:\Users\YourName\OneDrive\Documents\Arduino for your sketches, place these libraries (uncompressed) in the "libraries" folder.

Adafruit OLED 1.3" 4-pin 128x64 display  test for SSD1306 driver.


Geekcreit OLED 1.3" 4-pin 128x64 display test for SH1106 driver


Note: if the display is missing the left-most column of pixels, switch to the other display driver: SSD1306 versus SH1106.


U8X8 Arduino monochrome text libraries.

U8G2 Arduino monochrome graphics and text libraries.

BME280 Sensor:

Temperature, Humidity, Barometric Pressure

BME280 Sensor Demo


BME280 Sensor Module

- I2C: D10 (SDA), D11 (SCL)




The OLED is used to display the stats. There is no date and time posted until the RTC circuitry is installed.

Adafruit sensor provides temperature, humidity and barometric pressure.

I included the ability to measure the Humidex temperature (https://en.wikipedia.org/wiki/Humidex#Computation_formula)

Altitude can be roughly calculated based on current BP.

RTC (Real-Time Clock)



DS1307 RTC

Real Time Clock

- I2C: D10 (SDA), D11 (SCL)


Use this file to test the RTC with the Arduino IDE Serial Monitor.



Use this file to test all of the assembled modules so far.


Prints the current date, day-of-the-week and time on the serial monitor. Once initialized by your PC's clock, the date and time will be backed up by the coin cell battery. This link will provide info on the RTClib.

This program works the same as SdFilesList but now the most recent files are timestamped with the current date & time, thanks to the RTC.


SD Card Module

 - D0: SPI SS

 - D18: SPI MOSI

 - D19: SPI MISO

 - D20: SPI SCK


#define SS_PIN 0












Link to more SD functions

Write a test file to the SD card.


Read the contents of a file previously written to.


List the SD card's files in the root folder.


List the SD card's folders and files.



Switches & LEDs

 - LEDS: A1, A2, A3

 - Switches: D5, D6, D7

Switches_LEDs.zip When a left, center or right switch is pressed, the corresponding red, green or blue LED is illuminated briefly.


LDR: Light Dependent Resistor

 - LDR: D3

 - LEDs: A1, A2, A3


Three LEDs arranged like a traffic light, illuminate in succession as the light above the LDR is reduced.


PIR Motion Sensor Module

 - D2

PIR_01.zip The LED connected to D13 will illuminate when the signal from the PIR goes from 0v to 5v after detecting movement. Note how the LED stays lit until the movement ceases.


SD Card Module

 - SPI: D10, D11, D12, D13

 - A0









Link to more SD functions

Write a test file to the SD card.


Read the contents of a file previously written to.


List the SD card's files in the root folder.


List the SD card's folders and files.


OLED, BME, RTC, SD, RGB, and Buzzer

 - I2C: A4 (SDA), A5 (SCL)

 - no Reset

 - SPI (D10 to D13)



Included weather datalogging every minute to the SD.

 - 22614 / 32256 program space

 - 1524 / 2048 global variables


Full system including PIR motion detector

- I2C: A4 (SDA), A5 (SCL)

 - no Reset

 - SPI (D10 to D13)



Example of THBP.txt

The OLED display is enabled initially to show the stats for 10 seconds and then it's blanked.


The stats are written to the SD card every 60s. (An example can be found in the adjacent column as THBP.txt.)


If the PIR senses movement, the OLED is re-enabled for 10 seconds.

The flowchart on the left shows the logical operation. The Arduino code follows this logic.


Below the logic flow diagram is a short video of the working Weather Inside system. You can click on the .gif file for a larger .mp4 video.


I2C Addresses

0x3C: OLED

0x68: SD

0x77: BME280

 I2C-Scanner.zip Q: How do I know which I2C addresses are in effect? (This becomes important when you cannot get a new device to work with your current system configuration.)

A: Run I2C-Scanner.zip. It will give you a list of all I2C addresses currently in use. If you don't know which address is which, remove all of the I2C SCL/SDA connections, then add them one by one as you run the program. Use it to document your code for the addresses in use.



Tags: Arduino-type Microcontroller, ATMega328P