MKR485 sheild the wrong CRC output

I'm having trouble getting the a 485 sensor to connect with the MKR485 sheild and a MKR1400. I believe it's a delay issue, however I'm can't figure out the delay nor where should I have the delay.

thank you in advanced.

#include <Arduino.h>

#include <YosemitechModbus.h>


yosemitechModel model = Y511;  // The sensor model number


byte modbusAddress = 0x03;  

// Define pin number variables
const int sensorPwrPin =-1;  // The pin sending power to the sensor
const int adapterPwrPin =-1;  // The pin sending power to the RS485 adapter
const int DEREPin =-1;   // The pin controlling Recieve Enable and Driver Enable
                          // on the RS485 adapter, if applicable (else, -1)
                          // Setting HIGH enables the driver (arduino) to send text
                          // Setting LOW enables the receiver (sensor) to send text


HardwareSerial& modbusSerial = Serial1;

yosemitech sensor;
bool success;

void setup()
{
    pinMode(A6, OUTPUT);
    digitalWrite(A6, HIGH);
    pinMode(A5, OUTPUT);
    digitalWrite(A5, LOW);
    
    pinMode(sensorPwrPin, OUTPUT);
    digitalWrite(sensorPwrPin, HIGH);
    pinMode(adapterPwrPin, OUTPUT);
    digitalWrite(adapterPwrPin, HIGH);

    if (DEREPin > 0) pinMode(DEREPin, OUTPUT);

    Serial.begin(115200);  // Main serial port for debugging via USB Serial Monitor
    modbusSerial.begin(9600);  // The modbus serial stream - Baud rate MUST be 9600.

    // Start up the sensor
    sensor.begin(model, modbusAddress, &modbusSerial, DEREPin);
    
    // Turn on debugging
    //sensor.setDebugStream(&Serial);

    // Start up note
    Serial.print("Yosemitech ");
    Serial.print(sensor.getModel());
    Serial.print(" sensor for ");
    Serial.println(sensor.getParameter());

    // Allow the sensor and converter to warm up
    // DO responds within 275-300ms;
    // Turbidity and pH within 500ms
    // Conductivity doesn't respond until 1.15-1.2s
    Serial.println("Waiting for sensor and adapter to be ready.");
    delay(1200);

    // Get the sensor's hardware and software version
    Serial.println("Getting sensor version.");
    float hardwareV, softwareV;
    sensor.getVersion(hardwareV, softwareV);
    Serial.print("    Current Hardware Version: ");
    Serial.println(hardwareV);
    Serial.print("    Current Software Version: ");
    Serial.println(softwareV);

    // Get the sensor serial number
    Serial.println("Getting sensor serial number.");
    String SN = sensor.getSerialNumber();
    Serial.print("    Serial Number: ");
    Serial.println(SN);

    // Get the sensor calibration equation / status (pH only)
    switch(model)
    {
        case Y532:          // pH, calibration status
        {
            Serial.println("Getting sensor calibration status.");
            byte status = sensor.pHCalibrationStatus();
            Serial.print("    Status: 0x0");
            Serial.println(status, HEX);
        }
        case Y4000:
        {
            Serial.println("For Y4000, use YosemiTech software to get calibration parameters.");
            break;
        }
        default:  // Get the sensor's current calibration values
        {
            Serial.println("Getting sensor calibration equation.");
            float Kval = 0;
            float Bval = 0;
            sensor.getCalibration(Kval, Bval);
            Serial.print("    Current Calibration Equation: final = ");
            Serial.print(Kval);
            Serial.print("*raw + ");
            Serial.println(Bval);
        }
    }

    // Get/set the sensor brush status (for sensors with brushes).
    // NOTE: Not implemented for Y4000
    if (model == Y511 || model == Y513 || model == Y514 || model == Y4000)
    {
        // Check the wiper timing
        Serial.println("Getting sensor cleaning interval.");
        uint16_t interval = sensor.getBrushInterval();
        Serial.print("    Sensor auto-cleaning interval: ");
        Serial.print(interval);
        Serial.println(" minutes");

        // Reset the wiper interval to 30 minutes, the default
        Serial.println("Resetting cleaning interval to 30 minutes.");
        success = sensor.setBrushInterval(30);
        if (success) Serial.println("    Reset.");
        else Serial.println("    Set interval failed!");
    }

    // Tell the sensor to start taking measurements
    Serial.println("Starting sensor measurements");
    success = sensor.startMeasurement();
    if (success) Serial.println("    Measurements started.");
    else Serial.println("    Failed to start measuring!");

    // The modbus manuals recommend the following warm-up times between starting
    // measurements and requesting values :
    //    2 s for whipered chlorophyll
    //    20 s for turbidity
    //    10 s for conductivity

    // On wipered (self-cleaning) models, the brush immediately activates after
    // getting power and takes approximately 10-11 seconds to finish.  No
    // readings should be taken during this time.

    // pH returns values after ~4.5 seconds
    // Conductivity returns values after about 2.4 seconds, but is not stable
    // until ~10 seconds.
    // DO does not return values until ~8 seconds
    // Turbidity takes ~22 seconds to get stable values.
    Serial.println("Allowing sensor to stabilize..");
    for (int i = 10; i > 0; i--)
    {
        Serial.print(i);
        delay (250);
        Serial.print(".");
        delay (250);
        Serial.print(".");
        delay (250);
        Serial.print(".");
        delay (250);
    }
    Serial.println("\n");

    if (model == Y511 || model == Y513 || model == Y514 || model == Y4000) // Y4000 activates brush when powered on
    {
        // We'll run the brush once in the middle of this
        Serial.println("Activating brush.");
        success = sensor.activateBrush();
        if (success) Serial.println("    Brush activated.");
        else Serial.println("    Failed to activate brush!");
    }

    if (model == Y511 || model == Y513 || model == Y514 || model == Y510 || model == Y4000)
    {
        Serial.println("Continuing to stabilize..");
        for (int i = 12; i > 0; i--)
        {
            Serial.print(i);
            delay (250);
            Serial.print(".");
            delay (250);
            Serial.print(".");
            delay (250);
            Serial.print(".");
            delay (250);
        }
        Serial.println("\n");
    }

    switch (model)
    {
        case Y4000:
        {
            Serial.print("Time,  ");
            Serial.println(sensor.getParameter());
            // "DO,   Turb, Cond,  pH,   Temp, ORP,  Chl,  BGA"
            Serial.print("ms,    ");
            Serial.println(sensor.getUnits());
            // "mg/L, NTU,  mS/cm, pH,   °C,   mV,   µg/L, µg/L"
            break;
        }
        default:
        {
            Serial.print("Temp(°C)  ");
            Serial.print(sensor.getParameter());
            Serial.print("(");
            Serial.print(sensor.getUnits());
            Serial.print(")");
            if (model == Y532 || model == Y504) Serial.print("    Value");
            //Serial.print("    Millis");
            Serial.println();
        }
    }

}

