Grove i2cJH on impC001

I am unable to initialize the I2C grove connector on the new impC001. Would anyone point out what’s wrong? This page says to use the hardware.i2cJH for the grove connector. https://developer.electricimp.com/hardware/resources/reference-designs/impc001breakout

My code:
// Configuration code for Grove I2C port on impC001
i2c <- hardware.i2cJH;
// Configure clock speed
i2c.configure(CLOCK_SPEED_400_KHZ);

Server Log:
2018-09-17 12:49:58 -04:00 [Device] ERROR: the index ‘i2cJH’ does not exist

i2cJH is correct, but it wasn’t enabled in impOS in some early releases of the firmware. I’ll contact you directly to make sure you’re on the latest pre-release.

This is because currently, cellular is not on the full release (even number) - it’s on a dev release (odd number, ie 39.x) and hence has a moving target to upgrade to.

It should now upgrade to 39.12 and be happy. Let me know if it doesn’t.

is there documentation or code examples for using i2cJH on the impC001?

the code sequence I was using for uart57 on an imp April board now comes up with bad parameters using i2cJH

happy to study a few examples on how i2cJH differs from uart57 hardware driver commands.

thank you!

uarts and i2cs have different APIs; uarts just send and receive bytes, whereas i2c works with commands and packets.

What are you trying to talk to?

DS18B20

I had been using the code modeled in https://developer.electricimp.com/resources/onewire
This uses UARTs

Have not been able to locate something similar for i2c

thank you!

As you note DS18B20 is onewire. Whilst it’s possible to use a UART to talk onewire (as in that link), the same is not possible with I2C. The protocol can’t generate the onewire waveforms.

However, uartHJKL is on the same pins that go to that grove connector. So, use uartHJKL (with NO_CTSRTS as flags) and the linked example to implement your onewire - you will need a resistor and a diode as noted.

pinH is TX (SDA when it’s i2c) and pinJ is RX (SCL when it’s i2c)

Can HTS221 and DS18B20 co-exists?

On the impC001, the HTS221 is on pins KL and I use i2c = hardware.i2cKL in my code to access it.
I gather from your comments that I could use ow = hardware.uartHJKL to access the DS18B20 on pins HJ

What about possible conflicts?

thank you!

No, they cannot coexist; you can’t mix different types of device on a bus (that’s not an imp limitation, that’s just electrically how things work).

The HTS221 on the impC001 breakout itself is on i2cKL though, so you can use the on-board I2C to talk to that HTS221, and use the grove uartHJKL to implement a 1-wire interface.

If you have an HTS221 on a grove (and need remote sensing) then put it on the grove connector, and use another UART to implement your 1-wire interface. For example, uartYAB is available on the 0.1" headers of the Mikrobus connector, or uartNU is available on the GPS connector and the 0.1" breakout strips.

Hi Hugo,
thanks for clarifying and your suggestions.
Everything is working properly now.

Thank you!