- Netduino Forums
- → Zeus's Content
Zeus's Content
There have been 8 items by Zeus (Search limited from 22-September 23)
#27070 Data logger
Posted by Zeus on 12 April 2012 - 03:35 PM in Netduino Plus 2 (and Netduino Plus 1)
#27961 Data logger
Posted by Zeus on 23 April 2012 - 07:24 PM in Netduino Plus 2 (and Netduino Plus 1)
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; } } } } }
#27971 Data logger
Posted by Zeus on 23 April 2012 - 09:09 PM in Netduino Plus 2 (and Netduino Plus 1)
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); } } } }
#27066 Data logger
Posted by Zeus on 12 April 2012 - 02:55 PM in Netduino Plus 2 (and Netduino Plus 1)
#26990 Data logger
Posted by Zeus on 11 April 2012 - 11:10 PM in Netduino Plus 2 (and Netduino Plus 1)
#26849 Data logger
Posted by Zeus on 10 April 2012 - 08:58 AM in Netduino Plus 2 (and Netduino Plus 1)
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)
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
- Netduino Forums
- → Zeus's Content
- Privacy Policy