Hi,
I am extracting temperature reading from temperature sensor DS18B20 built application. I am obtaining values from temperature sensor build on NetDuino plus2. Whenever temperature of room changes, temperature server notify the client. I want to write the observed values from temperature sensor to a file (preferably to excel file) so that i can plot my simulation results. The debug command in the code below print temperature values whenever they are updated. Can anyone help me with code to write the values to an excel spreadsheet or another file.
void OnCoAPRequestReceived(CoAPRequest coapReq)
{
if (coapReq.MessageType.Value == CoAPMessageType.CON)
{
//Extract the temperature..but first, check if the notification is fresh
//The server sends a 4-digit sequence number
int newObsSeq = AbstractByteUtils.ToUInt16(coapReq.Options.GetOption(CoAPHeaderOption.OBSERVE).Value);
if ((lastObsSeq < newObsSeq && ((newObsSeq - lastObsSeq) < (System.Math.Pow(2, 23)))) ||
(lastObsSeq > newObsSeq && ((lastObsSeq - newObsSeq) > (System.Math.Pow(2, 23)))) ||
DateTime.Now > lastObsRx.AddSeconds(128))
{
//The value received from server is new....read the new temperature
//We got the temperature..it will be in payload in JSON
string payload = AbstractByteUtils.ByteToStringUTF8(coapReq.Payload.Value);
Hashtable keyVal = JSONResult.FromJSON(payload);
//int temp = Convert.ToInt32(keyVal["temp"].ToString());
//float temp = 10.1f;
float temp = (float)Double.Parse(keyVal["temp"].ToString());
Debug.Print("Temperature of Room is " + temp);
Thanks
escallanio
Writing Temperature Sensor Readings to a file
Started by escallanio, May 13 2014 10:15 AM
Visual Studio NetDuino Plus 2 Temperature Sensor File Writing
No replies to this topic
#1
Posted 13 May 2014 - 10:15 AM
Also tagged with one or more of these keywords: Visual Studio, NetDuino Plus 2, Temperature Sensor, File Writing
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
GSM shieldStarted by EagleSparrow, 17 Mar 2017 GSM, Netduino Plus 2 |
|
|||
General →
General Discussion →
Wi-Fi Shield for Netduino Plus 2Started by shiv.kumar, 26 Jan 2016 Netduino Plus 2, Wi-Fi |
|
|||
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
Netduino Plus 2 not respondingStarted by vicen.david@telefonica.net, 30 Nov 2015 Netduino Plus 2 |
|
|||
Answered
Hardware →
Netduino Plus 2 (and Netduino Plus 1) →
SerialPort Receive Data CorruptionStarted by Hawkez, 20 Jul 2015 Netduino Plus 2, Netduino 3 WiFi and 2 more... |
|
|||
Hardware →
Netduino 3 →
"An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll" Error with N3 on VS...Started by ishotjr, 05 Jul 2015 Visual Studio, VS2015 and 1 more... |
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users