OLED causes my arduino uno to freeze

so basically i am making a scale using a HX711 load cell and it works fine. but as soon as i plug my OLED to the circuit it starts to freeze within a few seconds. i didnt write the code myself but modified an already existing one and then just used a simple code to put the value i see on the oled display

here is the code

#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#include <Adafruit_SSD1306.h>
#include <splash.h>

#include <OLED_I2C.h>
#include <HX711_ADC.h>
#if defined(ESP8266)|| defined(ESP32) || defined(AVR)
#define OLED_WIDTH 128
#define OLED_HEIGHT 64

#define OLED_ADDR   0x3C

Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);
#include <EEPROM.h>

const int HX711_dout = 4; //mcu > HX711 dout pin
const int HX711_sck = 5; //mcu > HX711 sck pin

//HX711 constructor:
HX711_ADC LoadCell(HX711_dout, HX711_sck);

const int calVal_eepromAdress = 0;
unsigned long t = 0;

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.setCursor(25, 0);
  display.setCursor(25, 20);
  display.setCursor(25, 40);
  Serial.begin(57600); delay(10);

  float calibrationValue; // calibration value (see example file "Calibration.ino")
  calibrationValue = 384.0; // uncomment this if you want to set the calibration value in the sketch
#if defined(ESP8266)|| defined(ESP32)
  EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
  //EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom

  unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
  boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  else {
    LoadCell.setCalFactor(calibrationValue); // set calibration value (float)
    Serial.println("Startup is complete");

void loop() {
  static boolean newDataReady = 0;
  const int serialPrintInterval = 0; //increase value to slow down serial print activity

  // check for new data/start next conversion:
  if (LoadCell.update()) newDataReady = true;

  // get smoothed value from the dataset:
  if (newDataReady) {
    if (millis() > t + serialPrintInterval) {
      float i = LoadCell.getData();
      Serial.print("Load_cell output val: ");
      newDataReady = 0;
      t = millis();

  // receive command from serial terminal, send 't' to initiate tare operation:
  if (Serial.available() > 0) {
    char inByte = Serial.read();
    if (inByte == 't') LoadCell.tareNoDelay();

  // check if last tare operation is complete:
  if (LoadCell.getTareStatus() == true) {
    Serial.println("Tare complete");


what exactly is the problem here that causes my arduino to freeze as soon as i try to get it to display on my oled screen?

What is it about this description of this section that you don’t understand?

Now go and report your first post to the moderator by using the flag icon, and ask him to put it into an appropriate section of the forum.

Do you mean it slowly freezes, degrading over a period of time?

no it freezes completely or just slows down and then freezes it really depends on how my motherboard feels i'd say

Schematics showing the powering of all the parts in the project could show things.

apparently the reason it froze was i was sold a imitation motherboard which was sold to me as genuine. after changing the motherboard it worked with no problems

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.