Hello,
i wrote a small programm to messuare the temperature und the humid of the air with my panda II board,
using System;
using Microsoft.SPOT;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.IO;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using System.Threading;
using System.IO;
using Microsoft.SPOT.IO;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
AnalogIn temp, feucht;
double x, y;
int n=0;
temp = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An1);
temp.SetLinearScale(0, 5000);
feucht = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An3);
feucht.SetLinearScale(0, 5000);
//DateTime datum = new DateTime(2012, 07, 25, 11, 46, 11);
//DateTime datum = DateTime.Now;
//Utility.SetLocalTime(datum);
if (PersistentStorage.DetectSDCard())
{
Debug.Print("Sd Karte erkannt");
}
else
{
Debug.Print("nicht erkannt");
}
PersistentStorage sd;
sd = new PersistentStorage("SD");
sd.MountFileSystem();
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
FileStream stream = new FileStream(rootDirectory + @ "\werte.txt", FileMode.Create);
StreamWriter writer = new StreamWriter(stream);
while (true)
{
n++;
x = temp.Read();
x = x / 14.601;
string stringt;
stringt = x.ToString();
stringt = stringt.Substring(0, 5);
y = feucht.Read();
y = y / 61.79;
string stringf;
stringf = y.ToString();
stringf = stringf.Substring(0, 5);
Debug.Print(DateTime.Now.ToString());
Debug.Print(n.ToString());
Debug.Print("Temperatur: " + stringt + " °C");
Debug.Print("Rel. Luftfeuchte: "+stringf+" %");
Debug.Print("________________________________________");
writer.WriteLine("Temperatur: " + stringt + " °C");
/*
textFile.WriteLine("Temperatur: " + stringt + " °C");
textFile.WriteLine("Rel. Luftfeuchte: " + stringf + " %");
textFile.WriteLine("________________________________________");
textFile.Close();
*/
Thread.Sleep(2000);
}
}
}
}
Sd card has the format FAT.
The problem is that no file is created on the sd card.
What is my fault?
if theres anything you dont understand, i will try to translate (german).
greetings
kevin