Wire.write question

Hi,

I have a bunch of sensors running via I2C and am trying to use Wire.write and struggling to get my command to the sensor.

Wire.beginTransmission(channel); // call the circuit by its ID number.
Wire.write(); // transmit the command i want
Wire.endTransmission(); // end the I2C data transmission.

What i am trying to write is "cal,Xfigure" where the Xfigure is a double (eg. 7.00). So essentially it would look like "cal,7.00"..

Any idea on how i would do this?

:confused:

If you want universal compatibility, convert it to text into a character array, transmit it as text, and convert it on the receiving end.

It is unusual for I2C/TWI/Wire sensors to accept ASCII strings. Are these 'sensors' something that has a datasheet? If so you might be reading the datasheet incorrectly.

they are an atlas scientific product where there is a "module" that processes the data which attaches to the sensor

Which atlas scientific product?

Here is the example they provide for talking to their pH probe adapter via I2C:
http://www.atlas-scientific.com/_files/code/ph-i2c.pdf

They use Wire.write(char *); which sends consecutive bytes until it reaches a null character.

The circuit is generally used with async serial which is why it uses command strings instead of binary.

spot on it is the pH and EC circuit

starting to understand it slowly...

so how would this be written?

I have tried to Wire.write() each individual character and that seems to almost work but in no way is it efficient...

I have tried to Wire.write() each individual character and that seems to almost work but in no way is it efficient...

The Wire.write() method is overloaded, to take an array and an number of elements in the array.

Ok so is it this product?

Would be easier if you give a link....here is the datasheet

Your module supports two modes, serial or I2C so you need first to configure the mode and once done use the selected protocol to send your command

Read the documentation for the Wire library. There are three versions of .write():

Wire.write(char); // write a single character
Wire.write(char *); // write consecutive characters until reaching a null
Wire.write(char *, int); // write 'int' consecutive characters