I bought some DS1631Z thermo sensors, but I have big troble to communicate through I2C (using one per netduino),
I think I try every example I found through google, but nothing work for me
If you know about any working code, please let me know, or
if itās not very difficult, my config is all A pins grounded for someone who know I2C and can write code example fo me.
Thanks so much, after third day of trying, I think itās impossibleā¦
@ munderhill - Hello, thank, I have it.
All three A pins grounded, ground grounded, vcc I try with 3,3 and 5V too, no change and SD and SC are connected to 3,3/5V through 2,2/4,7K resistor.
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace NetduinoApplication2
{
public class Program
{
public static void Main()
{
//create I2C object
//note that the netmf i2cdevice configuration requires a 7-bit address! It set the 8th R/W bit automatically.
I2CDevice.Configuration con = new I2CDevice.Configuration(0xAA, 400);
I2CDevice MyI2C = new I2CDevice(con);
// Create transactions
// We need 2 in this example, we are reading from the device
// First transaction is writing the "read command"
// Second transaction is reading the data
I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[2];
// create write buffer (we need one byte)
byte[] RegisterNum = new byte[1] { 2 };
xActions[0] = I2CDevice.CreateWriteTransaction(RegisterNum);
// create read buffer to read the register
byte[] RegisterValue = new byte[1];
xActions[1] = I2CDevice.CreateReadTransaction(RegisterValue);
// Now we access the I2C bus using a timeout of one second
// if the execute command returns zero, the transaction failed (this
// is a good check to make sure that you are communicating with the device correctly
// and don't have a wiring issue or other problem with the I2C device)
if (MyI2C.Execute(xActions, 1000) == 0)
{
Debug.Print("Failed to perform I2C transaction");
}
else
{
Debug.Print("Register value: " + RegisterValue[0].ToString());
}
}
}
}
before:
Dim config As I2CDevice.Configuration = New I2CDevice.Configuration(1, 100)
Dim i2c As I2CDevice = New I2CDevice(config)
Dim write As Byte = ""
Dim read As byte = new byte[1]
' create I2C write and read transaction
Dim i2cTx As I2CDevice.I2CTransaction = New I2CDevice.I2CTransaction(1)
i2cTx(0) = I2CDevice.CreateWriteTransaction(write)
i2cTx(1) = I2CDevice.CreateReadTransaction(read)
' execution
i2c.Execute(i2cTx, I2C_TIMEOUT)
and before I found some libraries, but nothing with good result.
If I am reading the datasheet correctly, I think the address starts at 0x48 and goes through 0x4F, so with all the address lines tied to ground the would be 0x48.