I can't figure this one out. i have a crash-situation I can't figure out. i made a bare minimum code example that reproduces the error.
i'm building a simple weight-scale project using load sensors with hx711 decoders and an adafruit 32*128 monochrome oled i2c display.
The HX711 works like a dream, and in my main program it produces calibrated exact weight and displays it flawlessly on the serial monitor.
The oled also works like a charm in an example sketch, and produces rectangles, text and whatever I ask from it.
It's when I try to combine the two I get problems.
Te example program below works as presented, and produces repeatedly The words "Test before", a scale readout and the word "Test". However because the display.begin-line is commented out, the oled is not doing anything. (The "display.cleardisplay" statement is there to make a change in the oled state by commenting or uncommenting it to see if it's doing anything.)
If I uncomment the display.begin-line, the oled displays what it's told to, and the serial monitor outputs the words "Test before" once, and everything halts.
I guess this happens because of an incompatibility between the libraries, but I can't find any way to fix it.
I tried to disconnect the hx711, and as expected, the program ran without problem, displaying 0,000 for the scale-reading.
Help please?
Here's the program:
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <Wire.h>
#include <SPI.h>
#include <HX711.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
HX711 scale_a(5, 4);
void setup() {
// display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Oled setup Crash on scale_a.get_units if this line is uncommented.
// oled setup to here
//display.clearDisplay();
display.display();
Serial.begin(38400);
delay(1000);
}
void loop() {
Serial.println("Test Before");
Serial.println(scale_a.get_units(1),3);
Serial.println("Test");
}