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's Content

There have been 8 items by Zeus (Search limited from 17-April 20)


By content type

See this member's

Sort by                Order  

#27971 Data logger

Posted by Zeus on 23 April 2012 - 09:09 PM in Netduino Plus 2 (and Netduino Plus 1)

Well, I figured out the problem.
Here is the updated code.
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_A0);
            AnalogInput coSensor = new AnalogInput(Pins.GPIO_PIN_A1);
            AnalogInput o3Sensor = new AnalogInput(Pins.GPIO_PIN_A2);
            AnalogInput e_no2Sensor = new AnalogInput(Pins.GPIO_PIN_A3);
            AnalogInput e_noSensor = new AnalogInput(Pins.GPIO_PIN_A4);
            AnalogInput e_coSensor = new AnalogInput(Pins.GPIO_PIN_A5);
            OutputPort led = new OutputPort(Pins.GPIO_PIN_D8, false);

            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;

                    int digitalValue4 = e_no2Sensor.Read();
                    float analogValue4 = (float)digitalValue4 / MaximumValue * AnalogReference;

                    int digitalValue5 = e_noSensor.Read();
                    float analogValue5 = (float)digitalValue5 / MaximumValue * AnalogReference;

                    int digitalValue6 = e_coSensor.Read();
                    float analogValue6 = (float)digitalValue6 / MaximumValue * AnalogReference;

                Debug.Print("NO2 value:\t" + analogValue1.ToString() + "\nCO Value:\t" + analogValue2.ToString() + "\nO3 Value:\t" + analogValue3.ToString() + "\ne_NO2 value:\t" + analogValue4.ToString() + "\ne_NO Value:\t" + analogValue5.ToString() + "\ne_CO Value:\t" + analogValue6.ToString());

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

                    led.Write(true);
                    Thread.Sleep(295);
                    led.Write(false);
                    Thread.Sleep(50);
            }

            
        }

    }
}



#27961 Data logger

Posted by Zeus on 23 April 2012 - 07:24 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi,

I added here some more lines to add more sensors on analog pins. Unfortunately, when Netduino is plugged with wall wart, no data is written to SD card.
It only creates the file.
But when I debug the code and run, it logs data on SD card.
Kindly correct.

Thanks.

Regards,

Z

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;
        private static StreamWriter sw;

        public static void Main()
        {
            AnalogInput no2Sensor = new AnalogInput(Pins.GPIO_PIN_A0);
            AnalogInput coSensor = new AnalogInput(Pins.GPIO_PIN_A1);
            AnalogInput o3Sensor = new AnalogInput(Pins.GPIO_PIN_A2);
            AnalogInput e_no2Sensor = new AnalogInput(Pins.GPIO_PIN_A3);
            AnalogInput e_noSensor = new AnalogInput(Pins.GPIO_PIN_A4);
            AnalogInput e_coSensor = new AnalogInput(Pins.GPIO_PIN_A5);
            OutputPort led = new OutputPort(Pins.GPIO_PIN_D8, false);

            sw = new StreamWriter(@"SD\file.csv");

            while (true)
            {
                try
                {
                    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;

                    int digitalValue4 = e_no2Sensor.Read();
                    float analogValue4 = (float)digitalValue4 / MaximumValue * AnalogReference;

                    int digitalValue5 = e_noSensor.Read();
                    float analogValue5 = (float)digitalValue5 / MaximumValue * AnalogReference;

                    int digitalValue6 = e_coSensor.Read();
                    float analogValue6 = (float)digitalValue6 / MaximumValue * AnalogReference;

                    Debug.Print("NO2 value:\t" + analogValue1.ToString() + "\nCO Value:\t" + analogValue2.ToString() + "\nO3 Value:\t" + analogValue3.ToString() + "\ne_NO2 value:\t" + analogValue4.ToString() + "\ne_NO Value:\t" + analogValue5.ToString() + "\ne_CO Value:\t" + analogValue6.ToString());

                    sw.Write(analogValue1.ToString() + "," + analogValue2.ToString() + "," + analogValue3.ToString() + "," + analogValue4.ToString() + "," + analogValue5.ToString() + "," + analogValue6.ToString());
                    sw.Write("\n");
                    sw.Flush();

                    led.Write(true);
                    Thread.Sleep(295);
                    led.Write(false);
                    Thread.Sleep(500);
                }
                catch (Exception)
                {
                    sw.Close();
                    sw.Dispose();
                    break;
                }
            }
        }
    }
}



#27070 Data logger

Posted by Zeus on 12 April 2012 - 03:35 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi, I have RTC already. I bought DS1307 from Sparkfun. SDA and SCL are meant for analog pins 4 and 5. That I have figured out already but I am looking for a way to read time from this RTC module. Thanks. Z



#27066 Data logger

Posted by Zeus on 12 April 2012 - 02:55 PM in Netduino Plus 2 (and Netduino Plus 1)

Yes! This code works for logging data unto SD card. I also have an RTC - DS1307, I need to log the time in the CSV file corresponding to analog pin values. I have set time of RTC already using Arduino. With Netduino I only want to read and log time. Please help. Thanks. Best, Z



#26990 Data logger

Posted by Zeus on 11 April 2012 - 11:10 PM in Netduino Plus 2 (and Netduino Plus 1)

First of all, sorry for late reply. Second, thanks all and especially Paul. Tomorrow I will check the code and update in here. Best, Z



#26849 Data logger

Posted by Zeus on 10 April 2012 - 08:58 AM in Netduino Plus 2 (and Netduino Plus 1)

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



#24688 SD card logger

Posted by Zeus on 26 February 2012 - 01:45 AM in Netduino Plus 2 (and Netduino Plus 1)

Check out my post here. While it's focused on 1-wire devices, it contains the code I used to log data to an SD card.


Thanks Llaves.
I am trying to get your project work for my need.
I will get back to you shortly.

Z



#24680 SD card logger

Posted by Zeus on 25 February 2012 - 04:55 PM in Netduino Plus 2 (and Netduino Plus 1)

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.