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.

Terrence

Member Since 04 Oct 2014
Offline Last Active Aug 11 2015 11:38 AM
-----

Topics I've Started

Interrupt stops working after a while?

24 July 2015 - 02:42 AM

I have a ND Plus 2 that has a PIR sensor attached.

Everytime the PIR is triggered by movement I log the bit into Azure.

I have a heartbeat bit I loggin to Azure every 15 minutes to tell me the gateway is alive.

I have been running this code on my ND Plus 2 for many months. 24 X 7 without issue.

As the weeks wear on, my PIR data stops getting logged to Azure.

I reboot the board and things run fine for weeks before I have to reboot.

Then and they run fine for a week before I have to reboot.

Now I have to reboot every day and then the PIR only logs for a few hours.

 

My HeartBeat interupt keeps on logging to Azure.

So my thought is that the PIR interupt is not firing.

 

But I have no idea, I am new at this fun area of micro boards and IOT.

Any idea on what might be happening, or how to improve my code to make it more robust?

Thank you.

public class Program
{
	#region Properties

	private static string SubLocationID = "Gateway";

	private static int HeartBeatTimerPeriod = 15;
	private static Timer HeartBeatTimer = null;
	private static TimerCallback TimerCallback = null;
	private static DateTime LastMotionDetectedTime;

	private static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
	private static bool MotionDetected = false;
	private static InterruptPort PIRInterupt;
	private static string MACAddress;
	private static InterruptPort sdCardStatusPort;

	#endregion

	#region Methods

	public static void Main()
	{

		if (Program.GetIPAddressAndSetTime(out Program.MACAddress))
		{
			Program.AddData(Program.MACAddress, PIRLocal.MessageType.START);

			Program.TimerCallback = new TimerCallback(HeartBeatTimerInterrupt);
			Program.HeartBeatTimer = new Timer(Program.TimerCallback, null, 0, Program.HeartBeatTimerPeriod * 60000);

			//set the interupts after we get an ip address and time.
			PIRInterupt = new InterruptPort(Pins.GPIO_PIN_D8, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
			PIRInterupt.OnInterrupt += PIRInterupt_OnInterrupt;

			NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
			NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);

			while (true)
			{
				if (MotionDetected)
				{
					Program.MotionDetected = false; //turn this off.
					Program.Blink(1, 75);
					Program.AddData(Program.MACAddress, PIRLocal.MessageType.PIR);
				}
				Thread.Sleep(500);
			}
		}
	}

	private static bool GetIPAddressAndSetTime(out string macAddress)
	{
		while (!Network.GetIPAddress(out macAddress)) { }

		if (NTP.SetUTCTimeFromNtpServer())
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	private static void AddData(string macAddress, PIRLocal.MessageType messageType)
	{
		WebClient wc = new WebClient("http://xxxxxxx.azurewebsites.net/api/values", "Post");
		PIRLocal sd = new PIRLocal(macAddress, Program.SubLocationID, messageType);
		wc.Data = sd.ToJson();
		wc.Submit();

		Debug.Print(wc.ResponseStatusCode);
		Debug.Print(wc.ResponseStatusDescription);
		Debug.Print(wc.Data);
	}

	#endregion

	#region Interupts

	private static void HeartBeatTimerInterrupt(object state)
	{
		Program.AddData(Program.MACAddress, PIRLocal.MessageType.HB);
	}

	static void PIRInterupt_OnInterrupt(uint data1, uint data2, DateTime time)
	{
		Program.MotionDetected = true;
		Debug.Print(data1.ToString() + " - " + data2.ToString() + " - " + time.AddHours(-6).ToString());
		//bool pin = pirInterupt.Read();
	}

	static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
	{
		//Program.GetIPAddressAndSetTime();
		Program.AddData(Program.MACAddress, PIRLocal.MessageType.NetworkAddressChanged);

	}

	static void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
	{
		Program.GetIPAddressAndSetTime(out Program.MACAddress);
		Program.AddData(Program.MACAddress, PIRLocal.MessageType.NetworkAvailabilityChanged);
	}

	#endregion
}


How can customer configure wifi password

12 June 2015 - 06:22 PM

I would like to deliver the nd3wifi boards with my sensors attached to my paying customers.
 
Why method is available for them to select their router and key in their wifi password?
 
Surely I am not the only person with this requirement?
 
Thank you for your thoughts.

[edit++]

So I am googling around on this topic and I find this great TI wifi chip that has WiFi Provisioning, just what I need...

http://processors.wi...xx_Provisioning

<snip>
Wi-Fi provisioning is the process of connecting a new Wi-Fi device (station) to a Wi-Fi network (access point). The provisioning process involves loading the station with the network name (often referred to as SSID) and its security credentials. The Wi-Fi security standard distinguishes between personal security, mostly used in homes and businesses, and enterprise security, used in large offices and campuses. Provisioning a station for enterprise security usually involves installing certificates, which are used to verify the integrity of the station and the network by interaction with a security server managed by the IT department. Personal Wi-Fi security, on the other hand, needs to be handled by users at home, and it simply involves typing a pre-defined password. To provide robust security, the password can be as long as 64 characters.
</snip>

...and I think I will include this chip on the board that I will eventually get into production...then I come back here and do some more reading and low and behold...the nd3wf has the chip...TaDa!!!

But it is not enabled according to this forum post.

http://forums.netdui...hip/#entry62307

So I put my vote in for Chris to spend this weekend getting this feature enabled. :)

Will this power supply work?

08 April 2015 - 05:13 PM

I am sorry if this has been answered before.

 

I have a bunch of wall warts that...

 

Output: 12V - 1.5A, +center

 

 

Will I melt the world if I run my Netduino Plus 2 on these?

 

If I can, are there any drawbacks about using them?

 

Thank you.

 

Terrence


Preferred way to get IP from DHCP...

02 March 2015 - 05:06 PM

What is the preferred library to get an IP address from my DHCP server?

I can't seem to find a consensus.

 

Thank you.

Terrence

 

 


PIR interrupt fires exact opposite

21 December 2014 - 12:17 PM

pirInterupt 
= new InterruptPort(Pins.GPIO_PIN_D8, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);

pirInterupt.OnInterrupt += pirInterupt_OnInterrupt;

static void pirInterupt_OnInterrupt(uint data1, uint data2, DateTime time)
{
	Program.flag = true;
	Debug.Print(data1.ToString() + " " + data2.ToString());
}


Netduino Plus 2

Netmf 4.3

VS 2013

 

I have a PIR motion detector sensor attached to my board and it fires continuously.

 

I started waving my hand in front of it and I noticed that it stopped firing.

 

So the interrupt fires when there is no motion and does not fire when there is motion.

 

I have tried this on analog and digital ports.  I have tried reversion the gnd and vlt pins, but that did not fix it.

 

Any idea what is happening?


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.