Page 1 of 1

CJMCU-75 temp module question

Posted: Thu Oct 11, 2018 5:27 am
by viktor_au
Is it possible to use CJMCU-75 temp module with LM75b component?
And if it is:
- how to configure the i2c pads on this module to get the i2c address correct?

Re: CJMCU-75 temp module question

Posted: Thu Oct 11, 2018 12:32 pm
by Benj
Hello,

I cannot say 100% as the module has a LM75A instead of the LM75B but it looks like it should be compatible and work correctly.

Currently the address should be:

A0 = VCC
A1 = GND
A2 = GND

Taken from this line of the C code.
FCR_RETVAL = FC_CAL_I2C_Transaction_Init_1(0x49);
Inside the Initialise function.
MX_UINT8 FCD_0e021_LM75B_DigitalTemperature1__Initialise()
We should be able to add a new property to the component to allow the user to control the address.

Re: CJMCU-75 temp module question

Posted: Thu Oct 11, 2018 10:22 pm
by viktor_au
Thank you Benj

Will try

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 12:16 am
by viktor_au
Re: i2c address and pads
It works.

Re: temperature value
I used the code from the post of medelec35 » Wed Sep 16, 2015 (for DS18B20)

- Read Celsius as Int
- Celsius = Celsius * 49 / 10
- CelsiusString = ToString$ (Celsius)
- Length = Length$ (CelsiusString)
- TempString = Left$ (CelsiusString,Length - 1)

However the readings are wrong.
I cannot figure out how to change the 49 value to use it with CJmcu-75.
Any help?

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 12:29 am
by kersing
Could you try divide by 2? (So celcius = celcius / 2)

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 8:15 am
by viktor_au
RE: Could you try divide by 2?

I did. Does not work. The result is apprx. 300C

---------------------------------------------------------------------
I did some simple calculations.
LM75 raw value was (apprx.) 6240 at room temp 25 deg C.
-----------------
6240 / 25 = 249.6 ->per 1 degree
6240 / 250 = 24.96
-----------------
FC8 calculation-> Celsius = Celsius / 250
----------------
Sensor shows 25 deg C.

??? I am not sure if this is a good way to calculate the value for that temp. module.

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 10:08 am
by medelec35
Hi
viktor_au wrote: I used the code from the post of medelec35 » Wed Sep 16, 2015 (for DS18B20)

- Read Celsius as Int
- Celsius = Celsius * 49 / 10
- CelsiusString = ToString$ (Celsius)
- Length = Length$ (CelsiusString)
- TempString = Left$ (CelsiusString,Length - 1)

However the readings are wrong.
Why did you use the calculations for a component that produces completely different values for the same temperature?
For example, the DS18B20 result is in BCD format so you need to convert the BCD to a temperature reading.
You can * 10 so

Code: Select all

Temperature = (Raw >> 4) * 10 + (Raw & 15)
If Raw = 345 then Temperature = 219, so you just divide by 10 = 21.9
you need to format strings to place d.p in the correct palce.
With LM75 s. Temperature data is represented by a 9-bit, two's complement
word with an LSB (Least Significant Bit) equal to 0.5°C:
So you will need to read two bytes first is MSB and second is LSB
Then I believe temperature (for 0C and above):

Code: Select all

Temp = (((MSB << 8) | LSB) >> 7) * 0.5
For temperatures below 0:

Code: Select all

Temp =(((((MSB << 8) | LSB) >>7) * 0.5) -256)
What you could do is if result > 125 then use temperatures below 0 calculation.
Not able to confirm at the time of writing if the above calculations are correct or not?

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 12:09 pm
by viktor_au
Thank you medelec35.
It works.

The temperature is a bit high (one-two degrees).
Should I change 0.5 to tune the temperature?

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 1:15 pm
by medelec35
Glad it works for you.
That would be normal as if you look at the datasheet
The accuracy is +/- 2C from -25 C to +100C
So you could have an offset.
What normally so is have a small offset e.g Temp = Temp + 1 or Temp = Temp - 1 depending on which way you need to go.
For greater accuracy just use floating point then you can use 1.2 etc. instead of an integer.
Don't forget the the measuring equipment also has an tolerance so that requires taking in to account as well.

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 10:49 pm
by viktor_au
Wrong post

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 11:07 pm
by medelec35
Hi,
In my earlier post I stated:
medelec35 wrote:What you could do is if result > 125 then use temperatures below 0 calculation.
So you will need a decision branch

Code: Select all

If temp > 125 then Temp =(((((MSB << 8) | LSB) >>7) * 0.5) -256)
Since its two's complement the When reading temperatures below freezing, Temp result will read above 125 as MSB is set to 1 for negative numbers.
So your flowchart is wrong.

Re: CJMCU-75 temp module question

Posted: Fri Oct 12, 2018 11:14 pm
by viktor_au
By using medelec35 advice I have checked the LM75 datasheet.
The hard to understand part was about the two's complement format.
I need more time with that.

For now I have stopped at this diagram (please correct and add more info).

Re: CJMCU-75 temp module question

Posted: Sat Oct 13, 2018 9:22 am
by medelec35
Hi,
You edited your post as the post I'm referring to where the flowchart is wrong is just above this post

Code: Select all

Fri Oct 12, 2018 11:14 pm
.
refer to my post with date and time of:

Code: Select all

Fri Oct 12, 2018 11:07 pm

Re: CJMCU-75 temp module question

Posted: Sat Oct 13, 2018 9:22 am
by medelec35
Hi,
Yes The flowchart now looks correct.
You have got TempInt >125 instead of TempInt <0
It would be better if corrections are on a new post.
Does it work now?

Re: CJMCU-75 temp module question

Posted: Sat Oct 13, 2018 11:18 am
by viktor_au
Thanks Martin.
All good.
I am not able to check the minus temperature (for now, will do it later), but the code works OK.
Appreciate your help.

P.S. I work with the DHT22 module now. A few days ago Benj has updated this component and I am able (now) to read the temp/hum without any problems. Well.. Only during the init stage the DHT22 shows 0 for success and 1 for error as well... Not sure why.
But this is another story...
Thanks again.