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
Test & Tools
  • Technologies
  • More
Test & Tools
Blog Analysing Signals from SHT1X Software Module
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Test & Tools to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Former Member
  • Date Created: 10 Apr 2015 1:26 PM Date Created
  • Views 1799 views
  • Likes 2 likes
  • Comments 9 comments
  • sht11
  • click-board
  • lucie_tozer
  • tektronix
  • tbs1000
  • oscilloscope
  • mikro
  • gizmo2
  • tbs1052b
  • tbs1202b-edu
  • espruino
  • tbs1000b-edu
Related
Recommended

Analysing Signals from SHT1X Software Module

Former Member
Former Member
10 Apr 2015

Analysing Signals from SHT1X Software Module

 

Recently I wrote a software module to allow the Espruino development board send commands and receive data from the Sensirion SHT11 temperature and relative humidity sensor.

 

The SHT11 sensor uses a 2 wire bus similar to i2c but has a slight variance in the protocol which prevents using any standard i2c libraries or built in i2c hardware to communicate with it so I designed my software to manually reproduce clock and data signals that are compatible.

 

(the way the sensor tells us it has completed taking its reading and has data ready to send back to us also makes it unsuitable for using on a multi device bus so trying to coerce any built in i2c systems into playing nicely with the sensor wouldn't be a realistic solution)

 

image

 

The Setup is using the MikroC Click board mounted onto a Click board that's designed for Arduino headers but in this example, I'm using the empty click socket to plug jumpers from the Espruino board into. Excuse the rats nest of wires lower down, there's another project connected to the Espruino that isn't used in this write up but will be documented at a later date.

 

image

 

 

and closer:

 

The 2 black probes near the top of the picture below are connected to the scl &sda pins of the 2 wire bus.

image

 

 

 

Below, I used the Tektronix 1202B-EDU scope to capture the Espruino sending a command to the SHT11 sensor, I set the oscilloscope to trigger on the rising edge of the first clock pulse and scaled the acquisition timebase long enough to include the response from the sensor once it had completed it's task and then reading the data from the sensor back into the Espruino.

 

image

 

In the top section of the scope display above is the entirety of the data captured by the oscilloscope, with the information to the left side of that top section being the command to read temperature being sent from the Espruino. There's then a large pause around the middle while the sensor is accurately measuring the temperature. Towards the right side of that top bar is another section of tightly packed signals (similar in style to those on the left). This section is where the sensor signals that it has some data ready and the Espruino reads that data into itself.

 

The larger section of the display underneath is a zoomed in close up of a section of the captured data. The zoom display in the picture is showing the very beginning of the command transfer.

 

The yellow lines are the pulses sent from the clock line of the bus so they are pretty much in a uniform pattern during the communication sequences.

 

The blue lines are the signals captured from the data line of the bus and changes state if necessary between the clock pulses (except for the very beginning where the clock/data signals are sent out of their normal phase as a start sequence to tell the sensor to get ready to receive a new command).

 

image

 

 

Above is a page from the SHT11 datasheet showing an example of communicating with the sensor. Since my software module already manages to get the sensor to perform it's temperature and humidity readings and then transfers the data back to itself, I'm confident that the signals captured by the TBS1202B oscilloscope resemble those provided as an example in the datasheet.

 

The signals in the datasheet look to be a little more uniform and cleaner than the ones I'm capturing which tells me that even though my module is working, there is still room for improvement and could probably benefit from tightening up a little bit, there is also a few minor glitches along the captured data that could do with investigating too.

 

image

 

In the picture above, notice the glitch on the lower blue signal close to the right side. This is the data signal and should be quite clean transitions going between gnd(0v) to represent a binary 0 and +3.3v to represent a binary 1.

 

The signal dips from 3.3v down to around 2.9v; This happens right on the falling edge of a clock signal and stays like that until near the end of the next clock pulse where it dips very briefly to 0v then rises back to 3.3v.

 

Because the zoom display is showing the very end of the command sequence, it's easy enough to work out whats going on here:

 

1. The Espruino communicates the last bit of it's command to the sensor and the releases the data line to float freely. The data line is externally tied to the circuits +ve (in this case 3.3v) power supply using resistors to pull them high.

 

2. Once the Espruino releases the data line, the pull up resistor takes over trying to keep the data signal at 3.3v but since the resistor itself causes the voltage to drop a small amount aswell as some draining through the floating connections, the data signal suffers and can't maintain a 3.3v high but manages to keep at 2.9v which is still in range.

 

3. The reason the Espruino released the data line is to hand control of that bus line to the sensor.

 

4. In order for the sensor to signal it has recieved the command to start measuring the sensor, it takes control of the data line pulls the signal down to 0v(gnd) in acknowledgement while the clock signal is mid pulse.

 

5. The sensor then pulls the data signal back up to 3.3v. Once the SHT11 has finished measuring the temperature, it will pull that data signal back down to 0v(gnd) to let the Espruino know that it's finished and has that information ready to transfer.

 

6. This is the reason there is a large pause between the 2 sets of signals on the left and right hand sides of the upper section of the display.

 

 

image

 

 

The picture above shows the yellow clock signal being kept at 0v(gnd) for longer than the rest of the pattern 2 thirds along the display; once again, because of where about's in the signal transfer that we are looking at, we can work out what's going on..

 

1. The SHT11 sends back 16bits of data to the Espruino, but in 2 lots of 8bits.

 

2. That extended low cycle on the clock line is at the point where the sensor has transmitted the first 8bits and the 2 devices are sending acknowledge signals to each other before transferring the next 8bits.

 

3. These differences in the signals will always be there but with some more work on the software module, and possibly even some hardware changes should tighten it up and pull the signals closer together and look a bit cleaner.

 

image

 

 

An overview of this project showing all of the different aspects in 1 picture.

 

Final thought:

 

Even though the software module I made works and enables the Espruino to communicate with an SHT11 sensor, Using the TBS1202B-EDU from Tektronix has enabled me to see areas where I could pay more attention in improving both my software module as well as investigating the hardware. The improvements once factored in to this design will make for a much more reliable and stable device, The communication between the 2 devices is reliable enough in my testing environment but when it gets packaged into a standalone device, it's very probable that it will come into contact with interference, noise and general disturbance from other sources, those small glitches in the software could add to those other influences and be the thing that stops the device from functioning correctly so I'm using the TBS1202B-EDU as a tool to help take a "proof of concept" design and turn it into a robust device capable of being used in a wide range of environments and make it more able to cope with other sources of interference that might be present.

 

 

 

Lucie

 

 

A sneaky first look at the Gizmo2 that I'm turning into a retro games console to enable me to produce a road test review on it's suitability.

 

image

 

 

Bonus picture!! My little corner of CyberPunk heaven... and yep! my desk is actually quite tidy for a change hah!!

 

image

  • Sign in to reply
  • clem57
    clem57 over 10 years ago in reply to michaelwylie
    From Espruino - JavaScript for Microcontrollers

     

    Everything on one chip for the lowest power consumption.

    Unlike other boards that run JavaScript, Espruino fits everything it needs into single chip. This makes it affordable, reliable, and power efficient - allowing it to run for years on a battery.

    Espruino Microcontroller

    No software needed. Get started in seconds

    Espruino plugs in to your computer by USB and appears as a serial device. No drivers, and no special software. Just run a terminal application and start writing code right away!

    Espruino USB

    Graphical Editor makes it easy to learn

    The optional graphical editor makes it quick and easy to create simple devices, even if you've never programmed before.

    Espruino Graphical Code editor

    Espruino Web IDE makes coding even easier

    The Free Web App installs in seconds and provides a Syntax Highlighted editor that automatically loads any modules you need from the internet.

    Espruino Chrome Web IDE

    Cheers,

    Clem

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

    That's a very well thought out answer. I've never tried the Espruino stuff before, what are its advantages?

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

    Hey Mike,

     

    Yes the pull up resistor is 10k that's installed already on the click board, It's hinted at as an example value in the datasheet so I think MikroC designed around around that. I remember going through the theory of standard i2c bus designs a long time ago and remember that there is always some play off between bus speed and power consumption. A higher value pull up resistor produces a lower power consumption (the standard value being 47kΩ). This does lead to some concerns over the speed of the bus when the capacitance of the components and the bus itself is taken into account since the higher value resistor prevents the stored energy from travelling back out quickly. In cases where the speed is the most important factor, a lower value (like 2.4kΩ) is used. In systems where i2c is used to control computer memory, a lot of focus goes into choosing the optimal value of the resistors to enable the fastest speeds but also taking into account the allowable voltage drop determined by the components and also factoring in how temperature changes can affect the system too as well as other expected noise sources.

     

    I definitely agree that the voltage drop in this application isn't an issue, but for the sake of fiddling about I might try to optimise it a bit image

     

    The communication speed is limited at the minute due to the Espruino using a Javascript interpreter which creates a significant performance drop when it comes to bit banging like this, though I do remember seeing somewhere in the documentation a piece about being able to insert assembly instructions so I might consider streamlining the software module with that at some point. (I don't intend on using the Espruino in the final application, it's just an extremely useful device for quickly getting some logic going in a project. It also runs commands as you type them so is also very useful for debugging. The module I wrote for the sensor is on the Espruino website http://www.espruino.com/SHT1x).

     

    To get started with the sensor, I did a bit of googling and came across a forum where somebody had posted the start sequence; from there I managed to piece together the rest of the basic communication from the datasheet. The formula to calculate dew point I copied from an implementation for am rpi I think it was (I could have worked it out from the datasheet too but I was being lazy!!image)

     

    Lucie

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

    Lucie;

     

    I really enjoyed reading your post. Good work. How big is the pullup on the line, 10 kΩ? I completely understand the frustration of writing the software for these modules as I've written the bit banging routines as well. Sensirion does give example code for some modules, dd you start with those when working on your sensor? I see you are running your lines at about 10 Hz? I wonder what would happen if you sped up the communication? Personally, I wouldn't worry about the drop if it's within spec.

     

    Mike

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

    I am sure you would make a splash there in Tokyo or elsewhere. A thought here is how does the current fluctuate if the resistance is static? Maybe that is your real problem is a drop in current from the supply?

    image

    So do you have a grounding problem? Maybe a ground is a reference that is changing on you and not a true earth ground.Otherwise the power is dropping off.

    Clem

    • 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