Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

delbiorobi

Member Since 03 Nov 2012
Offline Last Active Sep 24 2013 07:50 PM
-----

Posts I've Made

In Topic: I2C & temperature sensor TCN75A

18 March 2013 - 07:18 AM

I'm having the same issues with my TC74 sensor. I'm new to the C# world. Could you post your entire VisualStudio solution? So I could learn from it? Thanks.

 

 

namespace TCN75A example{    public class Program    {        private static Byte[] rxbuffer = new Byte[2];         private static I2CDevice tempSensor;         private static int tempReg = 0;        private static float tempValue = 0;              public static void Main()        {            tempSensor = new I2CDevice(new I2CDevice.Configuration(0x48, 400));            I2CDevice.I2CTransaction[] settings = new I2CDevice.I2CTransaction[]            {                I2CDevice.CreateWriteTransaction(new Byte[] { 0x01, 0x60 }),            };            tempSensor.Execute(settings, 500);            TimerCallback tempDelegate = new TimerCallback(tempRead);            Timer tmrTemperature = new Timer(tempDelegate, null, 0, 60000);			public static void tempRead(Object currentTime)			{				I2CDevice.I2CTransaction[] rd = new I2CDevice.I2CTransaction[]						{							I2CDevice.CreateWriteTransaction(new Byte[] { 0x00 }),							I2CDevice.CreateReadTransaction(rxbuffer)						};				tempSensor.Execute(rd, 500);				tempReg = rxbuffer[0];				tempReg = tempReg << 8;				tempReg += rxbuffer[1];				tempReg = tempReg >> 4;				tempValue = (float)tempReg / 16;			}		}	}	}

In Topic: I2C & temperature sensor TCN75A

05 November 2012 - 10:42 AM

I2CDevice.CreateWriteTransaction(new byte[] { 0x01, 0x60 })

try this.


Yes, it works!
Thank you very much NooM.

In Topic: I2C & temperature sensor TCN75A

04 November 2012 - 09:24 PM

It seems that
I2CDevice.I2CTransaction[] settings = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(new Byte[1] { 0x01 }),
                I2CDevice.CreateWriteTransaction(new Byte[1] { 0x60 })
            };
is unable to write the registers of TCN75A.
0x01 point to config register, and 0x60 change the temperature resolution, but output value is not affected to these changes.
Someone else uses it and has the same problem?

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace NetduinoPlus_Temp_01
{
    public class Program
    {
        public static void Main()
        {
            Byte[] rx = new Byte[2];
            int tempreg = 0;
            float temperature = 0;

            I2CDevice.Configuration config = new I2CDevice.Configuration(0x48, 400);

            I2CDevice sensore = new I2CDevice(config);

            I2CDevice.I2CTransaction[] settings = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(new Byte[1] { 0x01 }),
                I2CDevice.CreateWriteTransaction(new Byte[1] { 0x60 })
            };

            I2CDevice.I2CTransaction[] rd = new I2CDevice.I2CTransaction[]
            {
                I2CDevice.CreateWriteTransaction(new Byte[1] { 0x00 }),
                I2CDevice.CreateReadTransaction(rx)
            };

            sensore.Execute(settings, 500);

            while (true)
            {
                sensore.Execute(rd, 500);

                tempreg = rx[0];
                tempreg = tempreg << 8;
                tempreg += rx[1];
                tempreg = tempreg >> 4;

                temperature = (float)tempreg / 16;

                Debug.Print("Temperatura attuale: " + temperature.ToString() + "°C");

                Thread.Sleep(2000);
            }

        }
    }
}

In Topic: I2C & temperature sensor TCN75A

04 November 2012 - 04:15 PM

Thank you Noom,
the problem was pull-up resistors; i was convinced that they were integrated into the temperature sensor board, but it's not: now i can read temperature output.
I'm trying your class, very useful, because i'll use 3 or 4 sensor with I2C.


did you use pull-up resistors on your wiring?


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.