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

Home Control with Netduino Plus 1


  • Please log in to reply
16 replies to this topic

#1 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 19 February 2013 - 06:05 PM

Hello guys,

 

I'm planning to create a complete Home Control System using the Netduino as server.

In this case I've some questions or problems and I would be very happy if you could help me to solve them.

 

First: As request later I would like to define settings at a computer and transfer them to the Netduino, which is connected to the network. Then, the Netduino shall work completely independent.

 

And here is my first question: Is there any sort of database on the Netduino, that allows me to save values on the Netduino which are permanently stored?

 

Many thanks in advance,

JoRu1407



#2 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 19 February 2013 - 06:23 PM

no there isent, but you can save your data on a sd card, and if its smaller than 64kb on an eeprom.

there is also flash ic's with some mb (but i think they are unhandy, need to earse a whole sector a time.. and such stupido stuff :P )



#3 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 19 February 2013 - 06:26 PM

You can use either serial communication or host a web server like the NeonMika webserver on the Netduino.  Since you want it connected to the network the NeonMika webserver is probably the way to go.

 

There is no database on the netduino but you can store any files you want on the SD Card.  You can create a text based config file and update and read it using the NeonMika webserver.



#4 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 19 February 2013 - 06:37 PM

Tanks for your answers.

 

I imagine that the following way: With the computer I can set different timetables for each output.

They are saved on the Netduino and it will set the Outputs on or off - Based on the configured times.

 

And there's also my second question: Is there any clock on the Netduino and is there any possibility to get the actual time automatically from the internet?



#5 NooM

NooM

    Advanced Member

  • Members
  • PipPipPip
  • 490 posts
  • LocationAustria

Posted 19 February 2013 - 06:39 PM

you can get gthe time by timeserver.

and use a realtime clock as backup (the ds1307 chip even havs some battery backed sram - wich you can use to store a few timetables)

 