// ---------------------------------------------------------------------------
// Main loop function
// ---------------------------------------------------------------------------
void loop()
{
    // send the command to get the values
    switch (model)
    {
        case Y4000:
        {
            float DOmgL, Turbidity, Cond, pH, Temp, ORP, Chlorophyll, BGA = -9999;
            // byte errorCode = 0xFF;  // Error!

            sensor.getValues(DOmgL, Turbidity, Cond, pH, Temp, ORP, Chlorophyll, BGA);

            Serial.print(millis());
            Serial.print("  ");
            Serial.print(DOmgL);
            Serial.print("  ");
            Serial.print(Turbidity);
            Serial.print("  ");
            Serial.print(Cond);
            Serial.print("  ");
            Serial.print(pH);
            Serial.print("  ");
            Serial.print(Temp);
            Serial.print("  ");
            Serial.print(ORP);
            Serial.print("  ");
            Serial.print(Chlorophyll);
            Serial.print("  ");
            Serial.print(BGA);
            Serial.println();
            break;
        }
        default:
        {
            float parmValue, tempValue, thirdValue = -9999;
            sensor.getValues(parmValue, tempValue, thirdValue);
            Serial.print(tempValue);
            Serial.print("      ");
            Serial.print(parmValue);
            if (model == Y532 || model == Y504)
            {
                Serial.print("      ");
                Serial.print(thirdValue);
            }
            // Serial.print("      ");
            // Serial.print(millis());
            Serial.println();
        }
    }



    // Delay between readings
    // Modbus manuals recommend the following re-measure times:
    //     2 s for chlorophyll
    //     2 s for turbidity
    //     3 s for conductivity
    //     1 s for DO

    // The turbidity and DO sensors appear return new readings about every 1.6 seconds.
    // The pH sensor returns new readings about every 1.8 seconds.
    // The conductivity sensor only returns new readings about every 2.7 seconds.

    // The temperature sensors can take readings much more quickly.  The same results
    // can be read many times from the registers between the new sensor readings.
    delay(5000);
}

