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.

don664's Content

There have been 77 items by don664 (Search limited from 28-April 23)


By content type

See this member's


Sort by                Order  

#40239 RN-XV WiFly Module driver

Posted by don664 on 26 November 2012 - 05:05 PM in Project Showcase

Is there a way to set the timezone just before the synchronize; as I need the times to be GMT +2? Thanks :)



#40238 Replacing texst in strings

Posted by don664 on 26 November 2012 - 05:03 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi there,

I'm trying to post a date/time via an HTTP request for an application I'm writing. The only problem is that I am getting an error because of the space in the date/time.

string = "&dateTimeStamp=06/01/2011 00:00:28"


I need it to be

string = "&dateTimeStamp=06/01/2011%2000:00:28"


I have created the following:

public static string replace(string str, string unwanted, string replacement)
        {
            StringBuilder sb = new StringBuilder(str);
            sb.Replace(unwanted, replacement);
            return sb.ToString();
        }

but calling it like this does not get rid of the space:

string httpLine = replace(originalLine, " ", "%20");

Is there an escape character I should use for replacing the space?

Thanks,
Donovan



#40220 RN-XV WiFly Module driver

Posted by don664 on 26 November 2012 - 11:38 AM in Project Showcase

Ah ha ;) Perfect! Thanks for the help Stefan!



#40212 RN-XV WiFly Module driver

Posted by don664 on 26 November 2012 - 05:41 AM in Project Showcase

You can swap the integratedsocket for the wifi socket;
http://netmftoolbox....ailable classes


Hi Stefan,

Thanks... but now I don't know how to set the time as "Synchronize" is not part of SimpleSocket:

'Toolbox.NETMF.NET.SimpleSocket' does not contain a definition for 'Synchronize' and no extension method 'Synchronize' accepting a first argument of type 'Toolbox.NETMF.NET.SimpleSocket' could be found (are you missing a using directive or an assembly reference?)


I've tried looking through the IntelliSense options for TimeClient but can't figure out which to use.

// Initializes the time client
            SimpleSocket TimeClient = new WiFlySocket("time-a.nist.gov", 123, WifiModule);
            // Displays the time in three ways:
            Debug.Print("Amount of seconds since 1 jan. 1900: " + TimeClient.NtpLookup());
            //Debug.Print("UTC time: " + TimeClient.UTCDate.ToString());
            //Debug.Print("Local time: " + TimeClient.LocalDate.ToString());
            // Synchronizes the internal clock
            TimeClient.Synchronize();



#40165 RN-XV WiFly Module driver

Posted by don664 on 25 November 2012 - 02:49 PM in Project Showcase

Hi Stefan,

Thanks for the link... which reference do I need to add for "IntegratedSocket"?

I keep getting the following error:

The type or namespace name 'IntegratedSocket' could not be found (are you missing a using directive or an assembly reference?)


I'm running a Netduino Plus 2.



#40095 RN-XV WiFly Module driver

Posted by don664 on 24 November 2012 - 04:51 AM in Project Showcase

I have the toolbox.... will look again for an ntpvexample Thanks :-)



#40013 RN-XV WiFly Module driver

Posted by don664 on 23 November 2012 - 02:56 PM in Project Showcase


By the way, for those who know that netmftoolbox thingy, I also added an SNTP client today


When was this added and is there an example of it's simple usage to set the dateTime on the Netduino?

Thanks,
Donovan



#40010 Netduino Plus 2 NTP class for Wifi

Posted by don664 on 23 November 2012 - 02:40 PM in General Discussion

For anyone looking here's more info on NTP and wifi:

http://forums.netdui...hl__ntp__st__40



#40007 Netduino Plus 2 NTP class for Wifi

Posted by don664 on 23 November 2012 - 02:26 PM in General Discussion

I guess it has something to do with the board's footprint and there just physically not being space to accommodate the battery. I'd trade the ethernet port about now for an RTC module though ;)



#40003 Netduino Plus 2 NTP class for Wifi

Posted by don664 on 23 November 2012 - 02:16 PM in General Discussion

I can't figure it out... too much going on for my limited noob abilities. Just going to get a RTC module on Monday. Netduino Plus 3 to have an RTC onboard?



#40002 Netduino Plus 2 NTP class for Wifi

Posted by don664 on 23 November 2012 - 01:41 PM in General Discussion

Thanks Dave, Taking a look now. Very nicely ordered code... just trying to extract the NTP class now.



#39997 Netduino Plus 2 NTP class for Wifi

Posted by don664 on 23 November 2012 - 12:32 PM in General Discussion

Hi there, Does anyone have an example of how to set the Netduino dateTime from the internet using wifi for a connection? Thanks, Donovan



