Code V.01
Libraries
We use several libraries in the code to help you quickly and easily control different parts and do specific things with your code. You can find all the libraries used in the project folder under “Libraries”
#include "HX711.h"
HX711 scale;
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Arduino.h"
#include "uRTCLib.h"
uRTCLib rtc(0x68);
Defines
We define pins, loadcells factor. To calculate your calibration factor….
#define LOADCELL_DOUT_PIN 2
#define LOADCELL_SCK_PIN 0
float calibration_factor = 27;
int weigth = 0;
The same for OLED display, depends if you use the same…
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int bufferSize = 4;
struct Measurement {
char Calendar[20];
float weight;
};
Measurement measurements[bufferSize];
int currentIndex = 0;
#define enA 15
#define in1 13
#define in2 12
float cal = 0.0007;
int16_t Hour_A;
int16_t Hour_B;
int16_t Minute_A;
int16_t Minute_B;
int16_t Meal_size_A;
int16_t Meal_size_B;