Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.

Log in or register to post/reply in the forum.

CR1000X I2C Communication? Not even showing up in CRBasic Editor

Waq Aug 22, 2018 02:46 PM

Hey everyone,

Very new to this datalogger programming. learning as I go, one brick wall I've come across is that there is absolutely no mention of I2C (or even SPI-12) functions in the CRBasic Editor (version 3.7 is installed). The product manual lists support for I2C protocol. And there is a question on this website that pops up with an answer as of last year using commands such as I2COpen, I2CRead, I2CWrite etc. in their program, but why can I find no documentation on this.

Also no generic option available in the Short Cut sensors menu as well. 

If anybody has successfully read from a humidity/temperature sensor in I2C or interfaced with I2C in general on these dataloggers could I get some tips on where to get started? Thank you. 

JDavis Aug 23, 2018 08:48 AM

Run the CR1000X OS2 update on your computer, and the instructions will show up in CRBasic Editor.

Waq Aug 23, 2018 10:48 AM

Thanks, installing the latest OS for CR1000x pulled up the I2C commands in the CRBasic Help. Will keep this thread posted soon as to how the connection is going and/or any problems encountered. 

Waq Aug 28, 2018 11:59 AM

I am having a problem with the I2C Communication on a SHT31-D RH/Temp sensor with the CR1000X Datalogger 

It is currently reading a -1 value in my return variable when I call in the I2CRead option in my program.

Public TemporaryRead as Long

  PortPairConfig(C5,2) 'set C5 for SCL and C6 for SDA and at 3.3V'
  I2COpen (C5, 500000) '500 mHZ start at port C5
  I2CWrite (C5, &H44, &H2130, 3, &H2)
  Scan (1, Sec, 0, 0)
    PanelTemp (PTemp, 60)
    Battery (Batt_Volt)
    I2CWrite (C5, &H44, &HE000, 2, &H2)
    I2CRead (C5, &H44, TemporaryRead, 4, &H5)

this is the link to the sensor datasheet

Pages 9 and 11 are where I am getting my command instructions to pass to the sensor as well as the address. I am using address 0x44 and attempting periodic acquisition mode at 1 mps

Any advice as to where my program is going wrong would be appreciated, thanks. Maybe I'm inputting the instructions wrong? or missing a step? or maybe specifying the wrong number of bytes in the Read and Write methods 

Waq Sep 7, 2018 09:53 AM


Program and sensor was working, had to reduce the bitrate down to 50000 Hz (my program originally had it at 500000). There is an upper limit to this sensor apparently. 

alirashidniaghi68 May 28, 2019 12:57 PM

I am trying to connect MLX sensor with 0x5A address but the program fail to compile and gives an error related to undeclared variable and illegal parameter of 0x5A. Anyone has any idea how to address this in I2CWrite and Read?

DataLoggerNut May 28, 2019 04:37 PM

Use &h05A syntax for entering in the hexadecimal slave address 0x05A.

i.e.: I2CWrite(C3,&H5A,&h06,1,&H2 )'<-- Send register address to reading from.

--dd-- Oct 23, 2020 08:00 AM

Hi, following the example above (changed to 50 000 hz) i also read -1

SHT31 sensor is wired to external 3.3v

SCL --> C1

SDA --> C2

4k7 pull-up resistors to SCL and and SDA

What can i do wrong?

Public PTemp, Batt_Volt
Public TemporaryRead As Long

  PortPairConfig(C1,2) 'set C1 for SCL and C2 for SDA and at 3.3V'
  I2COpen (C1, 50000) '50 kHZ start at port C1
  I2CWrite (C1, &H44, &H2130, 3, &H2)
  Scan (3, Sec, 0, 0)
    PanelTemp (PTemp, 60)
    Battery (Batt_Volt)
    I2CWrite (C1, &H44, &HE000, 2, &H2)
    I2CRead (C1, &H44, TemporaryRead, 4, &H5)


stevieb Jan 31, 2021 05:56 PM

Does anyone have a working sample CR1000X program with wiring for the SHT31-D they care to share?

Roqu Apr 14, 2021 07:16 AM

after long tinkering with a CR1000x, I found the following solution

'CR1000X Series Datalogger
'I2C Test using a SHT85'

'* Wiring *
'VDD Sensor on 5V of the logger
'C1 Clock (osziloscope channel 1)
'C2 Data (osziloscope channel 2)
'Pull up resistors 2.2 kOhm between C1 and 5V
'Pull up resistors 2.2 kOhm between C2 and 5V
'higher values of the pull ups give a terrible signal shape
'but it might be that it works too


'* Constants and Variables *
Const Scanintervall=1 'Sekunden
Public PTemp
Public Batt_volt
' Commands should be given as variables!
' both works: "single shot" within the "Scan"
' Dim DReg As Long = {&H24000000} 'Measurement command for single shot data aquisition
' or
' "starting periodic aquisition" before the "Scan" and "Fetch Data" within
Dim Mcmd As Long = {&H21300000} 'Measurement command for periodic data aquisition
Dim DReg As Long = {&HE0000000} 'Fetch Data command, Sensor sends 6 bytes
Public dest(2) As Long ' is able to read up to 8 bytes
Public ta0 As Long ' raw data
Public rh0 As Long
Public ta As Long ' final temperature
Public rh As Long

'* Main Program *
PortPairConfig(C1,1) '
I2CWrite (C1, &H44, Mcmd, 2,&H02)
Scan (Scanintervall,Sec,0,0)
PanelTemp (PTemp, 60)
Battery (Batt_volt)
I2CWrite (C1, &H44, DReg, 2,&H02)
I2CRead (C1, &H44, dest, 6, &H05)
ta = -45 + 175*ta0/65535
rh = 100 * rh0/65535

Log in or register to post/reply in the forum.