Hardware:
Adafruit Feather HUZZAH with ESP8266
Adalogger FeatherWing (using RTC only)
2.9" Tri-Color ePaper Display FeatherWing
HX711 breakout board
Hello! I can't get the HX711 to work simultaneously with the Tri-Color ePaper Display FeatherWing. Each work perfectly independently. But when both are initialized, the HX711 returns a constant value (-2040g). I have tried using the HX711 on SPI pins 12, 13, and 14 in different combinations. But same problem.
The goal is to eventually read and upload weight to server every 30 minutes, but I need the last weight to be displayed permanently. Hence the ePaper Display.
/*
Hardware:
Adafruit Feather HUZZAH with ESP8266
Adalogger FeatherWing (using RTC only)
2.9" Tri-Color ePaper Display FeatherWing
HX711 breakout board
*/
#include <SPI.h>
#include <Wire.h>
#include "RTClib.h"
#include "HX711.h"
#include "Adafruit_ThinkInk.h"
RTC_PCF8523 rtc; // Adafruit RTC board
HX711 scale;
//Define HX711 load sensor interface pins
#define DOUT 12
#define CLK 14
float weight;
float calibration_factor = 271.49; //Use "calibrate_load_sensor" sketch to find
//Define 2.9" Tri-Color ePaper Display FeatherWing interface pins
#define EPD_DC 15 // can be any pin, but required!
#define EPD_CS 0 // can be any pin, but required!
#define EPD_BUSY -1 // can set to -1 to not use a pin (will wait a fixed delay)
#define SRAM_CS 16 // can set to -1 to not use a pin (uses a lot of RAM!)
#define EPD_RESET -1 // can set to -1 and share with chip Reset (can't deep sleep)
//Define 2.9" Tricolor EPD FeatherWing:
ThinkInk_290_Tricolor_Z10 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
long previousMillis = 0; // will store last time Display was updated
long interval = 180000; // interval at which Display is updated
//=============================================================================================
// SETUP
//=============================================================================================
void setup() {
Serial.begin(115200);
delay(1000);
//----------------Initialize RTC--------------------------
// Initialize the library to run the RTC
Wire.begin();
Wire.setClock(400000L);
// Following line sets the RTC to the current date and time
//rtc.adjust(DateTime(DATE, TIME));
// Test if the RTC is working properly
if (! rtc.isrunning()) {
Serial.println(F(""));
Serial.println(F("RTC is NOT running!"));
}
else {
// Output the succesfull initialization message to the serial monitor
Serial.println(F(""));
Serial.println(F("RTC initialized."));
}
//----------Initialize scale---------------------------------
scale.begin(DOUT, CLK);
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor);
//----------Initialize TRICOLOR E-PAPER DISPLAY---------------------------------
display.begin(THINKINK_TRICOLOR);
Serial.println("E-Paper Display begun");
delay(2000);
}
//=============================================================================================
// LOOP
//=============================================================================================
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
weight = scale.get_units();
Serial.print("Weight: ");
Serial.print(weight, 1); //number indicates # of decimal places
Serial.println(" g ");
//--------------- E-Paper Display --------------
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
display.clearBuffer();
display.setTextSize(5);
display.setCursor((display.width() - 150) / 2, (display.height() - 30) / 2);
display.setTextColor(EPD_BLACK);
display.print(weight, 0); //number indicates # of decimal places
display.print (" g");
display.display();
Serial.println("Display updated");
}