Unfortunately we cannot help you because you forget to provide the necessary information. No wiring diagram, no link to the used hardware (that "485 sensor"), no link to the YosemitechModbus library, no serial output of your test run.

I did a quick and dirty search around github and found what may be the libraries you are using. Is the code that you have designed to work with the MKR485 board?

The code you posted seems to use only one signal - DEREPin - to switch the RS485 line driver between Tx and Rx modes. From what I can see on the MKR485, the Tx Enable & Rx Enable signals are separate, which you seem to know as you are setting A5 and A6 as outputs.

Hi, I am apologize for the lack of info, I'm a noob, under is the info you require. I also apologize for the shitty wiring diagram drawned with Paint.

wiringdiagram

here is the modbus manual for Yosemitech Y511.
"YosemitechModbus/Y511-Turbidity+Wiper-v1.7_ModbusInstructions.pdf at master · EnviroDIY/YosemitechModbus · GitHub"

here is the library.

There is a mixture of CRC invalid and "respons from wrong slave", in the code above the "ModbusAddress" is 0X03, however I changed it to 0X01 on both sensor and in code.

Thank you very much in advanced, I appreciate it.

BR,

Hi,

Thanks for the apply. The code is for MKR485 board, yes.

So you suggest that the DEREPin should be both A5 & A6, like "const int DEREPin =A5&&A6;" hence the library asks for the DEREPin in the "sensor.begin"

BR,

I'll check more thoroughly when I'm back at a bigger screen, but:

The data you are sending is the same as the data you are receiving judging by the screenshot. I suspect that your setup of the RE and DE signals means that you are talking to yourself.

RE and DE are normally either both high or both low. The only time they are really opposites is when both the Tx and Rx are disabled.

From memory, some modbus Lib's have have a couple of functions called preTransmission and postTransmission which you use to control the direction of flow of the data for your chosen RS485 line driver chip.

EDIT: Ok, the MKR485 uses the MAX3157 chip. According to the datasheet, driving A6 high and A5 low on the MKR485 will enable both the transmitter and receiver at the same time. So you will effectively be receiving your own transmissions, which is what occurs most of the time in the screenshot you posted in #4. The corruption is probably the other device responding as well.

You get these errors because you mostly get back what you sent but not always. This is probably caused by a floating DE/RE pin of the RS-485 driver chip. In your code you don't activate the direction selection but your hardware requires that!

Change the DEREPin constant to A6, remove the code that sets A5 (so leave it in input state) and A6 (first 4 lines of setup()) and connect A5 and A6 on the MKR485 shield by a jumper wire.

Hi Pylon,

I appreciate the help. I have removed the lines with A5 and A6 in setup(), and connected A5&A6 with a jumper. However, it didn't work.

Serial output

With the code I troubleshooted with the computer as a slave with Hercules.
hercules output from the MKr485.

BR,

Hi Mark,

Thank you for the help. I tried to make two function as preTransmission and postTransmission. with different delays.

void preTransmission()
{
    pinMode(A6, OUTPUT);
    digitalWrite(A6, HIGH);
    delay(30);
}

void postTransmission()
{
    pinMode(A5, OUTPUT);
    digitalWrite(A5, LOW);
    delay(30);
}

tried first with the.

    sensor.begin(model, modbusAddress, &modbusSerial, DEREPin);
    preTransmission(); 
    postTransmission();

serial output

Hercules output, with computer as slave.

then i tried to put the pre and post other places.

    // Get the sensor's hardware and software version
    preTransmission();  
    Serial.println("Getting sensor version.");
    float hardwareV, softwareV;
    sensor.getVersion(hardwareV, softwareV);
    Serial.print("    Current Hardware Version: ");
    Serial.println(hardwareV);
    Serial.print("    Current Software Version: ");
    Serial.println(softwareV);
    postTransmission();

serial output.

Hercules output

I appreciate the help!

BTW, the sensor is function with QmodbusMaster and calibration program.

BR,

Hmm, I think I've probably made things worse for you. The preTransmission and postTransmission functions are usually passed as a call back into the modbus library. In your case, it looks like the library you are using doesn't work like that.

I would suggest that you follow the advice from @pylon in reply #7.

Hi, tnx for the fast reply.

I tried what pylon suggested. You can see the output in the reply #8.

BR,

Can you post your code with the mod in, that you used in #8.

Of course, here is the code

#include <Arduino.h>

#include <YosemitechModbus.h>


yosemitechModel model = Y511;  // The sensor model number


byte modbusAddress = 0x01;  

// Define pin number variables
const int sensorPwrPin =-1;  // The pin sending power to the sensor
const int adapterPwrPin =-1;  // The pin sending power to the RS485 adapter
const int DEREPin =A6;   // The pin controlling Recieve Enable and Driver Enable
                          // on the RS485 adapter, if applicable (else, -1)
                          // Setting HIGH enables the driver (arduino) to send text
                          // Setting LOW enables the receiver (sensor) to send text


HardwareSerial& modbusSerial = Serial1;

yosemitech sensor;
bool success;





void setup()
{

    pinMode(sensorPwrPin, OUTPUT);
    digitalWrite(sensorPwrPin, HIGH);
    pinMode(adapterPwrPin, OUTPUT);
    digitalWrite(adapterPwrPin, HIGH);

    if (DEREPin > 0) pinMode(DEREPin, OUTPUT);

    Serial.begin(115200);  // Main serial port for debugging via USB Serial Monitor
    delay(1000);
    
    
    modbusSerial.begin(9600);  // The modbus serial stream - Baud rate MUST be 9600.

      // Start up the sensor
    sensor.begin(model, modbusAddress, &modbusSerial, DEREPin);
    // Turn on debugging
    sensor.setDebugStream(&Serial);

    // Start up note
    Serial.print("Yosemitech ");
    Serial.print(sensor.getModel());
    Serial.print(" sensor for ");
    Serial.println(sensor.getParameter());
    delay(1500);

    // Allow the sensor and converter to warm up
    // DO responds within 275-300ms;
    // Turbidity and pH within 500ms
    // Conductivity doesn't respond until 1.15-1.2s
    Serial.println("Waiting for sensor and adapter to be ready.");
    delay(500);

    // Get the sensor's hardware and software version  
    Serial.println("Getting sensor version.");
    float hardwareV, softwareV;
    sensor.getVersion(hardwareV, softwareV);
    Serial.print("    Current Hardware Version: ");
    Serial.println(hardwareV);
    Serial.print("    Current Software Version: ");
    Serial.println(softwareV);

    // Get the sensor serial number
    Serial.println("Getting sensor serial number.");
    String SN = sensor.getSerialNumber();
    Serial.print("    Serial Number: ");
    Serial.println(SN);
    // Get the sensor calibration equation / status (pH only)
    switch(model)
    {
        case Y532:          // pH, calibration status
        {
            Serial.println("Getting sensor calibration status.");
            byte status = sensor.pHCalibrationStatus();
            Serial.print("    Status: 0x0");
            Serial.println(status, HEX);
        }
        case Y4000:
        {
            Serial.println("For Y4000, use YosemiTech software to get calibration parameters.");
            break;
        }
        default:  // Get the sensor's current calibration values
        {
            Serial.println("Getting sensor calibration equation.");
            float Kval = 0;
            float Bval = 0;
            sensor.getCalibration(Kval, Bval);
            Serial.print("    Current Calibration Equation: final = ");
            Serial.print(Kval);
            Serial.print("*raw + ");
            Serial.println(Bval);
        }
    }

    // Get/set the sensor brush status (for sensors with brushes).
    // NOTE: Not implemented for Y4000
    if (model == Y511 || model == Y513 || model == Y514 || model == Y4000)
    {
        // Check the wiper timing
        Serial.println("Getting sensor cleaning interval.");
        uint16_t interval = sensor.getBrushInterval();
        Serial.print("    Sensor auto-cleaning interval: ");
        Serial.print(interval);
        Serial.println(" minutes");

        // Reset the wiper interval to 30 minutes, the default
        Serial.println("Resetting cleaning interval to 30 minutes.");
        success = sensor.setBrushInterval(30);
        if (success) Serial.println("    Reset.");
        else Serial.println("    Set interval failed!");
    }

    // Tell the sensor to start taking measurements
    Serial.println("Starting sensor measurements");
    success = sensor.startMeasurement();
    if (success) Serial.println("    Measurements started.");
    else Serial.println("    Failed to start measuring!");

    // The modbus manuals recommend the following warm-up times between starting
    // measurements and requesting values :
    //    2 s for whipered chlorophyll
    //    20 s for turbidity
    //    10 s for conductivity

    // On wipered (self-cleaning) models, the brush immediately activates after
    // getting power and takes approximately 10-11 seconds to finish.  No
    // readings should be taken during this time.

    // pH returns values after ~4.5 seconds
    // Conductivity returns values after about 2.4 seconds, but is not stable
    // until ~10 seconds.
    // DO does not return values until ~8 seconds
    // Turbidity takes ~22 seconds to get stable values.
    Serial.println("Allowing sensor to stabilize..");
    for (int i = 10; i > 0; i--)
    {
        Serial.print(i);
        delay (250);
        Serial.print(".");
        delay (250);
        Serial.print(".");
        delay (250);
        Serial.print(".");
        delay (250);
    }
    Serial.println("\n");

    if (model == Y511 || model == Y513 || model == Y514 || model == Y4000) // Y4000 activates brush when powered on
    {
        // We'll run the brush once in the middle of this
        Serial.println("Activating brush.");
        success = sensor.activateBrush();
        if (success) Serial.println("    Brush activated.");
        else Serial.println("    Failed to activate brush!");
    }

    if (model == Y511 || model == Y513 || model == Y514 || model == Y510 || model == Y4000)
    {
        Serial.println("Continuing to stabilize..");
        for (int i = 12; i > 0; i--)
        {
            Serial.print(i);
            delay (250);
            Serial.print(".");
            delay (250);
            Serial.print(".");
            delay (250);
            Serial.print(".");
            delay (250);
        }
        Serial.println("\n");
    }

    switch (model)
    {
        case Y4000:
        {
            Serial.print("Time,  ");
            Serial.println(sensor.getParameter());
            // "DO,   Turb, Cond,  pH,   Temp, ORP,  Chl,  BGA"
            Serial.print("ms,    ");
            Serial.println(sensor.getUnits());
            // "mg/L, NTU,  mS/cm, pH,   °C,   mV,   µg/L, µg/L"
            break;
        }
        default:
        {
            Serial.print("Temp(°C)  ");
            Serial.print(sensor.getParameter());
            Serial.print("(");
            Serial.print(sensor.getUnits());
            Serial.print(")");
            if (model == Y532 || model == Y504) Serial.print("    Value");
            //Serial.print("    Millis");
            Serial.println();
        }
    }

}

