Hi, I'm new to the Arduino community. Anyway, I tried connecting an SSD1306 to a Seeed studio RP-2040, and the only thing that shows up on the display is the Adafruit logo, before going completely black. I don't know if I'm just being really dumb here or not, but here is my code:
#include "SPI.h"
#include "Wire.h"
#include "SHT2x.h"
#include "Adafruit_SSD1306.h"
#include "Adafruit_GFX.h"
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
uint32_t start;
uint32_t stop;
SHT2x sht;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
display.display();
delay(3000);
display.clearDisplay();
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("SHT2x_LIB_VERSION: \t");
Serial.println(SHT2x_LIB_VERSION);
sht.begin();
uint8_t stat = sht.getStatus();
Serial.print(stat, HEX);
Serial.println();
}
void loop()
{
uint16_t rawTemperature;
uint16_t rawHumidity;
start = micros();
bool success = sht.read();
stop = micros();
Serial.print("\t");
Serial.print(stop - start);
Serial.print("\t");
Serial.print(sht.getTemperature(), 1);
Serial.print("°C\t");
Serial.print(sht.getHumidity(), 1);
Serial.print("%\t");
Serial.println();
display.clearDisplay();
display.setTextSize(1);
display.setCursor(1, 5);
display.println("Temp & Humidity");
display.setTextSize(3);
display.setCursor(1,20);
display.print(sht.getTemperature());
display.print((char)247);
display.print("C");
display.println(sht.getHumidity());
display.print("%");
display.display();
delay(1000);
}
// -- END OF FILE --
It is worth noting that this is an edited version of Rob Tillaart's SHT2x Code.
It's intended to show the temperature and humidity from the sensor on the display.
If anyone could help that would be great!