Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Trying to bitbang i2c oled screen, using SSD1306Ascii library

Trying to bitbang i2c oled screen, using SSD1306Ascii library

Scheduled Pinned Locked Moved Development
12 Posts 4 Posters 2.4k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • alowhumA Offline
    alowhumA Offline
    alowhum
    Plugin Developer
    wrote on last edited by
    #1

    I have an irrigation node with 6 analog soil sensors.

    Now I want to attach an I2C OLED screen, and drive it with the SSD1306Ascii library.

    The problem is the screen uses SDA and CLK which are analog pins 3 and 4.

    Ideally I don't want to give up two soil sensors to add the screen.

    • Can I use bigbang I2C on the binary pins while still using the SSD1306Ascii library?
    • Or will software I2C use so much memory that all this will never work?
    • Should I buy another screen? Is there a version with (software) serial control?

    Google hasn't been very helpful :-(

    mfalkviddM 1 Reply Last reply
    0
    • alowhumA alowhum

      I have an irrigation node with 6 analog soil sensors.

      Now I want to attach an I2C OLED screen, and drive it with the SSD1306Ascii library.

      The problem is the screen uses SDA and CLK which are analog pins 3 and 4.

      Ideally I don't want to give up two soil sensors to add the screen.

      • Can I use bigbang I2C on the binary pins while still using the SSD1306Ascii library?
      • Or will software I2C use so much memory that all this will never work?
      • Should I buy another screen? Is there a version with (software) serial control?

      Google hasn't been very helpful :-(

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @alowhum seems simple enough? https://playground.arduino.cc/Main/SoftwareI2CLibrary

      very lightweight (roughly 250 bytes of flash and 0 byte of RAM, except for call stack)

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #3

        on the other hand, the SSD1306Ascii library seems unable to support software i2c.
        https://github.com/greiman/SSD1306Ascii/blob/master/src/utility/AvrI2c.h assumes hardware i2c

        1 Reply Last reply
        0
        • alowhumA Offline
          alowhumA Offline
          alowhum
          Plugin Developer
          wrote on last edited by
          #4

          @mfalkvidd Yes, that's what I ran into too.

          Screens that can be controlled through software serial might be an option. So far though it seems that most Aliexpress shops call I2C screens "serial"..

          1 Reply Last reply
          0
          • BartEB Offline
            BartEB Offline
            BartE
            Contest Winner
            wrote on last edited by BartE
            #5

            Hi @alowhum why using the SPI variant?

            This will require only one digital IO pen for the chip select (CS pin) the rest is shared with the radio SPI interface (MOSI, MISO, SCK, CE and power off course)

            1 Reply Last reply
            0
            • alowhumA Offline
              alowhumA Offline
              alowhum
              Plugin Developer
              wrote on last edited by
              #6

              I don't quite follow. Do you mean I should use the SPI version of the screen?
              Since I am using NRF24 as a radio I thought that might not be possible, since it already occupies the Arduino Nano's SPI interface?

              mfalkviddM 1 Reply Last reply
              0
              • R Offline
                R Offline
                reinhold
                Hardware Contributor
                wrote on last edited by
                #7

                Another idea might be to connect all analog sensors to I2C Analog-digital converters like the ADS1115:
                https://www.aliexpress.com/store/product/I2C-ADS1115-16-Bit-ADC-4-channel-Module-with-Programmable-Gain-Amplifier-2-0V-to-5/324775_32903062908.html

                As you can hook up multiple devices to the same i2c bus, simply attach the OLED and two of those ADS1115 boards (apparently you can assign up to 7 different I2C addresses to the ADC boards...) to the I2C bus.

                1 Reply Last reply
                1
                • R Offline
                  R Offline
                  reinhold
                  Hardware Contributor
                  wrote on last edited by
                  #8

                  If you insist on connecting the analog sensors to the arduino and switch to a software I2C implementation on non-hardware I2C pins, you might simply extend the SSD1306Ascii library. It currently has classes for the SSD1306 over the AVR hardware i2c, another class for generic Wire implementations (not tailored to atmel chips; e.g. I'm using it on nrf51822), and the SPI devices.

                  Looking at the SoftwareI2CLibrary docs, it appears that they even provide a Wire interface (SoftWire.h), so you might even get away with the SSD1306AsciiWire class for the OLED.

                  If that does not work, you'll have to write your own software I2C implementation for the SSD1306Ascii class (e.g. takt SSD1306AsciiWire, rename it to SSD1306AsciiSoftI2C and adjust it to use the SoftwareI2C library for all I2C communication).)

                  1 Reply Last reply
                  1
                  • alowhumA alowhum

                    I don't quite follow. Do you mean I should use the SPI version of the screen?
                    Since I am using NRF24 as a radio I thought that might not be possible, since it already occupies the Arduino Nano's SPI interface?

                    mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #9

                    @alowhum SPI is a shared bus. Many devices can use it. Which device is active is controlled by the CS pin.

                    1 Reply Last reply
                    1
                    • alowhumA Offline
                      alowhumA Offline
                      alowhum
                      Plugin Developer
                      wrote on last edited by
                      #10

                      Thanks everyone. That's a lot to think about.

                      1 Reply Last reply
                      0
                      • alowhumA Offline
                        alowhumA Offline
                        alowhum
                        Plugin Developer
                        wrote on last edited by
                        #11

                        This looks interesting: a completely serial screen for $4:
                        https://www.aliexpress.com/item/1-77-1-8-128-160-HMI-Intelligent-Smart-USART-UART-Serial-TFT-LCD-Module-Display/32908921322.html

                        1 Reply Last reply
                        1
                        • alowhumA Offline
                          alowhumA Offline
                          alowhum
                          Plugin Developer
                          wrote on last edited by
                          #12

                          For anyone finding this: I got that 'smart' LCD screen that can be controlled with serial commands. It's awesome!

                          The screen now displays a bar graph for all 6 moisture sensors (irrigation controller).

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          17

                          Online

                          11.7k

                          Users

                          11.2k

                          Topics

                          113.1k

                          Posts


                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • MySensors
                          • OpenHardware.io
                          • Categories
                          • Recent
                          • Tags
                          • Popular