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.

Ellen's Content

There have been 65 items by Ellen (Search limited from 29-April 23)


By content type

See this member's


Sort by                Order  

#32889 DHCP startup problem

Posted by Ellen on 30 July 2012 - 06:17 AM in Netduino Plus 2 (and Netduino Plus 1)

Okay, cool. I hope it helps. If not, we'll figure something out.


Hi Stefan,
Now every day the Netduino starts as it should be without any errors.
Thank you for share the programm code.
Ellen



#32888 I notice a difference in results, but it should not be.

Posted by Ellen on 30 July 2012 - 06:15 AM in Netduino Plus 2 (and Netduino Plus 1)

So as I understand, (the bottom line) when you want calculate with time very precisely, you need to use dateTime.Now.Ticks All the other methods results in capricious output.



#32729 I notice a difference in results, but it should not be.

Posted by Ellen on 26 July 2012 - 07:29 PM in Netduino Plus 2 (and Netduino Plus 1)

Are the calculations for AC_Wattage, zTestWattage2 and zTestWattage all in the same thread?


Yes Gorf, they are all in the same thread.



#32707 I notice a difference in results, but it should not be.

Posted by Ellen on 26 July 2012 - 02:28 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Ellen,

If I understand this correctly; you need to measure the time between two pulses. Am I right in that?
What kind of timeframe should I think of, in ns, µs, ms, seconds, minutes?

Ps. nice project you're building!


Hello Stefan,
The pulse meter give 2000 pulse per KiloWatt so 3600 seconds in 1 hour / 2000 give 1.8 seconds per pulse/KW. And I update the cosm server every 20 seconds.

There must be some kind of something wrong. It is between lets say 1610 Watt and 1803 watt.
Have a look at my afternoon image (the gap), and the afternoon mirror the morning, the two should be identical:


This one is the bad one.
Posted Image

This one is the good one:
Posted Image



#32694 I notice a difference in results, but it should not be.

Posted by Ellen on 26 July 2012 - 09:32 AM in Netduino Plus 2 (and Netduino Plus 1)

Hello,
I am using my Netduino for solar logging.
I had notice these days that there was een difference in output between my Solar Inverter wattage output and the netduino output. My question is why?

I log the time between 2 electrical pulse with a KWH counter in the electrical box.

'wait for the first pulse
   dtStartTime = DateTime.Now
   Do
      If portElectricPulse_D13.Read()   'wait for the pulse'
 
Here is the code for the 1st image/stream:


dtEndTime = DateTime.Now
sSeconds = (dtEndTime.TimeOfDay - dtStartTime.TimeOfDay).Seconds.ToString
sMilliSeconds = (dtEndTime.TimeOfDay - dtStartTime.TimeOfDay).Milliseconds.ToString
dblSecsAndMsecs = CType((sSeconds & "." & sMilliSeconds), Double) 
intWattage = CInt(1800 / dblSecsAndMsecs)

Posted Image


Here is the code for the second stream, and this one calculate it oké:
dblTestWattage = (dtEndTime.Ticks - dtStartTime.Ticks) / TimeSpan.TicksPerSecond
intTestwattage = CInt(1800 / dblTestWattage)


Here is the code for the third stream:
tsElapsedTime = dtEndTime.Subtract(dtStartTime)
dblTestWattage2 = CType((tsElapsedTime.Seconds & "." & tsElapsedTime.Milliseconds), Double)
inttestwattage2 = CInt(1800 / dblTestWattage2)


Posted Image



#32683 DHCP startup problem

Posted by Ellen on 26 July 2012 - 05:43 AM in Netduino Plus 2 (and Netduino Plus 1)

Stefan thanks, I have implement your snippet into my source code. Now I am testing it, thats take a while in time. I will let you know. Ellen.



#32458 DHCP startup problem

Posted by Ellen on 22 July 2012 - 08:32 AM in Netduino Plus 2 (and Netduino Plus 1)

Although this probably wont work as it requires a DHCP allocated IP address for the initial DNS lookup, are static IP's totally out of the question for your application? As the only reliable methods i can think of to obtain IP's are:

  • Leave the router on, then you can have an expectation of having a DHCP server availible
  • Use a second timer plug and delay it for 5 to 10 mins to allow router to boot and get online.
  • Use a static IP on your netduino.
Nak.


I have set the Netduino with a static IP as you proposed.
Startup Modem/router at the same time as the Netduino with the timer.
I had programmed a 3 minute software delay in the Netduino before sending to the internet.
The modem was ready but NO, socket error.
Netduino out and in the AC, (the router is still on) and it's works fine.
Strange is not it?



#32277 DHCP startup problem

Posted by Ellen on 19 July 2012 - 09:36 AM in Netduino Plus 2 (and Netduino Plus 1)

With a bit more work, you could check if the interface has an IP. If not, wait a second, renew, check again.


Thxs Stefan,

Would this work?
Thank you in advance.


Try

   dim  connection As Socket = Connect(strHost, 5000)
   If connection Is Nothing then

   Else

   'do something'

   End if   
   

Catch Ex As Exception
   
   
End Try





Private Function Connect(ByVal host As String, ByVal timeout As Integer) As Socket
        ' look up hosts domain name to find IP address(es) '
        Dim hostEntry As IPHostEntry = Dns.GetHostEntry(host)
        ' extract a returned address '
        Dim hostAddress As IPAddress = hostEntry.AddressList(0)
        Dim remoteEndPoint As New IPEndPoint(hostAddress, 80)

        Dim connection = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        connection.Connect(remoteEndPoint)
        connection.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, True)
        connection.SendTimeout = timeout
        Return connection
    End Function



#32273 DHCP startup problem

