Guten Tag,
Ich versuche aktuell ein HX711 mit einem Ethernet shield W5100 zu verbinden.
Dies versuche ich auf dem Arduino Uno r3 umzusetzen.
Allerdings liefert mir der HX711 so keine Daten.
Verkabelt habe ich den HX711 wie hier abgebildet allerdings ist es am W5100 angeschlossen
Das Ethernet shield arbeitet Problemlos
#include <SPI.h>
#include <Ethernet.h>
#include <HX711_ADC.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress serverIP(192,168,5,100); // IP Adress to our Server
int serverPort=54711;
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to
EthernetClient client;
void setup() {
LoadCell.begin(); // start connection to HX711
LoadCell.start(2000); // load cells gets 2000ms of time to stabilize
LoadCell.setCalFactor(720.0); // calibration factor for load cell => strongly dependent on your individual setup
lcd.begin(16, 2); // begins connection to the LCD module
lcd.backlight(); // turns on the backlight
// start the serial for debugging
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting to Server ...");
// if you get a connection to the Server
if (client.connect(serverIP, serverPort)) {
Serial.println("connected");//report it to the Serial
String msg="Hello Server";//Message to be sent
Serial.println("sending Message:"+msg);//log to serial
client.println(msg);//send the message
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
void loop() {
LoadCell.update(); // retrieves data from the load cell
float i = LoadCell.getData(); // get output value
lcd.setCursor(0, 0); // set cursor to first row
lcd.print("Weight[g]:"); // print out to LCD
lcd.setCursor(0, 1); // set cursor to secon row
lcd.print(i); // print out the retrieved value to the second row
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();//report it to the serial
Serial.println("disconnected");
client.stop();
// do nothing forevermore:
for(;;)
;
}
}