#39889 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 03:09 PM in General Discussion

If anyone is interested in FTP I have found this: http://forums.netdui...-client-socket/ and will let you know how I get on with it. Hmmm... seems to be for an Ethernet connection and not wifi...



#39883 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 02:58 PM in General Discussion

I hope I'm able to find someone who's written some FTP code then or my project could be scuppered! Thanks for the help Stefan :D



#39879 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 02:37 PM in General Discussion

You could also make a main loop, not working with interrupts, like you probably did with an Arduino before.


I think that was how I did it before... with a timer to ensure the wifly was only handling one request at a time.

I am thinking that for this to work I may need to have the interrupt write the "count" to the SD card and then every minute (or whatever) have the wiFly upload that file (maybe XML) to the server and then send an HTTP request for the server to get the data from the file.

Are there any examples for FTP with the wifly?



#39874 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 02:25 PM in General Discussion

I have amended the "Port.InterruptMode.InterruptEdgeBoth" to be "Port.InterruptMode.InterruptEdgeHigh" so it should only catch one part of the state change for the interrupt... ...will see if that helps at all and let you know.



#39873 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 02:24 PM in General Discussion

Hi Stefan, Thanks for getting back to me... I have just started to think the same thing because when I do the socket.open and the HTTP send in the main thread it's fine but there is only a problem when I try and do it in the interrupt method. I'm using a try/catch now to try and see if that's the issue. Could be a major setback for my project if it's the case and I may have to go back to the Arduino :(



#39798 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 10:21 AM in General Discussion

Would a way around this be to set the wifi details using coolTerm directly onto the RN-XV module so that as soon as it has power it will automatically connect to the wifi network? Then surely I'd be able to create the socket and send the HTTP request each time the sensor is interrupted as the wifi connection will be in place?



#39796 Socket.Connect locks up Netduino if no network

Posted by don664 on 21 November 2012 - 09:27 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi there,

I'm having a similar problem where I try and access the wifi module to get the local IP (this just for testing and I actually want to create a socket and send an HTTP request) and it simply stops all threads from running.

Any ideas about why I can't access any network related stuff from within my interrupt event method?

Problem detailed here

Thanks,
Donovan



#39792 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 07:54 AM in General Discussion

ok... so in the mySensor_OnInterrupt method I CAN actually interact with the WifiModule itself like this:

public static void mySensor_OnInterrupt(uint port, uint state, DateTime time)
        {
            Debug.Print(WifiModule.MacAddress);

The problem is that I can't access anything related to the WiFi connection like the Local IP Address or creating a socket to send an HTTP request for posting the counter value.



#39790 OnInterrupt problem calling WiFly

Posted by don664 on 21 November 2012 - 07:26 AM in General Discussion

Hi there,

Ok... so I have now added the on-board LED to the project

public class Program
    {
        static WiFlyGSX WifiModule;
        static OutputPort led;

and here

public static void Main()
        {
             WifiModule = new WiFlyGSX();
             led = new OutputPort(Pins.ONBOARD_LED, false);

Now when the event handler (the interruption of the photo sensor) is triggered I can interact with the led and turn it on and off:

This added to the method:

public static void mySensor_OnInterrupt(uint port, uint state, DateTime time)
        {
           led.Write(state == 0);

So why can I interact with the led but not the WifiModule in the event method?

What am I missing? :blink:

Thanks,
Donovan



#39745 OnInterrupt problem calling WiFly

Posted by don664 on 20 November 2012 - 04:42 PM in General Discussion

Hi guys,

This project includes a Netduino Plus 2, a photo sensor and a RN-XV WiFly module (with wireless shield).

What I am aiming for is that when the application starts a connection is made to the wifi network; then when the photo sensor is triggered a counter variable is sent to a webpage, as a querystring variable, to add it to a database.

Before I create the HTTP request I thought I would make sure I can access the WiFly "instance" from within the OnInterrupt "function/call" by simply getting the Local IP address again and writing it to the Debug window (apologies again if I'm getting the terminology wrong).

There is no problem populating the string "strLocalIP_1" but as soon as I try populate "strLocalIP_2" the application hangs.

What am I missing?

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.Netduino;
using Toolbox.NETMF;
using Toolbox.NETMF.NET;
using Toolbox.NETMF.Hardware;

namespace sandbox
{
    public class Program
    {
        // declare counter variable, photoSensor and wifly
        static uint counter = 0;
        static InterruptPort mySensor;
        static WiFlyGSX WifiModule;

        public static void Main()
        {
            // Create sensor instance
            mySensor = new InterruptPort(Pins.GPIO_PIN_D7, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
            mySensor.OnInterrupt += new NativeEventHandler(mySensor_OnInterrupt);

            // Create WiFly instance 
            WifiModule = new WiFlyGSX();

            // Allow some time for WiFly to power up and find network
            Thread.Sleep(5000);

            // Join Network
            WifiModule.EnableDHCP();
            WifiModule.JoinNetwork("SSID", 0, WiFlyGSX.AuthMode.MixedWPA1_WPA2, "Password");

            // Wait for authentication and joining
            Thread.Sleep(5000);

            Debug.Print("WiFi connected");

            // Get the Local IP to confirm connection to the wifi network
            string strLocalIP_1;
            strLocalIP_1 = WifiModule.LocalIP;

            Debug.Print(strLocalIP_1);
            
            // Indefinitely wait for any sensor interrupts...
            Thread.Sleep(Timeout.Infinite);
        }

        public static void mySensor_OnInterrupt(uint port, uint state, DateTime time)
        {
            // get the "interrupt" state to stop counter counting twice
            if (state == 0)
            {
                // Write the count to the debug window
                Debug.Print("counter: " + counter);

                // Get the Local IP to confirm connection to the wifi network
                string strLocalIP_2;
                strLocalIP_2 = WifiModule.LocalIP;

                Debug.Print(strLocalIP_2);

                // increase counter by 1
                counter++;
            }
        }
    }
}


Posted Image

I'm sure it's a real noob oversight on my part but would appreciate any help.

Thanks,
Donovan



#39730 Serial LCD and Netduino Plus 2

Posted by don664 on 20 November 2012 - 12:21 PM in Netduino Plus 2 (and Netduino Plus 1)

Ah ha! Thanks Dave :D



#39689 Communicating with serial 2x16 LCD

Posted by don664 on 20 November 2012 - 08:04 AM in Netduino 2 (and Netduino 1)

Hi Chuck,

Thanks for the response.

I have figured it and posted my solution here:

Serial LCD and Netduino Plus 2

Thanks again to Coyttl for also taking the time to help out.

Cheers,
Donovan



#39688 Serial LCD and Netduino Plus 2

Posted by don664 on 20 November 2012 - 08:02 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi there,

After struggling with this for a day I finally got it working and thought I'd share.

The problem seemed to be with the declaration syntax (sorry if I'm using the wrong terminology here) between .Net Micro Framework 4.1 and 4.2.

For example the class I was trying to use declared the serial port like this:
_lcd = new SerialPort(com, 9600, Parity.None, 8, StopBits.One);

Yet it needs to be like this:
_lcd = new System.IO.Ports.SerialPort(com, 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);

Once I sorted that out it all seems to be working just fine now. This syntax was corrected by right clicking on the red underlined text, such as SerialPort, and selecting "Resolve"... IntelliSense does the rest for you ;)

Here's the LCD class (LCD.cs):

using System;
using Microsoft.SPOT;

namespace slcdHelloWorld
{
    class LCD
    {
        private System.IO.Ports.SerialPort _lcd;
        private byte[] clear = { 0xFE, 0x01 };
        private byte[] blinkboxon = { 0xFE, 0x0D };
        private byte[] blinkboxoff = { 0xFE, 0x0C };
        
        public LCD(string com)
        { 
            _lcd = new System.IO.Ports.SerialPort(com, 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
            _lcd.Open();
            this.Clear();
            this.MoveCur(0);
            this.Write(blinkboxoff);
        }

        public void Clear()
        {
            this.Write(clear);
            this.MoveCur(0);
            this.Write(blinkboxoff);
        }

        public void Write(byte[] B)
        {
            _lcd.Write(b, 0, b.Length);
        }

        public void MoveCur(int i)
        {
            this.Write(blinkboxon);

            if (i > 15) i += 48;
            byte locByte = (byte)(128 + i);
            byte[] moveto = { 0xFE, locByte };
            Debug.Print("MoveTo - " + moveto[0].ToString() + " - " + moveto[1].ToString() + " - locByte " + locByte.ToString());
            this.Write(moveto);
        }
    }
}


And here's the Program.cs:

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.Netduino;

namespace slcdHelloWorld
{
    public class Program
    {
        // initialise the LCD display
        static LCD mylcd = new LCD("COM2");

        public static void Main()
        {
            // write your code here
            while (true)            {
                
                mylcd.Clear();
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes("Hello World");
                mylcd.Write(bytes);
                Thread.Sleep(5000);
                mylcd.Clear();
                mylcd.MoveCur(30); 
            }
        }

    }
}


In terms of connecting up the Serial LCD (https://www.sparkfun.com/products/9395) simply run wires like this (LCD to Netduino):


Posted Image

Thanks to everyone for the help and hope this saves someone else some time :D

Cheers,
Donovan




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.