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.

Zeus

Member Since 22 Feb 2012
Offline Last Active Jun 27 2012 07:45 PM
-----

Topics I've Started

Data logger

10 April 2012 - 08:58 AM

Hello,

I am trying to write some sensor data on SD card in a csv file.
But in the file I don't see all collected values, rather the last (just one set of three values).
Please correct.

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.NetduinoPlus;
using System.IO;
using System.Text;

namespace Integration
{
    public class Program
    {
        private const int MaximumValue = 1023;
        private const int AnalogReference = 5;

        public static void Main()
        {
            AnalogInput no2Sensor = new AnalogInput(Pins.GPIO_PIN_A1);
            AnalogInput coSensor = new AnalogInput(Pins.GPIO_PIN_A2);
            AnalogInput o3Sensor = new AnalogInput(Pins.GPIO_PIN_A3);

            while (true)
            {
                int digitalValue1 = no2Sensor.Read();
                float analogValue1 = (float)digitalValue1 / MaximumValue * AnalogReference;

                int digitalValue2 = coSensor.Read();
                float analogValue2 = (float)digitalValue2 / MaximumValue * AnalogReference;

                int digitalValue3 = o3Sensor.Read();
                float analogValue3 = (float)digitalValue3 / MaximumValue * AnalogReference;
                Debug.Print("NO2 value:\t" + analogValue1.ToString() + "\nCO Value:\t" + analogValue2.ToString() + "\nO3 Value:\t" + analogValue3.ToString());

                using (StreamWriter sw = new StreamWriter(@"SD\file.csv"))
                {
                    sw.Write(analogValue1.ToString() + "," + analogValue2.ToString() + "," + analogValue3.ToString());
                    sw.Write("\n");
                    sw.Flush();
                    sw.Close();
                }

                Thread.Sleep(1000);
            }

            
        }

    }
}

Thanks.

Regards,

Z

SD card logger

25 February 2012 - 04:55 PM

Hello guys,
I am new to Netduino, though I recently bought Netduino Plus.
I am trying to build a small project where I need to log some analog sensor data and date-time in a csv file on SD card.
Here is a small code which I wrote for CO sensor.

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.IO;
using Ethernet.Data;


namespace co
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            AnalogInput coSensor = new AnalogInput(Pins.GPIO_PIN_A0);
            coSensor.SetRange(0, 1024);
            while (true)
            {
                Debug.Print(coSensor.Read().ToString());
            Thread.Sleep(1000);
        }

        }

    }
}

Please help me log it on SD card.

Thanks.

Z

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.