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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 1835 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…
Parents
  • mcb1
    mcb1 over 10 years ago

    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

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

    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

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

    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 and read the upper registers and 10

    reads of temperature and humidity and then stop the stream, close the port and exit.

     

    It is only intended to prove the HDC1000EVM operated properly on the Raspberry Pi

    and as a clue for others who want to code programs for the device

     

    You will need pyserial.  "apt-get install python-serial" or if you are running python3

    you will have to get python3-serial.

     

    Note I have NOT tried the code on Raspberry Pi Python3, only 2.7 It runs well

    on my Windows8.1 Python33

     

    Let me know of any problems as I would like the code to be compatible.

    On the Raspberry Pi, it locates the device in the /dev/serial folder by name

     

    I haven't moved it around to my other RPi computers yet so the name could change I suppose.

    I do know that if one addresses it by port (/dev/ttyACM0) unplugs it and plugs it back in the

    port may change to /dev/ttyACM1 which is why I used the by name location.

    • Cancel
    • Vote Up +1 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