// ---------------------------------------------------------------------------
// Main loop function
// ---------------------------------------------------------------------------
void loop()
{
    // send the command to get the values
    switch (model)
    {
        case Y4000:
        {
            float DOmgL, Turbidity, Cond, pH, Temp, ORP, Chlorophyll, BGA = -9999;
            // byte errorCode = 0xFF;  // Error!

            sensor.getValues(DOmgL, Turbidity, Cond, pH, Temp, ORP, Chlorophyll, BGA);

            Serial.print(millis());
            Serial.print("  ");
            Serial.print(DOmgL);
            Serial.print("  ");
            Serial.print(Turbidity);
            Serial.print("  ");
            Serial.print(Cond);
            Serial.print("  ");
            Serial.print(pH);
            Serial.print("  ");
            Serial.print(Temp);
            Serial.print("  ");
            Serial.print(ORP);
            Serial.print("  ");
            Serial.print(Chlorophyll);
            Serial.print("  ");
            Serial.print(BGA);
            Serial.println();
            break;
        }
        default:
        {
            float parmValue, tempValue, thirdValue = -9999;
            sensor.getValues(parmValue, tempValue, thirdValue);
            Serial.print(tempValue);
            Serial.print("      ");
            Serial.print(parmValue);
            if (model == Y532 || model == Y504)
            {
                Serial.print("      ");
                Serial.print(thirdValue);
            }
            // Serial.print("      ");
            // Serial.print(millis());
            Serial.println();
        }
    }



    // Delay between readings
    // Modbus manuals recommend the following re-measure times:
    //     2 s for chlorophyll
    //     2 s for turbidity
    //     3 s for conductivity
    //     1 s for DO

    // The turbidity and DO sensors appear return new readings about every 1.6 seconds.
    // The pH sensor returns new readings about every 1.8 seconds.
    // The conductivity sensor only returns new readings about every 2.7 seconds.

    // The temperature sensors can take readings much more quickly.  The same results
    // can be read many times from the registers between the new sensor readings.
    delay(5000);
}

