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 28-April 23)


By content type

See this member's


Sort by                Order  

#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



#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



#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.



#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






#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



#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



#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?



#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



#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?



#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.



#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



#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



#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.



#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.



#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



#33157 OnBoard MicroSD

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

Most 1 or 2 GB ones work. There was a beta version that the 4 & 8 GB worked, but that code is not in 4.2 that I know of, so you are stuck with 1 & 2 GB.

For me, the SD card also is not working because I bought a 8 gieg. (bigger counts :-))
I think the store (mediamarkt) will not exchange the card for a smaller one.

Is there any chance that the SD Card 4&8 Gb support will be implemented in the version 4.2
Because I program in VB, I am stuck on version 4.2
BTW, VB and 4.2 works very well.
Ellen



#33322 PV Solar logging. with source code.

Posted by Ellen on 09 August 2012 - 11:14 AM in Visual Basic Support

Hi you all,
We want to contribute our program sources for Solar data logging.
I know it is not the most streamlined sources but with a little imagination and patience.....
Found some code here and there and edit it.

With 2 servo's for Watt and KWH Like a clock.
A display for Time, Temperature of the Solar panels, Watt and KWH.
2 LED for write to internet and read the Electric SO port. http://www.groepenka...kel-tarief.html


Write to 3 internet servers , Cosm.com, ThingSpeak and PVoutput.
Read the time from internet into the Netduino

and the Google Gauges ThingSpeak HTML file.
Just run the html file.

Thanks to everybody especially Stefan for his help.

Attached Files




#33356 PV Solar logging. with source code.

Posted by Ellen on 10 August 2012 - 06:00 AM in Visual Basic Support

Ohh that's awesome! Luckely you'll get a lot of sun in the next few days :)

Hi Stefan, I am looking forward to the nice weather, we did have a long raining period and we are almost depressed by the bad weather. But after rain there is .....
greeting Ellen



#33492 DHCP startup problem

Posted by Ellen on 12 August 2012 - 06:48 PM in Netduino Plus 2 (and Netduino Plus 1)

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


UPDATE.... BUG REPORT maybe?
After a few days without internet startup errors, now again.

So I went to have a closer look about this problem.
The bottom line is when the Netduino is running before the router is powered up, there is no way to establising the connection without reseting the Netduino.

This Netduino reboot should not to be a problem if I can write to the SD Card but I do not have a small 1 or 2 gieg card, larger is not supported in 4.2 untill now.

Workeround with writing to sd.....

Startup Netduino
If internet....

If file existe("alreadyBooted")
delete file
endif

end if

If not internet ....

If file existe("alreadyBooted")

...no second reboot.
...internet can not be restored ... already tried.

Else

write dummy file to sd card filecreate("alreadyBooted")
reboot

endif

This is to prevent a forever reboot.
It is wonderfull when we have a static memory of 1 byte.



#33577 N+ hangs sometimes when try to receive Time

Posted by Ellen on 14 August 2012 - 09:03 AM in Netduino Plus 2 (and Netduino Plus 1)

Hello,

How can i resolve hanging my N+ when i want to sync my Netduino with a time server.

Function call:

Utility.SetLocalTime(NTPTime("time-a.nist.gov"))
"time-a.nist.gov" : ntp ok, time,daytime busy, not recommended

He will sometimes hang when receive :

s.Receive(ntpData)

I can choose out of many servers but that is for now not the point.
http://tf.nist.gov/tf-cgi/servers.cgi

