Compare commits
No commits in common. "6cd280389d78773c4f677a7a617115e5994b858d" and "8a558c31218bb77f47017b8433bc4b6789c79f98" have entirely different histories.
6cd280389d
...
8a558c3121
55
src/main.cpp
@ -13,9 +13,6 @@
|
|||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "commonFS.h"
|
#include "commonFS.h"
|
||||||
|
|
||||||
bool mainTaskWasPaused = 0;
|
|
||||||
uint8_t scaleTareCounter = 0;
|
|
||||||
|
|
||||||
// ##### SETUP #####
|
// ##### SETUP #####
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -48,14 +45,32 @@ void setup() {
|
|||||||
// NFC Reader
|
// NFC Reader
|
||||||
startNfc();
|
startNfc();
|
||||||
|
|
||||||
start_scale();
|
uint8_t scaleCalibrated = start_scale();
|
||||||
|
if (scaleCalibrated == 3) {
|
||||||
|
oledShowMessage("Scale not calibrated!");
|
||||||
|
for (uint16_t i = 0; i < 50000; i++) {
|
||||||
|
yield();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
}
|
||||||
|
} else if (scaleCalibrated == 0) {
|
||||||
|
oledShowMessage("HX711 not found");
|
||||||
|
for (uint16_t i = 0; i < 50000; i++) {
|
||||||
|
yield();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WDT initialisieren mit 10 Sekunden Timeout
|
// WDT initialisieren mit 10 Sekunden Timeout
|
||||||
bool panic = true; // Wenn true, löst ein WDT-Timeout einen System-Panik aus
|
bool panic = true; // Wenn true, löst ein WDT-Timeout einen System-Panik aus
|
||||||
esp_task_wdt_init(10, panic);
|
esp_task_wdt_init(10, panic);
|
||||||
|
|
||||||
// Aktuellen Task (loopTask) zum Watchdog hinzufügen
|
// Aktuellen Task (loopTask) zum Watchdog hinzufügen
|
||||||
esp_task_wdt_add(NULL);
|
esp_task_wdt_add(NULL);
|
||||||
|
|
||||||
|
// Optional: Andere Tasks zum Watchdog hinzufügen, falls nötig
|
||||||
|
// esp_task_wdt_add(task_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,17 +147,9 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ausgabe der Waage auf Display
|
// Ausgabe der Waage auf Display
|
||||||
if(pauseMainTask == 0)
|
if (pauseMainTask == 0 && weight != lastWeight && hasReadRfidTag == 0 && (!autoSendToBambu || autoSetToBambuSpoolId == 0))
|
||||||
{
|
{
|
||||||
if (mainTaskWasPaused || (weight != lastWeight && hasReadRfidTag == 0 && (!autoSendToBambu || autoSetToBambuSpoolId == 0)))
|
(weight < 2) ? ((weight < -2) ? oledShowMessage("!! -0") : oledShowWeight(0)) : oledShowWeight(weight);
|
||||||
{
|
|
||||||
(weight < 2) ? ((weight < -2) ? oledShowMessage("!! -0") : oledShowWeight(0)) : oledShowWeight(weight);
|
|
||||||
}
|
|
||||||
mainTaskWasPaused = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mainTaskWasPaused = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,20 +161,11 @@ void loop() {
|
|||||||
// Prüfen ob die Waage korrekt genullt ist
|
// Prüfen ob die Waage korrekt genullt ist
|
||||||
if ((weight > 0 && weight < 5) || weight < 0)
|
if ((weight > 0 && weight < 5) || weight < 0)
|
||||||
{
|
{
|
||||||
if(scaleTareCounter < 5)
|
scale_tare_counter++;
|
||||||
{
|
|
||||||
scaleTareCounter++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scaleTareRequest = true;
|
|
||||||
scaleTareCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scaleTareCounter = 0;
|
scale_tare_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prüfen ob das Gewicht gleich bleibt und dann senden
|
// Prüfen ob das Gewicht gleich bleibt und dann senden
|
||||||
@ -211,6 +209,7 @@ void loop() {
|
|||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield();
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ TaskHandle_t ScaleTask;
|
|||||||
int16_t weight = 0;
|
int16_t weight = 0;
|
||||||
|
|
||||||
uint8_t weigthCouterToApi = 0;
|
uint8_t weigthCouterToApi = 0;
|
||||||
bool scaleTareRequest = false;
|
uint8_t scale_tare_counter = 0;
|
||||||
uint8_t pauseMainTask = 0;
|
uint8_t pauseMainTask = 0;
|
||||||
uint8_t scaleCalibrated = 1;
|
uint8_t scaleCalibrated = 1;
|
||||||
|
|
||||||
@ -34,16 +34,14 @@ void scale_loop(void * parameter) {
|
|||||||
Serial.println("++++++++++++++++++++++++++++++");
|
Serial.println("++++++++++++++++++++++++++++++");
|
||||||
Serial.println("Scale Loop started");
|
Serial.println("Scale Loop started");
|
||||||
Serial.println("++++++++++++++++++++++++++++++");
|
Serial.println("++++++++++++++++++++++++++++++");
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (scale.is_ready())
|
if (scale.is_ready())
|
||||||
{
|
{
|
||||||
// Waage nochmal Taren, wenn zu lange Abweichung
|
// Waage nochmal Taren, wenn zu lange Abweichung
|
||||||
if (scaleTareRequest == true)
|
if (scale_tare_counter >= 5)
|
||||||
{
|
{
|
||||||
Serial.println("Re-Tare scale");
|
|
||||||
scale.tare();
|
scale.tare();
|
||||||
scaleTareRequest = false;
|
scale_tare_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
weight = round(scale.get_units());
|
weight = round(scale.get_units());
|
||||||
@ -53,13 +51,13 @@ void scale_loop(void * parameter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_scale() {
|
uint8_t start_scale() {
|
||||||
Serial.println("Prüfe Calibration Value");
|
Serial.println("Prüfe Calibration Value");
|
||||||
float calibrationValue;
|
long calibrationValue;
|
||||||
|
|
||||||
// NVS lesen
|
// NVS lesen
|
||||||
preferences.begin(NVS_NAMESPACE, true); // true = readonly
|
preferences.begin(NVS_NAMESPACE, true); // true = readonly
|
||||||
calibrationValue = preferences.getFloat(NVS_KEY_CALIBRATION, defaultScaleCalibrationValue);
|
calibrationValue = preferences.getLong(NVS_KEY_CALIBRATION, defaultScaleCalibrationValue);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
|
|
||||||
Serial.print("Read Scale Calibration Value ");
|
Serial.print("Read Scale Calibration Value ");
|
||||||
@ -70,13 +68,6 @@ void start_scale() {
|
|||||||
if (isnan(calibrationValue) || calibrationValue < 1) {
|
if (isnan(calibrationValue) || calibrationValue < 1) {
|
||||||
calibrationValue = defaultScaleCalibrationValue;
|
calibrationValue = defaultScaleCalibrationValue;
|
||||||
scaleCalibrated = 0;
|
scaleCalibrated = 0;
|
||||||
|
|
||||||
oledShowMessage("Scale not calibrated!");
|
|
||||||
for (uint16_t i = 0; i < 50000; i++) {
|
|
||||||
yield();
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
|
||||||
esp_task_wdt_reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oledShowMessage("Scale Tare Please remove all");
|
oledShowMessage("Scale Tare Please remove all");
|
||||||
@ -110,21 +101,21 @@ void start_scale() {
|
|||||||
} else {
|
} else {
|
||||||
Serial.println("ScaleLoop-Task erfolgreich erstellt");
|
Serial.println("ScaleLoop-Task erfolgreich erstellt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (scaleCalibrated == 1) ? 1 : 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t calibrate_scale() {
|
uint8_t calibrate_scale() {
|
||||||
uint8_t returnState = 0;
|
long newCalibrationValue;
|
||||||
float newCalibrationValue;
|
|
||||||
|
|
||||||
vTaskSuspend(RfidReaderTask);
|
|
||||||
vTaskSuspend(ScaleTask);
|
|
||||||
|
|
||||||
|
//vTaskSuspend(RfidReaderTask);
|
||||||
|
vTaskDelete(RfidReaderTask);
|
||||||
|
vTaskDelete(ScaleTask);
|
||||||
pauseBambuMqttTask = true;
|
pauseBambuMqttTask = true;
|
||||||
pauseMainTask = 1;
|
pauseMainTask = 1;
|
||||||
|
|
||||||
if (scale.wait_ready_timeout(1000))
|
if (scale.wait_ready_timeout(1000))
|
||||||
{
|
{
|
||||||
|
|
||||||
scale.set_scale();
|
scale.set_scale();
|
||||||
oledShowMessage("Step 1 empty Scale");
|
oledShowMessage("Step 1 empty Scale");
|
||||||
|
|
||||||
@ -146,7 +137,7 @@ uint8_t calibrate_scale() {
|
|||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
float newCalibrationValue = scale.get_units(10);
|
long newCalibrationValue = scale.get_units(10);
|
||||||
Serial.print("Result: ");
|
Serial.print("Result: ");
|
||||||
Serial.println(newCalibrationValue);
|
Serial.println(newCalibrationValue);
|
||||||
|
|
||||||
@ -159,43 +150,35 @@ uint8_t calibrate_scale() {
|
|||||||
|
|
||||||
// Speichern mit NVS
|
// Speichern mit NVS
|
||||||
preferences.begin(NVS_NAMESPACE, false); // false = readwrite
|
preferences.begin(NVS_NAMESPACE, false); // false = readwrite
|
||||||
preferences.putFloat(NVS_KEY_CALIBRATION, newCalibrationValue);
|
preferences.putLong(NVS_KEY_CALIBRATION, newCalibrationValue);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
|
|
||||||
// Verifizieren
|
// Verifizieren
|
||||||
preferences.begin(NVS_NAMESPACE, true);
|
preferences.begin(NVS_NAMESPACE, true);
|
||||||
float verifyValue = preferences.getFloat(NVS_KEY_CALIBRATION, 0);
|
long verifyValue = preferences.getLong(NVS_KEY_CALIBRATION, 0);
|
||||||
preferences.end();
|
preferences.end();
|
||||||
|
|
||||||
Serial.print("Verified stored value: ");
|
Serial.print("Verified stored value: ");
|
||||||
Serial.println(verifyValue);
|
Serial.println(verifyValue);
|
||||||
|
|
||||||
Serial.println("End calibration, remove weight");
|
Serial.println("End calibration, revome weight");
|
||||||
|
|
||||||
oledShowMessage("Remove weight");
|
oledShowMessage("Remove weight");
|
||||||
|
|
||||||
scale.set_scale(newCalibrationValue);
|
|
||||||
for (uint16_t i = 0; i < 2000; i++) {
|
|
||||||
yield();
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
|
||||||
esp_task_wdt_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
oledShowMessage("Scale calibrated");
|
|
||||||
|
|
||||||
// For some reason it is not possible to re-tare the scale here, it will result in a wdt timeout. Instead let the scale loop do the taring
|
|
||||||
//scale.tare();
|
|
||||||
scaleTareRequest = true;
|
|
||||||
|
|
||||||
for (uint16_t i = 0; i < 2000; i++) {
|
for (uint16_t i = 0; i < 2000; i++) {
|
||||||
yield();
|
yield();
|
||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
returnState = 1;
|
oledShowMessage("Calibration done");
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < 2000; i++) {
|
||||||
|
yield();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -208,10 +191,10 @@ uint8_t calibrate_scale() {
|
|||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
returnState = 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("HX711 not found.");
|
Serial.println("HX711 not found.");
|
||||||
@ -223,13 +206,16 @@ uint8_t calibrate_scale() {
|
|||||||
vTaskDelay(pdMS_TO_TICKS(1));
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
}
|
}
|
||||||
returnState = 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskResume(RfidReaderTask);
|
oledShowMessage("Scale Ready");
|
||||||
vTaskResume(ScaleTask);
|
|
||||||
|
Serial.println("restart Scale Task");
|
||||||
|
start_scale();
|
||||||
|
|
||||||
pauseBambuMqttTask = false;
|
pauseBambuMqttTask = false;
|
||||||
pauseMainTask = 0;
|
pauseMainTask = 0;
|
||||||
|
|
||||||
return returnState;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ uint8_t tareScale();
|
|||||||
extern HX711 scale;
|
extern HX711 scale;
|
||||||
extern int16_t weight;
|
extern int16_t weight;
|
||||||
extern uint8_t weigthCouterToApi;
|
extern uint8_t weigthCouterToApi;
|
||||||
extern uint8_t scaleTareRequest;
|
extern uint8_t scale_tare_counter;
|
||||||
extern uint8_t pauseMainTask;
|
extern uint8_t pauseMainTask;
|
||||||
extern uint8_t scaleCalibrated;
|
extern uint8_t scaleCalibrated;
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 540 KiB |
Before Width: | Height: | Size: 525 KiB |
Before Width: | Height: | Size: 7.9 MiB |
Before Width: | Height: | Size: 183 KiB |
@ -1,12 +0,0 @@
|
|||||||
## **Heat insert location**
|
|
||||||
|
|
||||||
Housing:
|
|
||||||
- every hole is made to fit a heat insert
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
Scale top:
|
|
||||||
- two heat inserts for the NFC Reader
|
|
||||||

|
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 491 KiB |
Before Width: | Height: | Size: 834 KiB |
Before Width: | Height: | Size: 1.9 MiB |
@ -1,69 +0,0 @@
|
|||||||
## Modifications
|
|
||||||
|
|
||||||
To reduce costs, components were sourced from AliExpress instead of Amazon. However, differences in dimensions and mounting hole spacing necessitated adjustments to the 3D-printed parts. Additionally M3 heat inserts were used to limit M4 screws to a minimum.
|
|
||||||

|
|
||||||
---
|
|
||||||
|
|
||||||
List of parts that were used:
|
|
||||||
- Display: https://aliexpress.com/item/1005007389730469.html
|
|
||||||
- Scale(5KG with HX711): https://aliexpress.com/item/1005006827930173.html
|
|
||||||
- NFC Reader: https://aliexpress.com/item/1005005973913526.html
|
|
||||||
- NFC Chips: https://aliexpress.com/item/1005006332360160.html
|
|
||||||
- [VORON](https://vorondesign.com/) Heat Inserts M3 OD5mm L4mm: https://aliexpress.com/item/1005003582355741.html - make sure to select the correct size
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
- **Parts are designed to be printed in ABS/ASA.** Shrinking compensation not needed.
|
|
||||||
|
|
||||||
- **Display and Scale Adjustments:** The AliExpress-sourced display and scale had different dimensions and hole spacings compared to the Amazon versions. The 3D models were modified to accommodate these differences, ensuring proper fit and functionality.
|
|
||||||
- measurement of my Display & Scale to check if your parts will fit can be found in the images folder
|
|
||||||
|
|
||||||
- **Screw Size and Heat Inserts:** All holes originally designed for M4 screws were resized to fit M3 screws. Standard VORON heat inserts were incorporated to provide durable threading. This change standardizes the hardware and simplifies assembly.
|
|
||||||
|
|
||||||
- **Display Mounting:** The display is now mounted using M3 screws with VORON heat inserts. The display's mounting holes need to be drilled to 3mm to accommodate the M3 screws.
|
|
||||||
|
|
||||||
- **Scale Top Surface:** The top surface of the scale was modified to allow M3 socket head cap screws to sit flush with the 3D-printed part. This design ensures that the filament spool rests flat without interference.
|
|
||||||
|
|
||||||
- **NFC Reader Mounting:** The NFC reader is also secured using M3 screws and VORON heat inserts, maintaining consistency across all components.
|
|
||||||
|
|
||||||
- **Scale Base Mounting:** The only M4 screws required are for attaching the metal part of the scale to its base.
|
|
||||||
|
|
||||||
## Benefits of Modifications
|
|
||||||
|
|
||||||
- **Cost Reduction:** Sourcing components from AliExpress offers a more affordable alternative to Amazon, making the project more accessible.
|
|
||||||
|
|
||||||
- **Standardized Hardware:** Using M3 screws and [VORON](https://vorondesign.com/) heat inserts throughout the assembly simplifies the build process and reduces the variety of required hardware.
|
|
||||||
|
|
||||||
- **Enhanced Compatibility:** Adjustments to the 3D models ensure compatibility with readily available components, accommodating variations in part dimensions.
|
|
||||||
|
|
||||||
## Assembly Instructions
|
|
||||||
|
|
||||||
1. **Component Preparation:**
|
|
||||||
- Carefully drill the display's mounting holes to 3mm to fit M3 screws.
|
|
||||||
|
|
||||||
2. **Heat Insert Installation:**
|
|
||||||
- install VORON M3 heat inserts into the designated holes in the 3D-printed housing/case for the ESP32 and Scale top → [heat insert location pictures](./Images/README.md)
|
|
||||||
|
|
||||||
3. **Component Mounting:**
|
|
||||||
- Attach the display, scale, and NFC reader to their respective mounts using M3 screws.
|
|
||||||
- Secure the metal part of the scale to its base using M4 screws.
|
|
||||||
|
|
||||||
4. **Final Assembly:**
|
|
||||||
- Assemble all components according to the original FilaMan instructions, ensuring that all modified parts fit correctly and function as intended.
|
|
||||||
|
|
||||||
For detailed assembly guides and additional resources, refer to the [original FilaMan documentation](https://github.com/ManuelW77/Filaman).
|
|
||||||
|
|
||||||
## Conclusion
|
|
||||||
|
|
||||||
These modifications to the FilaMan project provide a cost-effective and standardized approach to building a filament management system. By sourcing components from AliExpress and adjusting the 3D models accordingly, users can achieve the same functionality at a reduced cost, with the added benefit of using uniform hardware throughout the assembly.
|
|
||||||
|
|
||||||
## Changelog
|
|
||||||
|
|
||||||
### Version 1.0 - 2025-03-04
|
|
||||||
- Initial release of modifications for AliExpress-sourced components.
|
|
||||||
- Adjusted 3D models to fit different display and scale dimensions.
|
|
||||||
- Replaced M4 screws with M3 screws and integrated VORON heat inserts.
|
|
||||||
- Modified display mounting, requiring drilling to 3mm for M3 screws.
|
|
||||||
- Adjusted scale top surface for flush screw placement.
|
|
||||||
- Standardized NFC reader mounting with M3 screws and VORON heat inserts.
|
|
||||||
- Retained M4 screws only for metal scale attachment.
|
|