I had recently bought 6 (resistance based) soil moisture sensors and an SSD1306 128x64 .96 I2C display, however since the I2C pins on the ATmega are analog pins I didn't have enough analog pins for the sensors (I could theoretically connect all of them on the same pin and power them individually like I already do to save power but I would need diodes for that, correct me if I'm wrong) and so far I hadn't found an actual working solution for softwire and ssd1306 (i tried u8g2, adafruit_ssd1306's softwire fork, ssd1306 and ssd1306xled) so I decided to use an SPI display so I bought one and I have run into a few issues:
ofc it's using more pins so I might not have enough pins to have a pin for each sensor's vcc (i could just connect multiple vcc to the same pin so its not that big of an issue)
short answer: it's not working
pins are labeled (from left to right) as: GND, VCC, D0, D1, RES, DC, CS
tried it with my arduino nano 33 iot and it worked fine but when I connected it to the atmega I just got random dots
If anyone has any idea for
a) how I could set up software i2c with ssd1306
or b) how I could get the screen to work with SPI on the atmega
I'd really appreciate it.
If you had included a link to your particular display it might have been possible to point you towards the mods needed to switch it from I2C to SPI. Since you didn't appear to (that monolithic block of punctuation free text is next to impossible to decipher), it isn't.
Alternatively, you could use an external ADC like the one below, leave the OLED on I2C and still have 2 spare ADC channels.
I don't seem to have any problem with U8g2 running software I2C with an SSD1306, can you post the sketch you were testing with? Its possible you are running low on memory,
You don't need to use a separate software I2C library such as SoftWire, U8g2 has built-in software I2C and SPI support just by using the correct constructor.
You should have them active only when doing a read, since they corrode. Turn them off in between reads, which can be done with a common P- or N-chan MOSFET controlled by the ATmega. If you find yourself in need for new sensors, get the capacitive ones. Just beware of the clones and get branded ones, I found DFRobot to work fine.
As I've said I bought an SPI display after the software I2C was just not working.
I've tried u8g2 software i2c and it didn't work for me.
I'm already turning the sensors on only when I'm using them.
SSD1306 128 by 64 .96 OLED display (blue but tbh that doesnt really matter). Also I'd like to update the comment, the libraries I tried even if they did work with software i2c they only worked with analog pins as the i2c pins (so it didnt solve anything).
It is set to 8mhz (its the highest I could go without using external crystals and I'm not planning on doing it since I'm trying to achieve the lowest current consumption possible since the project will run on AA batteries).
It's a lot of information we apparently have been unaware of, like the other display with SPI, what model is it? That's a SSD1306 too? Would you be kind and provide link to datasheet (unless it's the manufacturers which says nothing how the display is configured as by next instance) and / or the sellers page.
I have talked about the SPI display, it is literally the title of the post. The datasheet for it is probably this, however quite frankly I have no idea as the seller didn't provide any information about the display.