I looked through the SensorModbusMaster & YosemitechModbus libraries, and the low level sendCommand() function that ultimately spits out the bytes onto the RS485 bus has a debug printout that will print any bytes received in response to a command.

The serial monitor screenshot you provided in #8 shows that sendCommand() didn't get a single byte back in response to any of the requests.

Looking though the Modbus guide for the sensor, it looks like you have the correct baud rate of 9600 baud.

It looks like the default slave address of the sensor is 1 - but it can be changed. Do you know if the sensor may have been programmed with a different address?

Have you got your A & B wires the right way round?

How are you powering the sensor?

Thank you, for the work you done so far.

Yea, the slave address is the default address. however I can change it if that is necessary.

I've tried to change the A&B wires, same output result

I'm using a Adjustable PSU. And wired acoording to the wire diagram.
image

BR,

That's good that you know the sensor works and what it's address is.

Just checking but do you have the 0v of the PSU connected to the 0v of your Arduino?

I wonder if a simple sketch sending out one modbus command would work to check out your Arduino hardware.

Yea, the 0V of the PSU is connected to the 0V, it was connected to the ISOgnd on the mkr485, now I connected the 0V to gnd pin also, just in case.

sorry, I don't follow you.

BR,

I was thinking of bypassing all of the library stuff and just using a simple sketch that transmitted one command sequence and waited for a reply just to try and check that the MKR485 hardware was functioning ok. I'll see if I can cobble something together.

Another thought, is switch 2 on the MKR485 in the half or full position?

Oh, yea, thank you.:slight_smile:

the switch is on half, I can try it on full also.

I hope this doesn't waste your time and drag you off down a non-existent rabbit hole, but here's a bit of code that I put together that hopefully tries to request the serial number from your Y511. It doesn't care about any Modbus timing etc or use a Modbus library.

Caution: I don't have a MKR board to test this on so it may not work for you!

// Untested crude attempt to talk to a Y511 modbus device and get it's serial number
// For MKRxxx board and MKR485 shield - hopefully!

#define RE A5
#define DE A6

// command for: get serial number
const byte msg1[] = {0x01, 0x03, 0x09, 0x00, 0x00, 0x07, 0x07, 0x94};

void setup() {
  // start the USB serial port
  Serial.begin(9600);

  // start the hardware serial port on pins 13 & 14
  Serial1.begin(9600);

  // set the MAX3157 control lines as outputs
  pinMode(RE, OUTPUT);
  pinMode(DE, OUTPUT);

  // put the MAX3157 into receive mode
  digitalWrite(RE, LOW);
  digitalWrite(DE, LOW);

  delay(1000);
}

void loop() {
  uint32_t startTime;
  uint8_t  rxByte;

  Serial.println("Sending command");
  Serial.print("Response: ");
  
  // put the MAX3157 into transmit mode
  digitalWrite(RE, HIGH);
  digitalWrite(DE, HIGH);  

  Serial1.write( msg1, sizeof(msg1) );
  // wait for the message to be sent
  Serial1.flush();

  // put the MAX3157 into receive mode
  digitalWrite(RE, LOW);
  digitalWrite(DE, LOW);

  startTime = millis();
  // wait for up to 2 seconds for any reply and print out any received bytes
  while ( millis() - startTime < 2000UL ) {
    if ( Serial1.available() ) {
      rxByte = Serial1.read();
      Serial.print( rxByte, HEX );
      Serial.print( " " );
    }
  }
  Serial.println();
  Serial.println();

  // 5 second delay, then repeat the whole process again
  delay( 5000 );  
}

That should send out the command to get the serial number using the command sequence from your SmartPC screenshot in #15. It should print out any bytes received in response to the command.

You should have switch 2 in the HALF position, and your RS485 wires on the Y & Z pins.

If you get a response, then hopefully it should be the same bytes that appear in the SmartPC screenshot you posted previously. Getting a response printed should at least show that the basic hardware is working.