CJMCU-75 temp module question

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

Moderator: Benj

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

CJMCU-75 temp module question

Postby viktor_au » Thu Oct 11, 2018 5:27 am

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 2023 times

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

Re: CJMCU-75 temp module question

Postby Benj » Thu Oct 11, 2018 12:32 pm

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.
These users thanked the author Benj for the post:
viktor_au (Thu Oct 11, 2018 10:23 pm)
Rating: 5.26%
 

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Thu Oct 11, 2018 10:22 pm

Thank you Benj

Will try

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Fri Oct 12, 2018 12:16 am

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: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: CJMCU-75 temp module question

Postby kersing » Fri Oct 12, 2018 12:29 am

Could you try divide by 2? (So celcius = celcius / 2)
These users thanked the author kersing for the post:
viktor_au (Fri Oct 12, 2018 8:15 am)
Rating: 5.26%
 
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Fri Oct 12, 2018 8:15 am

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: CJMCU-75 temp module question

Postby medelec35 » Fri Oct 12, 2018 10:08 am

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?
These users thanked the author medelec35 for the post:
viktor_au (Fri Oct 12, 2018 12:09 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Fri Oct 12, 2018 12:09 pm

Thank you medelec35.
It works.

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: CJMCU-75 temp module question

Postby medelec35 » Fri Oct 12, 2018 1:15 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Fri Oct 12, 2018 10:49 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: CJMCU-75 temp module question

Postby medelec35 » Fri Oct 12, 2018 11:07 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Fri Oct 12, 2018 11:14 pm

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 1928 times
Last edited by viktor_au on Sat Oct 13, 2018 1:13 am, edited 1 time in total.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: CJMCU-75 temp module question

Postby medelec35 » Sat Oct 13, 2018 9:22 am

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3450 times
Contact:

Re: CJMCU-75 temp module question

Postby medelec35 » Sat Oct 13, 2018 9:22 am

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?
These users thanked the author medelec35 for the post:
viktor_au (Sat Oct 13, 2018 11:19 am)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

viktor_au
Posts: 122
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 21 times
Been thanked: 31 times
Contact:

Re: CJMCU-75 temp module question

Postby viktor_au » Sat Oct 13, 2018 11:18 am

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.