Posted by Ellen on 19 July 2012 - 09:18 AM in Netduino Plus 2 (and Netduino Plus 1)

I have to ask why do you have a Router on a timer?

They are designed to be left switched on...

Nak.


Nak, Dutch people are economical, frugal and also parsimonious. B)
..., why must the modem/router stays on when I do not use him, more then 12 hours a day?



#32262 DHCP startup problem

Posted by Ellen on 19 July 2012 - 07:02 AM in Netduino Plus 2 (and Netduino Plus 1)

I have a problem to solve with the internet. I use the Netduino for datalogging. I startup the Netduino on the same time as my router with a timer. But the Netduino starts faster then my router with the result that the router don't "see" my Netduino (he is not in the DHCP table). When I pull out and pull in the AC plug of the Netduino, the Netduino/internet works oké. What can I do the best?, buy a second timer and set the Netduino startup time later, or can I solve the problem in the software. Thanks in advance. Ellen



#32074 Sending data to the Cosm server.

Posted by Ellen on 16 July 2012 - 08:01 PM in Visual Basic Support

Well it could speed up a little by sending all the items at once.

dim strAllItems as string
strAllItems = Item1 & Constants.vbCr & Constants.vbLf & Item2 & Constants.vbCr & Constants.vbLf & Item3

Using connection As Socket = Connect(URi, 5000)      
   SendRequest(connection, apiKey, feedId, strAllItems)       
End Using



#31871 Sending data to the Cosm server.

Posted by Ellen on 11 July 2012 - 07:54 PM in Visual Basic Support

Still working on a small learning project out of the book Internet and things and want to send data to the Cosm.com server. (it was Pachube) Have found some code here and on other sites.

I am wondering if it can be programmed a little bit better so it will work faster.
Now i send for every item/feed a new request but i want to sent more then 1 item to the datastream in 1 request. I have tried a few possibilities but without any success. :blink:
Thank you.

Now my code is:


'all the items have the same connection, apiKey and feedId
'Sending the items every 30 seconds


Item1 = "Volt,23"
Item2 = "Ampere,3"
Item3 = "Direction,34.2" 

Do While True

   Using connection As Socket = Connect(URi, 5000)
      SendRequest(connection, apiKey, feedId, Item1) 
      SendRequest(connection, apiKey, feedId, Item2)
      SendRequest(connection, apiKey, feedId, Item3)
   End Using

   'do other things for 30 seconds and read the new data in the items

loop


Private Function Connect(ByVal host As String, ByVal timeout As Integer) As Socket
        ' look up host's domain name to find IP address(es)
        Dim hostEntry As IPHostEntry = Dns.GetHostEntry(host)
        ' extract a returned address
        Dim hostAddress As IPAddress = hostEntry.AddressList(0)
        Dim remoteEndPoint As New IPEndPoint(hostAddress, 80)

        Dim connection = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        connection.Connect(remoteEndPoint)
        connection.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, True)
        connection.SendTimeout = timeout
        Return connection
    End Function

    Private Sub SendRequest(ByVal s As Socket, ByVal apiKey As String, ByVal feedId As String, ByVal content As String)
        Dim contentBuffer As Byte() = Encoding.UTF8.GetBytes(content)
        Dim CRLF As String = Constants.vbCr & Constants.vbLf
        Dim requestLine = "PUT /v2/feeds/" & feedId & ".csv HTTP/1.1" & CRLF
        Dim requestLineBuffer As Byte() = Encoding.UTF8.GetBytes(requestLine)
        Dim headers = "Host: api.pachube.com" & CRLF & "X-PachubeApiKey: " & apiKey & CRLF & "Content-Type: text/csv" & CRLF & "Content-Length: " & contentBuffer.Length & CRLF & CRLF
        Dim headersBuffer As Byte() = Encoding.UTF8.GetBytes(headers)
        s.Send(requestLineBuffer)
        s.Send(headersBuffer)
        s.Send(contentBuffer)
    End Sub






#31521 The best calculation between 2 times

Posted by Ellen on 03 July 2012 - 07:31 AM in Visual Basic Support

I'm not going to claim that it's "better", but I THINK it is...

        Dim dtStartTime As DateTime = DateTime.Now
        'Do stuff
        Dim tsEndTime As TimeSpan = DateTime.Now.Subtract(dtStartTime)
        Debug.Print(tsEndTime.Seconds & "." & tsEndTime.Milliseconds)


After a lot of tests, this works indead very well.
Thank you.



#31046 The best calculation between 2 times

Posted by Ellen on 22 June 2012 - 06:26 AM in Visual Basic Support

Hello, I am working on a small home project and need the very best calculation between a time interval. Now i have programmed: dtStartTime = DateTime.Now 'start 'do other things and then.... dtEndTime = DateTime.Now 'endtime 'extracting the seconds and millisecs sSeconds = (dtEndTime.TimeOfDay - dtStartTime.TimeOfDay).Seconds.ToString sMilliSeconds = (dtEndTime.TimeOfDay - dtStartTime.TimeOfDay).Milliseconds.ToString 'and put it back together dblSecsAndMsecs = CType((sSeconds + "." + sMilliSeconds), Double) My question is : Is there a better way to do this.?. Ellen



#30678 Thermometer Reading, 3rd App using VB

Posted by Ellen on 14 June 2012 - 10:18 AM in Visual Basic Support

Thanks Stefan, did not thought of that. Cool, going to try this code immediately.


I am a newbee and I know, it is an old post.

Is it right to do it like this, rounding up.?.

dim dblSecsAndMsecs as Double = 12345.6789
Debug.Print(dblSecsAndMsecs.ToString("N0"))

N = numeric and the zero is for no decimals, so 2 decimals = N2




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.