Hello, I am trying to take readings from a DMM (OWON XDM1041) Using an Arduino Mega 2560.
Sending a MEAS? command via a terminal program I receive the measurement from the DMM.
My issue arises when I try to send the MEAS? command via the Arduino itself to the DMM. I have connected the USB TTL cable to the PC to check that MEAS? is actually being sent and it is, but my .read() function is returning -1 (no data). The Baud rate of mySerial and the DMM match at 115200.
I am struggling to see where I am going wrong here. If anyone has any experience talking to SCPI instruments, your help and guidance would be very much appreciated, I have attached a link to the Programming manual of the DMM below.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
int incomingByte = 0; // for incoming serial data
float DMMbyte = 0;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
mySerial.begin(115200);
}
void loop()
{
if (Serial.available() > 0)
{
// read the incoming byte:
incomingByte = Serial.read();
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
mySerial.write("MEAS?\r\n");
if (mySerial.available() > 0)
{
DMMbyte = mySerial.read();
Serial.print("I received (through mySerial): ");
Serial.println(DMMbyte, DEC);
}
}