PySerial and a Mastech MAS-345

Discussion in 'Python' started by Pejell, Jun 1, 2008.

  1. Pejell


    Jun 1, 2008
    Likes Received:
    Hey, this is my first post here, and I am hoping someone might be able to give me a hand.

    I found this topic here:

    which wasn't all that helpful but it looks like some people here might know a thing or two that could help me.

    This is all for a college year one project I am doing. The idea is to use the multimeter to read amperage on a device, transmit it to a database, then to a website, in order to show power usage statistics. I am handling the meter and readings end of things.

    I have a Mastech MAS-345 Digital Multimeter, connected to COM1 on my desktop. It is currently reading the draw from an external hard drive of mine. The meter is set to: 400mA and AC.

    I have a program called MASView, which shows me the incoming data. I am mainly using this to confirm the connection and the presence of data.

    I am (attempting) to write a small and simple program to read the data from the meter, but I am having issues. I'm not very good at coding, so bare with me please. I tried Java, but I'm horrid with java and a great prof of mine suggested I try Python. So I have it all set up and I just cannot read any data.

    There is VERY little info ont he MAS-345's settings, so I am going on little snippets I have picked up here and there.

    Here is the code I am using so far:

    import serial
    ser = serial.Serial()
    ser.port = 0
    ser.baudrate = 2400
    ser.bytesize = 7

    This works just fine, however, due to lack of information I do not know if I have the baudrate or bytesize settings wrong. I am sure the defaults for the other settings are correct as is, but again, I cannot be sure.

    When I do this:

    I get a "box" for a return character. like this: [] but connected.

    x = ser.readline()
    print x

    Gets me nothing. And


    gets me: 0L

    I am at a loss as to what is going on.

    I have also tried to send a newline to the device to trigger a return of data, but that did not work. (I got that from an article called Electrickery, where this exact meter is used with Perl (blech) to read data from it. We are NOT using perl for this.)

    It is not clear to me, from the pyserial docs, if I can query the meter for its settings, or whether calling the connection using the defaults will use the defaults according to the meter or according to pyserial.

    Does anyone have some thoughts on this?

    Mainly I need to know

    if I have the correct com settings, or if I can check them somehow.

    how to get data from the device.

    Pejell, Jun 1, 2008
    1. Advertisements

  2. Pejell

    Mark Rages

    Mar 30, 2015
    Likes Received:
    Mark Rages, Mar 30, 2015
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.