CJMCU-75 temp module question

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

CJMCU-75 temp module question

Post 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?
Attachments
vcjmcu75.jpg
vcjmcu75.jpg (70.12 KiB) Viewed 7124 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: CJMCU-75 temp module question

Post 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.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post by viktor_au »

Thank you Benj

Will try

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post 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?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: CJMCU-75 temp module question

Post by kersing »

Could you try divide by 2? (So celcius = celcius / 2)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CJMCU-75 temp module question

Post 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?
Martin

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post 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?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CJMCU-75 temp module question

Post 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.
Martin

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post by viktor_au »

Wrong post
Last edited by viktor_au on Sat Oct 13, 2018 12:41 am, edited 2 times in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CJMCU-75 temp module question

Post 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.
Martin

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post 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).
Attachments
LM75_diagram1.jpg
LM75_diagram1.jpg (65.46 KiB) Viewed 7029 times
Last edited by viktor_au on Sat Oct 13, 2018 1:13 am, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CJMCU-75 temp module question

Post 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
Martin

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CJMCU-75 temp module question

Post 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?
Martin

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: CJMCU-75 temp module question

Post 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.

Post Reply