Understand the serial data transfer - SHT15 and Arduino

Hello Arduino forum!

This is my first post, so please be patient! :slight_smile:

I have always been interested in analogue electronics, and now I decided to learn more about digital electronics playing with an arduino with the intention of building a solar powered weather station.

I have an Arduino Mega2560 as a board, and a SHT15 temperature and relative humidity sensor which work just fine. I want to understand the data transfer protocol (I don't really like black boxes).

I read the datasheet of the SHT15 sensor, and tried to follow along with my oscilloscope.

However, what I get does not seem to match the information in the datasheet, so I don't really understand what's going on.

In the figure attached the line in yellow is the serial clock, the line in blue is the data. There appear to be 16 10ms bits in the data per cycle of the sck, although that already confuses me: given the baud rate of 9600, shouldn't a bit be about 104us?

Overall, in a 2s period the oscilloscope triggers 3 clk pulses corresponding (for the attached image) to the following data:
1- 0001100001110100
2- 0000100010011100
3- 0001100001111001

Usually, the data corresponding to the first and third clk pulse start with 00011 (maybe it's the temperature command in Table4?), the second pulse can change (I saw e.g. 0000011..., I have not yet seen the 00101 for RH). I can't really seem to get my head around understanding what's on the datasheet and how it matches with what I see on the oscilloscope.

I have set a 5s delay between measurements, and my code is extremely simple:

#include <SHT1X.h>
SHT1x sht15(A4, A5);//Data, SCK

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print(sht15.readTemperatureC());
Serial.print(',');
Serial.print(sht15.readHumidity());
Serial.println();
delay(5000);
}

Can anyone enlighten me?

Thank you very much!
Mattia

Mattia_Mancini:
Hello Arduino forum!

This is my first post, so please be patient! :slight_smile:

I have always been interested in analogue electronics, and now I decided to learn more about digital electronics playing with an arduino with the intention of building a solar powered weather station.

I have an Arduino Mega2560 as a board, and a SHT15 temperature and relative humidity sensor which work just fine. I want to understand the data transfer protocol (I don't really like black boxes).

I read the datasheet of the SHT15 sensor, and tried to follow along with my oscilloscope.

However, what I get does not seem to match the information in the datasheet, so I don't really understand what's going on.

In the figure attached the line in yellow is the serial clock, the line in blue is the data. There appear to be 16 10ms bits in the data per cycle of the sck, although that already confuses me: given the baud rate of 9600, shouldn't a bit be about 104us?

Overall, in a 2s period the oscilloscope triggers 3 clk pulses corresponding (for the attached image) to the following data:
1- 0001100001110100
2- 0000100010011100
3- 0001100001111001

Usually, the data corresponding to the first and third clk pulse start with 00011 (maybe it's the temperature command in Table4?), the second pulse can change (I saw e.g. 0000011..., I have not yet seen the 00101 for RH). I can't really seem to get my head around understanding what's on the datasheet and how it matches with what I see on the oscilloscope.

I have set a 5s delay between measurements, and my code is extremely simple:

#include <SHT1X.h>
SHT1x sht15(A4, A5);//Data, SCK

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print(sht15.readTemperatureC());
Serial.print(',');
Serial.print(sht15.readHumidity());
Serial.println();
delay(5000);
}

Can anyone enlighten me?

Thank you very much!
Mattia

op image:

you are confusing Serial with serial data.

the baud rate you set for Serial is for your serial monitor output.

The SHT15 communication is basically like how you would operate a shift register; you have a clk line and a data line. the clk line would then shift in/out whatever level is on the data line on every pulse clk line receives.

just delve into the SHT15 library if you want to understand how the communication is set up! :slight_smile:

hope that help clarify a bit.

I cannot believe that the posted picture shows the (working) communication with a SHT15 sensor where yellow is the clock signal and blue is the data signal. I don't own an SHT15 to check myself but if this shows a working communication the datasheet was completely wrong.

I tested another sensor (a BMP180, I2C protocol). The BMP180 looks exactly like it's shown in its datasheet.

Please post a (sharp) picture of your setup!

Remember: the SDA/SCL pins of the Mega2560 are not connected to A4/A5!