0

I am trying to make my Arduino uno and gy-521 accelerometer a modbus tcp server to feed data to a client on my pc. Most likely the HMI I am going to be using is wonder ware.

#include <Wire.h>
const int MPU=0x68; 
int16_t AcZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B); 
  Wire.write(0);    
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop(){
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,12,true);  

  AcZ=Wire.read()<<8|Wire.read();  

  Serial.print("Accelerometer: ");
  Serial.print(" | Z = "); Serial.println(AcZ); 
}

EDIT

Can anyone help me write the code for a modbus tcp server on Arduino uno for an accelerometer. The Arduino server would then feed the data to a client on the pc. The code below is what I have been using to read the data so far on Arduino. Only the Z axis of the accelerometer is needed for this project, so im thinking only the registers for the Z axis is needed. Any help would be greatly appreciated.

1
  • Comments are not for extended discussion; this conversation has been moved to chat. – VE7JRO Mar 9 '20 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.