Hello all,
I have a problem with communication between 2 arduino nano v3.
Communication is done by 1st arduino is a Slave Sender and 2nd arduino is a Master Reader.
On the 1st arduino i have connected weight sensor which measure weight from load cell.
On the next step data are sending by i2c to master reader arduino.
Everything is allright when i put known weight on the load cell up to 255 kg.
If I put 100kg 1st arduino shows (in serial monitor )100kg and 2nd arduino shows 100kg too.
If I put 255 kg 1st arduino shows 255kg and 2nd arduino shows 255kg too.
Problems are when I put more than 255kg, for example when I put knows weight ex. 300kg 1st arduino shows 300kg and 2nd arduino after i2c communication get only 45 kg - now i know it is 300-255=45 kg its just a rest difference.
I searched everywere and as i know everything that is the reason write topic here.
Look in my code.
Slave sender :
#include "HX711.h"
#include "Wire.h"
// HX711.DOUT - pin #A1
// HX711.PD_SCK - pin #A0
HX711 scale(A1,A0); // parameter "gain" is ommited; the default value 128 is used by the library
long A;
void setup()
{
Serial.begin(9600);
scale.set_scale(3350.f); // this value is obtained by calibrating the scale with known weights; see the README for details
scale.tare(); // reset the scale to 0
Wire.begin(2); // join i2c bus with address #2
Wire.onRequest(requestEvent); // register event
}
void loop()
{
A = scale.get_units(),0;
Serial.print("\t| average:\t");
Serial.println(A);
scale.power_down(); // put the ADC in sleep mode
delay(500);
scale.power_up();
}
void requestEvent()
{
Wire.write(A);
}
Master Reader :
#include "LiquidCrystal.h"
#include "Wire.h"
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
lcd.begin(20, 4); // ustawienie wielkosci wyswietlacza
Serial.begin(9600);
}
void waga1()
{
Wire.requestFrom(2,2); // request 2 bytes from slave device #2
while(Wire.available()) // slave may send less than requested
{
long c = Wire.read(); // receive a byte as character
Serial.print(c); // print the weight
}
delay(500);
}
void loop()
{
waga1();
delay(1000);
}
I don't have any more patience for that and any more ideas how to fix that.
Maybe from You Guys somebady will know how to help me.
p.s Sorry for my English but i think all is understand.
Best Regards Mariusz.