the netduino has no builtin rtc :(

 

i hope netduino 3 will have one :P



#6 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 19 February 2013 - 06:49 PM

Ok, so if i understood it properly:

 

I shall generate a txt file with the timetables at the computer and transfer them using the NeonMika Webserver to the Netduino's SD card.

 

Then it will be possible to read the configured times from the txt file and to trigger events based on them?

 

And regarding the clock I should use the ds1307 chip and get the time from a timeserver?

How is the chip connected to the Netduino?

 

P.S.: You have to know I was only programming Omron PLC yet and there it's all completely differnt  ;) 



#7 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 19 February 2013 - 06:59 PM

Yes you can poll a time server to keep the time accurate and update the DS1307 Real Time Clock (RTC) on a pre-programmed schedule (ie: every day, every hour).  The reason for the DS1307 RTC is to keep time on the Netduino if the power goes out or if the network connection is lost.



#8 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 19 February 2013 - 07:32 PM

So, now I defined the following two structures of my txt files:

 

Attached File  timetables.png   27.38KB   17 downloads

 

(This are different timetables where you can set 10 different times (T1-T10) and the associated states that the output shall get.)

 

Attached File  outputs.png   2.77KB   16 downloads

 

(This are the outputs of the Netduino with information which timetable shall be used on which weekday).

 

Do you understand my structure?

 

Now is my question: What's the best way to work off these rules every minute on the netduino?

With a while(true) loop and many different if conditions or is there a better way?



#9 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 19 February 2013 - 09:10 PM

You may want to look at this scheduler. http://forums.netdui...uino-scheduler/

 

You can also consider using XML instead of fixed text in your configuration file. Something like this.  You can even use JSON.  Both can be pushed and retrieved by the NeonMika WebServer.  Using XML you can also create a style and transform and allow a user to get a HTML page of the schedule by going to a URL you configure (ie: http://192.168.1.4/MyGizmoSchedule)

 

<scheduler id="1">

  <timer id="1">

  <time>18:00:00</time>

  <action>on</action>

  <device>1</device>

  <status>off</status>

  </timer>

</scheduler>



#10 emg

emg

    Advanced Member

  • Members
  • PipPipPip
  • 129 posts

Posted 19 February 2013 - 09:27 PM

+1 for using XML or other machine readable format. I would also look to change the schema so you can define any number of on/off times per end-point rather than a fixed flat layout as you are currently envisioning.



#11 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 19 February 2013 - 10:41 PM

Hey JoRu1407,

 

I'm now back at my home office so I can give you a little more verbose answer on your post.

 

First, I know you likely already have a Netduino Plus, but you may want to consider getting a Netduino Plus 2 for this project.  It gives you more code space and runs faster.  I only recommend this because you may want to add new features down the road.

 

So, the web server I recommended is called the NeonMika webserver.  It is available on Codeplex and there is a thread on these forums about it. The server is pretty robust and Markus explains how it works pretty clearly.

 

Another good example using a slimmed down version of the NeonMika server that uses a webpage to save a config file like you are trying to do is the DIY Brewery Temperature Logger project which is also discussed in the forums.

 

As I mentioned earlier this may be a good scheduler example to look at: http://forums.netdui...uino-scheduler/

 

For the Clock Portion... as mentioned the Netduino will only keep time while powered.  So when it loses power or is rebooted time is gone.  The solution is a DS1307 Real Time Clock.  Here is one example from Adafruit.  It is I2C based so it's easy to hook up.  The .NET Micro Framework Toolbox written and maintained by Stefan contains a driver class for the DS1307 as well as an SNTP Client class for getting the time from a time server.

 

On the Networking side, you may want to also add NameService support so you can access your ND+ on your network using http://MyNetduino instead of http://192.168.1.4 or whatever IP and NAME you choose to use.  I am using this class from Huysentruit Wouter and is easy to implement.

 

This should get you started started in the right direction.



#12 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 20 February 2013 - 05:30 AM

Hi Dave, first: Thank you very much for your extensive answer.

 

I'm already considering on getting a Netduino Plus 2, but I'll wait if it's not to complicated to realize the project with it because otherwise I planned to use a PLC. :D

 

In the afternoon I'll download the NeonMika WebServer an work me in.

 

Regarding the clock: If the Netduino only will lose the time if it's powerd off that would also be ok, because internet is alway there. So I'll try to set the Netduino Time with the NETFM Toolbox, right?

 

And regarding the IP adress: I don't need a real network name because I generally work with IP adresses - That's not so important ;)

 

So, now I'm going to try out the whole things and if there's any problem, I'll aks here :)

 

With best regards,

JoRu1407



#13 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 20 February 2013 - 12:07 PM

Regarding the clock: If the Netduino only will lose the time if it's powerd off that would also be ok, because internet is alway there. So I'll try to set the Netduino Time with the NETFM Toolbox, right?

 

Yes each time you power up the Netduino the time will be incorrect.  You will need to update it using the SNTP class in the NETMF toolbox and perhaps use a timer to update it on a schedule just in case the power is lost.  Perhaps every 15 minutes this way there is a good chance it will not interrupt your scheduled events.



#14 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 22 February 2013 - 12:39 PM

So here's the guy from NeonMika.Webserver :P

If you have any questions about it, just ask.

I think you could do this pretty easy with my webserver code. Just write a small method, probably called "ChangeSetting". This will have 2 Parameter: "Name" and "Value". And to change one of your Settings just call the URL. But it's all yours how you want to design the communication. But I think it shouldn't be hard to implement it.

 

Greets, Markus

 

EDIT: You could also generate the file on the PC side and just upload it to the SD Card via POST. :)


NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#15 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 02 March 2013 - 08:55 PM

So, after some tests and plans I would prefer to transfer the settings via HTTP Requests from my Application to the Netduino.

Now I need a simple class to save variables to the SD card and read them out after restarting the Netduino.



#16 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 02 March 2013 - 11:08 PM

The DIY Brewery Temperature Logger project I mentioned a few posts back has this capability. You can use that as an example.



#17 JoRu1407

JoRu1407

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 02 March 2013 - 11:38 PM

Oh, sorry, I overlooked it. Thanks ;-)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.