How to use EVAL-CN0428 by I2C with a generic microcontroller?

Hi to everyone here
please,I'm in urgent need to use the capabilities of the EVAL-CN0428,in conjunction with an existing microcontrollor board,connected with an EVAL-M355-ARDZ-INT board.


My question is:
Is there a guide about how to use CN0428 with a generic microcontroller?


I have the ADICUP3029 code,ADICUP3029 board and CN0428 code and board.
Despite this, I'm not able to reply on my microcontroller the communication necessary to have PH,conductivity and temperature measurements.
On my board an I2C port and some GPIO's are available
By now I need only 1 CN0428,so there is no need of I2C address reassignement.
I have experienced communication,but  without properly understanding details.

I have found some unexpected behaviour:
1)The CN0428,by default ,acknowledges the I2C address 0x98
Changing its address with command 0x80 it still acknowledges the I2C address 0x98,is it correct?
I kept low the CS pin during this operation,and I waited for 1 second,as in the ADICUP3029 example:
this is my code about it

    SS1_LOW;
	Delay(100);
	i2c_write_data_buffer[0]=SET_I2C_ADDRESS;
	i2c_write_data_buffer[1]=new_addr;  
	hal_st=HAL_I2C_Master_Transmit(&hi2c1,old_addr, i2c_write_data_buffer, 2, 50);
	Delay(1000); /* wait for selected slave to change its address */
	SS1_HIGH;

2)Lot of communication between boards is done sending ASCII values on I2C,for example ,when requesting measuresensor by PuTTY terminal , a string is sent by ADICUP3029
to CN0428 :   cmeasuresensor\r   ,then other strings are read by I2C reads from CN0428,they look the same of  strings printed on PuTTY terminal.
I am not able to relate these strings with I2C commands listed in adi_m355_gas_sensor.h

3)Still about strings,i'm able to read back in some way the welcome message:Welcome to Water Quality Demo!Sensor Site: 1!  ..but I wonder how it works:
If I read the I2C buffer more than necessary CN0428 pulls down(stretches?) the SCL pin,and it remains low unless I reset the CN0428,so, what tells to I2C master how long is the message to be read?

4)It looks that long delays are necessary between reset and some operations,is there a list of these timings?I mean without searching them one by one in ADICUP3029 CN0428 example code?
Actually the code is small ,but I would like to be shure to respect all the timings and dont miss anyone.

Thanks for your help or your attention.

Diego Colombo
Milan,Italy.









Noticed some errors in caps,and other errors
[edited by: Diegotrex at 8:35 AM (GMT -5) on 18 Nov 2021]
  • Hi Diego, we're looking into this and will reply shortly.

    -Mark

  • Thanks Mark
    I checked some Q&A in the forum before sending my message,but Ii missed this one.
    CN0428 default firmware communication protocol - Q&A - Reference Circuits - EngineerZone (analog.com)
    I read it only after posting and before your answer.
    That answers to one of the questions, and contains fundamental infos:

    In fact analyzing the code and the answer it looks there is a kind of polling,
    command 'a'=0x61 is sent(I call it command but maybe is better
    consider it a register address?)
    then a 'c'=0x63  is issued followed by read of the proper amount of data,
    this looks compliant to the code in cn0428_cn0429.cpp rows from 1241 to 1255

    	do { /* 0.1s loop waiting for slave */
    		delay_ms(95);
    		numbytes = 0;
    		pGasSensor->I2CReadWrite(READ,
    					 BYTES_TO_READ,
    					 (uint8_t *) &numbytes,
    					 1);
    		delay_ms(5);
    
    		/* read <=255B chunks until slave buffer is empty */
    		while (numbytes > 0) { /* data available */
    			tempError = pGasSensor->I2CReadWrite(READ,
    							     0x63,
    							     &Slave_Rx_Buffer[0],
    							     numbytes);


    Hoping that is useful to the discussion and other readers of this forum:
    20 or 0x14 should be the device address assigned to my CN0428 board.
    Is it correct?

    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    22' + NAK Yes,22 chars
    Setup Write to ['20']
    c
    Count of chars Setup Read to ['21']
    1 T
    2 e
    3 m
    4 p
    5 e
    6 r
    7 a
    8 t
    9 u
    10 r
    11 e
    12 :
    13 '
    14 0
    15 8
    16 4
    17 .
    18 3
    19 5
    20 1
    21 \r
    22 \n + NAK
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK no
    Setup Write to ['20']
    a
    Setup Read to ['21']
    16' + NAK Yes,16 chars
    Setup Write to ['20']
    c
    Count of chars Setup Read to ['21']
    1 p
    2 H
    3 :
    4 '
    5 1
    6 3
    7 .
    8 2
    9 4
    10 3
    11 5
    12 \r
    13 \n
    14 \r
    15 \n
    16 ~ + NAK
    Setup Write to ['20']
    a
    Setup Read to ['21']
    0' + NAK


    Thanks

  • And thank you for posting your findings! I see one dangling question about the device address. I'll consult the apps engineer, but in general, there's no harm in simply scanning all addresses to see how a particular board is configured.

    Here's an Arduino Uno address scanner:

    https://github.com/analogdevicesinc/Linduino/blob/master/LTSketchbook/Utilities/I2C_Address_Scan/I2C_Address_Scan.ino

    that should be pretty easy to port to your favorite platform.

    -Mark

  • Hello Diego,

    Sorry for the delay. I just wanted to add a little bit about the I2C addressing in this project.

    "The CN0428,by default ,acknowledges the I2C address 0x98
    Changing its address with command 0x80 it still acknowledges the I2C address 0x98,is it correct?"

    The default I2C address used by the ADuCM355 in the CN0428 project is 0x4C (7-bit address value, so left-shifted by 1 will give you the 0x98). The ADICUP3029 uses that address as a general call for avoiding potential I2C address conflicts. 0x4C is treated as write-only by the ADICUP3029 since all sensor board nodes are listening to that address simultaneously.

    At start-up, the ADICUP3029 attempts to assign new I2C addresses to each of the 4 sites. It does this by holding a GPIO low for the site it would like to address and then sending an address change request command to 0x4C. All ADuCM355's on the bus will see the command, but the ADuCM355 only changes its address if it sees that GPIO is low, otherwise the request is ignored. Finally, ADICUP3029 checks for a response from the new address to see if an actual sensor was found. Then it reports which sites and which new addresses gave a response.

    Thanks to a feature of the ADuCM355 that allows it to respond to two different I2C addresses, the sensor nodes are still listening on 0x4C even after being assigned new addresses on initialization. This is mainly for reset behavior, so if a reset was issued to the ADICUP3029, it can go through initialization like normal even if each ADuCM355 was not reset. Therefore the behavior you described is expected for the system.

    I hope this helps.
    Thanks,
    Scott