Moin Moin ... Ich bin zwar kein absoluter Newbie in Sachen Arduino, aber stehe noch ziemlich am Anfang und fummel mich gerade in die ganze Sache rein. Ich habe aus dem Kaffee-Netz Forum die Bauanleitung für eine spezielle Waage mit Wägesensor am Wickel, die Hardware (basiert auf einem Arduino NANO) dafür besorgt und mit Arduino IDE versucht den Sketch in den Nano zu beamen.
Nachdem ich anfangs erst einmal die Probleme mit den Lib`s erledigt hatte, bekam ich aber immer wieder folgende Fehlermeldung:
C:\Users\Jo\Downloads\SJ_Scale_OLED\Scale.cpp: In constructor 'Scale::Scale(byte, byte, byte, byte)':
C:\Users\Jo\Downloads\SJ_Scale_OLED\Scale.cpp:17:37: error: no matching function for call to 'HX711::HX711(byte&, byte&)'
_scale = new HX711(doutPin, sckPin); // parameter "gain" is ommited; the default value 128 is used by the library
^
In file included from C:\Users\Jo\Downloads\SJ_Scale_OLED\Scale.h:4:0,
from C:\Users\Jo\Downloads\SJ_Scale_OLED\Scale.cpp:1:
C:\Users\Jo\Documents\Arduino\libraries\HX711\src/HX711.h:30:3: note: candidate: HX711::HX711()
HX711();
^~~~~
C:\Users\Jo\Documents\Arduino\libraries\HX711\src/HX711.h:30:3: note: candidate expects 0 arguments, 2 provided
C:\Users\Jo\Documents\Arduino\libraries\HX711\src/HX711.h:19:7: note: candidate: constexpr HX711::HX711(const HX711&)
class HX711
^~~~~
C:\Users\Jo\Documents\Arduino\libraries\HX711\src/HX711.h:19:7: note: candidate expects 1 argument, 2 provided
exit status 1
Compilation error: no matching function for call to 'HX711::HX711(byte&, byte&)'
Der Fehler scheint in der Datei Scale.cpp zu liegen, da hier heraus der Fehler entsteht:
#include "Scale.h"
Scale::Scale(byte doutPin, byte sckPin, byte vdcPin, byte gndPin) {
if (gndPin != NO_PIN) {
// power supply use of A4 and A5 for HX711 (normal operation < 1.5mA)
// GND
pinMode(gndPin, OUTPUT);
digitalWrite(gndPin, LOW);
}
if (vdcPin != NO_PIN) {
// +5VDC
pinMode(vdcPin, OUTPUT);
digitalWrite(vdcPin, HIGH);
}
_scale = new HX711(doutPin, sckPin); // parameter "gain" is ommited; the default value 128 is used by the library
}
void Scale::init(float scaleFactor) {
_scale->set_scale(scaleFactor);
}
float Scale::calibrate() {
/*
How to Calibrate your scale:
1. Call set_scale() with no parameter.
2. Call tare() with no parameter.
3. Place a known weight on the scale and call get_units(10).
4. Divide the result in step 3 to your known weight. You should get about the parameter you need to pass to set_scale.
5. Adjust the parameter in step 4 until you get an accurate reading.
*/
_scale->set_scale();
_scale->tare();
// give use up to 10s time to place calibration weight
delay(10000);
float scaleFactor = _scale->get_units(10) / CALIBRATION_WEIGHT;
init(scaleFactor);
return scaleFactor;
}
void Scale::start() {
int maxTare = 20;
int data;
byte numReads = 0;
noInterrupts();
do
{
_scale->tare(); // reset the scale to 0
delay(100);
data = abs(_scale->get_units() * 10);
if (data > 1)
numReads = 0;
else
numReads++;
maxTare--;
} while (maxTare > 0 && numReads < 2); // re-tare as long as we have two consecutive reads with > 0.1g after tare (max. retries: 20)
_numScaleReadings = 0;
_totalWeight = 0;
for (int i = 0; i < MAX_SCALE_READINGS; i++)
_scaleReadings[i] = 0;
interrupts();
}
unsigned int Scale::updateCurrentWeight() {
// note: this method takes up to 580µs (each scale read takes ap. 550µs)
unsigned int data = _scale->get_units() * 10;
if (data > 999) {
data = _scaleReadings[_numScaleReadings];
}
// remove oldest value from total
_totalWeight -= _scaleReadings[_numScaleReadings];
// add newest value
_scaleReadings[_numScaleReadings] = data;
_totalWeight += data;
_numScaleReadings = (_numScaleReadings + 1) % MAX_SCALE_READINGS;
return _totalWeight / MAX_SCALE_READINGS;
}
Die Befehlszeile
_scale = new HX711(doutPin, sckPin); // parameter "gain" is ommited; the default value 128 is used by the library
}
wird in der Fehlermeldung rot makiert.
Ich habe noch zu wenig Erfahrung um den Fehler selbst zu beheben und ich bräuchte da einmal Hilfe.