How to resolve?
Thanks in advance, Ellen



        Private Shared Function NTPTime(ByVal TimeServer As [String]) As DateTime

            Dim ep As New IPEndPoint(Dns.GetHostEntry(TimeServer).AddressList(0), 123)
            Dim s As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
            Dim ntpData As Byte() = New Byte(47) {}
            Array.Clear(ntpData, 0, 48)

            ntpData(0) = &H1B
            s.SendTimeout = 5000

            s.SendTo(ntpData, ep)
            s.Receive(ntpData)     'with debugging, HERE he will stop.'

            Dim offsetTransmitTime As Byte = 40

            Dim intpart As Long = 0
            Dim fractpart As Long = 0

            For i As Integer = 0 To 3
                intpart = (intpart << 8) Or ntpData(offsetTransmitTime + i)
            Next

            For i As Integer = 4 To 7
                fractpart = (fractpart << 8) Or ntpData(offsetTransmitTime + i)
            Next

            Dim milliseconds As Long = CLng(intpart * 1000 + (fractpart * 1000) / &H100000000L)

            s.Close()

            Dim timeSpan__1 As TimeSpan = TimeSpan.FromTicks(CLng(milliseconds) * TimeSpan.TicksPerMillisecond)
            Dim dT As New DateTime(1900, 1, 1)
            dT += timeSpan__1

            'daylight saving'
            If dT.Month < 3 OrElse dT.Month > 10 Then
                Return dT.AddHours(1)
            End If
            If dT.Month > 3 AndAlso dT.Month < 10 Then
                Return dT.AddHours(2)
            End If
            If dT.Month = 3 Then
                '      in march'
                If (dT.Day - CInt(dT.DayOfWeek)) < 25 Then
                    Return dT.AddHours(1)
                End If
                If (CInt(dT.DayOfWeek) = 0) AndAlso (dT.Hour < 2) Then
                    Return dT.AddHours(1)
                End If
                Return dT.AddHours(2)
            End If
            '      in october'
            If (dT.Day - CInt(dT.DayOfWeek)) < 25 Then
                Return dT.AddHours(2)
            End If
            If (CInt(dT.DayOfWeek) = 0) AndAlso (dT.Hour < 2) Then
                Return dT.AddHours(2)
            End If

            Return dT.AddHours(1)
        End Function





#33581 N+ hangs sometimes when try to receive Time

Posted by Ellen on 14 August 2012 - 10:32 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi Ellen,

Is your app hanging on Utility.SetLocalTime or on the NTPTime call?

What does the NTPTime code look like?

Chris


No he hangs on a earlier somewhere on this forum copied NTPTime call (source code I had included above), at s.Receive(ntpData)

I think i need to call the Socket.ReceiveTimeout Property because the default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.

In other words, with a ?bad connection? i can wait until i have gray hair. :blink:



#33704 Help upgrading TinyBooter using SAM-BA 2.12

Posted by Ellen on 15 August 2012 - 07:00 PM in General Discussion

Yes, please upgrade to the new Netduino 4.2 SDK. The August 2012 update (currently posted version) includes the WinUSB drivers you'll need.

Chris


Atmel offline.... any other site for downloading Samba.?.

Service Unavailable - DNS failure
The server is temporarily unable to service your request. Please try again later.
Reference #11.d70e4bd5.1345056762.110efaf



#33712 Netduino Plus Firmware v4.2.0

Posted by Ellen on 15 August 2012 - 07:59 PM in Netduino Plus 2 (and Netduino Plus 1)

Chris, You did not tell that also Netduino SDK 4.2.0.1 and .NET Micro Framework SDK v4.2Q2 is needed Without windows can not recognize the Netduino. Ellen



#33747 Netduino Plus Firmware v4.2.0

Posted by Ellen on 16 August 2012 - 08:04 AM in Netduino Plus 2 (and Netduino Plus 1)

Is there in this version 4.2.0.1 support for the SD HC 8 gieg card? Dim fs As FileStream = File.Create("\jj.txt") error: An unhandled exception of type 'System.IO.IOException' occurred in System.IO.dll If there is not than i can stop with finding out. gr Ellen



#33913 Netduino Plus Firmware v4.2.0

Posted by Ellen on 19 August 2012 - 06:50 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi Ellen,


The .NET MF team updated the SD card drivers in .NET MF 4.2. If there are any cards which worked with 4.1.1 but aren't working with the official 4.2 release, we want to make sure we get those supported.

Can you please provide the manufacturer and model number of your card, and we'll try to get one here to test against?

Chris

It took a while....
Chris, Stefan, I start with the bottom line, There is no way that we could read or write from the mini SDcard. I think there is a lot to re-write and test in the system.dll
What we did: purchased a second N+ and a second 4 gieg mini SDcard. Just to exclude that the first N+ or card was broken.
We did test it in the most unthinkable way and code, mixed...in ...out...power recycle...format....other computer, ....you name it, we did it.
Those who have a working SDcard must see themselves as the lucky ones. If there is someone who can tell ... with these steps and program code it must go well...
Ellen




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.