element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs HDC1000EVM communications protocol
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: wymand
  • Date Created: 18 Apr 2015 11:43 PM Date Created
  • Views 1801 views
  • Likes 1 like
  • Comments 9 comments
Related
Recommended

HDC1000EVM communications protocol

wymand
wymand
18 Apr 2015

Having been in communications since 1962 when NSA recruited me into the Army Security agency and my career after that

as a consultant, WSP communications engineering, WSDOT, and WSCTC consultant, I am particularly interested in how devices talk

So, lacking any reply from TI to questions on protocol, I am looking for myself.

 

The following Program is not intended to be fancy but gives out some communications protocol

that TI has not published yet!  TI has stated their intent to publish the full communications protocol

for the MSP230 communication with the i2c.  As written it works on my RPi B 


import serial

import binascii

#sample program to read Texas Instruments HDC1000EVM

#initialization and open the port

#possible timeout values:

 

 

#    1. None: wait forever, block call

#    2. 0: non-blocking mode, return immediately

#    3. x, x is bigger than 0, float allowed, timeout block call

ser = serial.Serial()

 

 

#ser.port = "/dev/ttyUSB0"

#ser.port = "COM4:"

#ser.port = "/dev/ttyACM1"

ser.port = "/dev/serial/by-path/platform-bcm2708_usb-usb-0:1.2:1.0"

ser.baudrate = 115200

ser.bytesize = serial.EIGHTBITS #number of bits per bytes

ser.parity = serial.PARITY_NONE #set parity check: no parity

ser.stopbits = serial.STOPBITS_ONE #number of stop bits

#ser.timeout = None          #block read

#ser.timeout = 1           #non-block read

ser.timeout = 2              #timeout block read

ser.xonxoff = False     #disable software flow control

ser.rtscts = False     #disable hardware (RTS/CTS) flow control

ser.dsrdtr = False       #disable hardware (DSR/DTR) flow control

ser.writeTimeout = 2     #timeout for write

 

 

try:

    ser.open()

except Exception as e:

    print ("error open serial port: " + str(e))

    exit()

if ser.isOpen():

    try:

        ser.flushInput() #flush input buffer, discarding all its contents

        ser.flushOutput()#flush output buffer, aborting current output

                        #and discard all that is in buffer

        #write data

 

 

        ser.write(serial.to_bytes([0x4C,0x12,0x01,0x00,0x03,0x40,0xFB,0x02,0x7a]))

        response = ser.readline()

        print("read Serial Number MSB = : 0x" + str(binascii.hexlify(response[7])) + str(binascii.hexlify(response[8])))

 

 

        ser.write(serial.to_bytes([0x4C,0x12,0x01,0x00,0x03,0x40,0xFc,0x02,0x11]))

        response = ser.readline()

        print("read Serial Number MID = : 0x" + str(binascii.hexlify(response[7])) + str(binascii.hexlify(response[8])))

 

 

        ser.write(serial.to_bytes([0x4C,0x12,0x01,0x00,0x03,0x40,0xFd,0x02,0x04]))

        response = ser.readline()

        print("read Serial Number LSB = : 0x" + str(binascii.hexlify(response[7])) + str(binascii.hexlify(response[8])))

 

 

        ser.write(serial.to_bytes([0x4C,0x12,0x01,0x00,0x03,0x40,0xFe,0x02,0x3b]))

        response = ser.readline()

        print("read Manufacturer = :" + str(response[7]) + str(response[8]))

 

 

        ser.write(serial.to_bytes([0x4C,0x12,0x01,0x00,0x03,0x40,0xFF,0x02,0x2e]))

        response = ser.readline()

        print("read Device ID = : 0x" + str(binascii.hexlify(response[7])) + str(binascii.hexlify(response[8])))

 

 

        ser.write(serial.to_bytes([0x33]))

        numOfLines = 0

        while True:

            response = ser.readline()

            if (str(response).find(",") == -1):

                print("start data: " + str(response))

            else:

                print("      Temperature: " + str(("{0:.2f}".format(((float(int((str(response).split(',')[0]),16))/float(65536)) * 165) -40)))+ u"\u00B0" + "C")

                print("      Temperature: " + str(("{0:.2f}".format((((((float(int((str(response).split(',')[0]),16))/float(65536)) * 165) -40) * 9) / 5) + 32)))+ u"\u00B0" + "F")

                print("Relative Humidity: " + str(("{0:.2f}".format((float(int((str(response).split(',')[1]),16))/float(65536)) * 100)))+ "%")

            numOfLines = numOfLines + 1

            if (numOfLines > 10):

                #ser.write(bytes(44))

                ser.write(serial.to_bytes([0x34]))

                response = ser.readline()

                print("read data: " + str(response))

                break

                ser.close()

    except Exception as e1:

        print ("error " + str(e1))

    #ser.write(bytes(44))

    ser.write(serial.to_bytes([0x34]))

    response = ser.readline()

    print("last data: " + str(response))

    ser.close()

else:

    print ("cannot open serial port ")

  • Sign in to reply

Top Comments

  • clem57
    clem57 over 10 years ago +2
    I like what you have done here. Helps the guys who know code to do very interesting things, Thanks, Clem
  • mcb1
    mcb1 over 10 years ago +1
    Doug For those of us who are not so software literate, how do you use it in a RPi. I'm assumming it is python .... Mark
  • wymand
    wymand over 10 years ago in reply to mcb1 +1
    Mark, Yes, it is python. save the program with a name ending in .py I used hdc1000.py Then, in a terminal window type python hdc1000.py and it should locate the port that the HDC1000EVM is connected on…
  • wymand
    wymand over 10 years ago in reply to michaelwylie

    Mike,

      Thanks for the verification.  It helps to know that it runs on more than just my Pi.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • michaelwylie
    michaelwylie over 10 years ago

    Doug;

     

    For verification here is the result of your script, modified for the serial address, running on the Pi 2:

     

     

    read Serial Number MSB = : 0x01e4

    read Serial Number MID = : 0xea14

    read Serial Number LSB = : 0x6d00

    read Manufacturer = :TI

    read Device ID = : 0x1000

    start data: stream start

     

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.26°C

          Temperature: 73.88°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.26°C

          Temperature: 73.88°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

          Temperature: 23.25°C

          Temperature: 73.86°F

    Relative Humidity: 44.29%

    read data: stream stop

     

    last data: stream stop

     

    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • wymand
    wymand over 10 years ago in reply to clem57

    That was my intent.  Though with some trepidation.  I fear someone could try experimenting with calls that could

    put the device into brick mode.  I also was hoping that someone would recognize the data check bit formula and

    reply with it, saving me the energy to figure out what method they are using. It looks like the 03 (i2c address)

    (register) 02 is a register read request so reading should be safe.  I intercepted a write register command but

    don't want to play till I finish and publish my evaluation of the kit as promised.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago

    I like what you have done here. Helps the guys who know code to do very interesting things,

    Thanks,

    Clem

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago in reply to wymand

    Doug

    Thanks for clarifying.

    I don't have the device but thought what you had done, may translate to other things ... hence the clarification.

     

    Cheers

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube