Hardware: FEZ Raptor
SDK: 4.3
I am attempting to use Ascended Temperature MCP9701(https://www.ghielectronics.com/community/codeshare/entry/81) in my project, but I am running into these two errors:
and
tempSensor.cs code:
// Ascended International
//
// Copyright (c) 2010
//
// All Rights Reserved
// ------------------------------------------------------------------------------
// * DO NOT REMOVE THIS HEADER. DO NOT MODIFY THIS HEADER *
/**********************************************************************************
* You may use this class for non-commercial purposes. If you wish to use this *
* software for a commercial purpose please contact Ascended International at: *
* mark@ ascended.com.au *
* *
* When using this free class, no warranty express or implied is offered. *
* In no event shall Ascended International, any of it's employees or shareholders*
* be held liable for any direct, indirect, special, exemplary, incidental or *
* consequential damages however caused. *
* *
* If you modify this class, please add your name and the date below as a *
* contributor, without removing this notice or modifying it in any way, shape *
* or form. *
**********************************************************************************/
using System;
using Microsoft.SPOT.Hardware;
#if NETDUINO
using SecretLabs.NETMF.Hardware;
#else
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.System;
#endif
namespace Ascended.SPOT.Sensors.Temperature
{
public interface ITemperatureSensor : IDisposable
{
float GetTemperatureInC();
float GetTemperatureInF();
int MaximumTemperatureCapability { get; }
int MinimumTemperatureCapability { get; }
}
public class MCP9701 : ITemperatureSensor
{
#if NETDUINO
protected AnalogInput sensor;
#else
protected AnalogIn sensor;
#endif
/// <summary>
/// Create a new base instance of the temperature sensor.
/// </summary>
/// <param name="pin">Pin the sensor's vout is connected to.
public MCP9701(Cpu.Pin pin)
{
// http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en022289
MaximumTemperatureCapability = 125;
MinimumTemperatureCapability = -40;
RequiredVoltage = 2.7f;
#if NETDUINO
sensor = new AnalogInput(pin);
sensor.SetRange(0, 3300);
#else
sensor = new AnalogIn((AnalogIn.Pin)pin);
sensor.SetLinearScale(0, 3300);
#endif
}
public float GetTemperatureInC()
{
// gain = 19.53 mV/Deg C
int mv = sensor.Read() - 400; // 400 = 0c
return mv / 19.53f;
}
public float GetTemperatureInF()
{
return GetTemperatureInC() * 9 / 5 + 32;
}
public int MaximumTemperatureCapability { get; protected set; }
public int MinimumTemperatureCapability { get; protected set; }
public float RequiredVoltage { get; protected set; }
public void Dispose()
{
sensor.Dispose();
sensor = null;
}
}
}
Program.cs code:
using System;
using System.Collections;
using System.Text;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Hardware;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.SocketInterfaces;
using GHIElectronics.NETMF.Hardware;
using Ascended.SPOT.Sensors.Temperature;
namespace iog
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
Mainboard.SetDebugLED(true);
this.usbSerial.Configure(9600, SerialParity.None, SerialStopBits.One, 8, HardwareFlowControl.NotRequired);
this.usbSerial.Port.NewLine = "\r";
this.usbSerial.Port.LineReceived += this.Port_lineReceived;
}
private void Port_lineReceived(Serial sender, string line)
{
/*Demo usbSerial communication to test I/O data which works :-)*/
Debug.Print(line);
if (line == "Off") Mainboard.SetDebugLED(false);
else if (line == "On") Mainboard.SetDebugLED(true);
/*End usbSerial Demo*/
/*Now get MCP9701 value and send the value usbSerial*/
using (ITemperatureSensor sensor = new MCP9701((Cpu.Pin)AnalogIn.Pin.Ain0))
{
while (true)
{
Debug.Print("Temperature: " + sensor.GetTemperatureInC() + "c");
Thread.Sleep(1000);
}
}
}
}
}
Errors:
[quote]Error 1 The type or namespace name âNETMFâ does not exist in the namespace âGHIElectronicsâ (are you missing an assembly reference?)
C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\tempSensor.cs 28 22 iog
Error 2 The type or namespace name âNETMFâ does not exist in the namespace âGHIElectronicsâ (are you missing an assembly reference?)
C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\tempSensor.cs 29 22 iog
Error 3 The type or namespace name âAnalogInâ could not be found (are you missing a using directive or an assembly reference?)
C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\tempSensor.cs 48 19 iog
Error 4 The type or namespace name âAnalogInâ could not be found (are you missing a using directive or an assembly reference?)
C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\tempSensor.cs 66 26 iog
Error 5 The type or namespace name âAnalogInâ could not be found (are you missing a using directive or an assembly reference?)
C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\tempSensor.cs 66 36 iog
Error 6 The type or namespace name âNETMFâ does not exist in the namespace âGHIElectronicsâ (are you missing an assembly reference?)
C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\Program.cs 19 22 iog
Error 7 The name âAnalogInâ does not exist in the current context C:\Users\Rich\documents\visual studio 2012\Projects\iog\iog\Program.cs 47 69 iog[/quote]
I attached an image of my included References.