Temperature - Hyp-ed/hyped-2024 GitHub Wiki

Using I2C to get values

This will be a quick guide on how you would use commands to get values from the temperature sensor.

1 - Wiring the temperature sensor to the BeagleBone

For this step just follow the image below to connect the pins to the right slots. Make sure that it is the P9 slots.

Black wire - ground Red wire - 3.3V Green wire - I2C tick Blue wire - I2C

2 - Going into the BeagleBone

Once you connect the BeagleBone to your laptop then open ubuntu and type in the command

ssh [email protected]

If it gives out nothing then just wait for a minute and then try again

It will then request a password from you which is temppwd

3 - Getting values with I2C

Now use the below commands to get the required information from the board

i2cdetect -l -- lists all the different busses on the beaglebone

i2cdetect -r 2 -- connect to the i2c 2nd bus, a table to registries will appear and the relevant register names would appear e.g. 38 3f

The next step is to set each of the modes, for the addresses of the beaglebone to be in continuous mode so that the board would constantly be getting new information from the sensor.

i2cset -y 2 0x3f 0x04 0x3c -- For one sensor

i2cset -y 2 0x38 0x04 0x3c -- For the other sensor

As for this breadboard, there are 2 sensors we will have 2 registries (being 0x38, 0x3f)

Next, you will get the information from the sensor, this can be done by typing these commands into the command line in ubuntu:

i2cget -y 2 0x3f 0x06 -- This is getting the Low temp which is the smaller insignificant value for the temperature

i2cget -y 2 0x3f 0x07 -- This is getting the High temp which would be the larger more significant value for temperature

i2cget -y 2 0x38 0x06 -- This will be doing the same thing but just for the second sensor

i2cget -y 2 0x38 0x07

The image below is an example of how it would look in the command line

Conversion

Then once you get your values go to the datasheet (Page 23 onwards) and concatenate the values together to get the temperature. e.g. if you get 0x40 (being your high value), and 0xec (the low value) then to concatenate it would be 0x40ec. Perform hexadecimal to decimal (base 10) conversion and multiply that value by 0.01 to get your temperature.

⚠️ **GitHub.com Fallback** ⚠️