Microcontroller, Ethernet, PoE & I/O - Page 1
Forum section: electronics / projects

author: nathon
author_rank: Contributor
timestamp: July 02, 2015, 02:09:44 pm
content: I am starting a project for automating my home and would like to ask a few questions. The basic idea is that I'd have some form of micro-controller with Ethernet and power-over-Ethernet support that would allow me to read and control lighting, door/window switches, watering system and other household type devices. A ready-made component would be nice (micro/PoE/IO), but I'd like to start designing my own boards anyway so individual components would be an option as well.Since it pertains to potential options, I'll give some background on myself. As you can probably guess, I'm not a professional (so please forgive any dumb questions). I have extensive computer experience (>20 years) and currently work as a software developer (>10 years). Although I know it's not much, I have also been working with electronics as a hobbyist for a while but haven't designed a board yet. So far I have only worked with pre-made devices (e.g. Arduino, Netduino, Pi, etc.).Given all of the above, here are my questions.1. Although I know it's probably too broad a question, I'll ask it anyway. What's the "best" microcontroller platform for quickly piecing together a programmable I/O solution with PoE support (e.g. AVR, PIC, other)?2. If I use an AVR solution (just because I already know this) is there a schematic and chipset I can use to add Ethernet support to the AT series?3. Does anyone know of a good pre-made (and hopefully inexpensive) solution that has the micro, Ethernet, PoE and I/O?4. Got any great ideas outside of what I've asked (different solutions, read-made, how-to's, etc.)?Thanks for your time.

author: picandmix
author_rank: Frequent Contributor
timestamp: July 02, 2015, 05:15:23 pm
content: My take would be to stick with the Arduino if you are already using it.As for making your own boards, seems a bit needless with all the cheap add on boards you can buy for the Arduinos these day.You can buy a ready made Ethernet shields and even bare shields to add your own custom circuity, if you cannot find something ready made.The problem with designing and producing a single board of your own is that it seldom has the flexability to readily add in new hardware that you currenly have not even thought about.As your project develops you soon get more ideas that you original board cannot accomodate , so you end up desiging mk2 and then mk3 etc etc . With Ardiuno plug in boards you just add or remove the boards as needed.

author: nathon
author_rank: Contributor
timestamp: July 02, 2015, 07:24:29 pm
content: Thanks for the reply. My only concern with doing that is I'd ideally like the solution to fit inside a U.S. household light switch box. They are 3.51" (89.19mm) wide x 4.23" (107.44mm) high x 3.45" (87.63mm) deep before adding the light switch itself. I figured that would mean building my own.

author: Yansi
author_rank: Super Contributor
timestamp: July 02, 2015, 07:52:27 pm
content: Just a safety note:Do you trust yourself enough, to design permanently mains connected devices mounted in an electric installation?I'd NOT recommend doing so, even considering arduino into it.Consider how much experience do you have in this field, consider all possible risks. You don't wanna burn your house down. This is not fun.

author: picandmix
author_rank: Frequent Contributor
timestamp: July 02, 2015, 08:23:13 pm
content: Quote from: nathon on July 02, 2015, 07:24:29 pmFor household automation you will never get it in a small box like that.If you search the forum /web on such a projects you will see the masses of boards, wiring , relays and control cabinets etc that are needed to do such control, though perhaps if everything was done on a wireless basis you could keep the controller more compact, but not switch box size.

author: LabSpokane
author_rank: Super Contributor
timestamp: July 03, 2015, 02:38:13 am
content: It could fit in a switch box. You'll need to spin a board, but it most certainly is possible. I don't see the huge safety issue if you use common sense design practices and a relay or two. Particle.io makes a relay board for their Core and Photon that could be a great starting point. It uses wiring for coding so it will be familiar. It also has an iPhone app so you literally can be controlling relays within minutes of opening the box.https://store.particle.io/?product=relay-shield

author: Rerouter
author_rank: Super Contributor
timestamp: July 03, 2015, 03:00:30 am
content: As i am guessing your not that fond of smd components, make a generic module with the Ethernet, regulator, possible RS485 Comms, with all other wires broken out to a rugged connector, or set of through hole screw mounts, keep your interface boards simple and robust, use watchdog timers, and provide a way to reset units if they will be mounted behind walls or secured panels (held in by screws)Get your core program writted up, to connect to whatever with your comms, broadcast a heartbeat signal, etc,Then focus on adding all your other functions, it may be wiser to keep things dumb, and have it update all of its I/O states, and let the server unit decide what it wants to use or change, as this will allow your units to be generic and easily replaced,If they will be mounted behind walls, you may want to use a programmer to burn on a Ethernet based boot loader to the device, to make firmware updates by ethernet native,For simple I/O. a at 328p is more than enough, infact for anything not requring video or audio broadcasting, a 328 should suite for home automation, just make sure the units software is robust, and cannot get itself locked up,

author: linux-works
author_rank: Super Contributor
timestamp: July 03, 2015, 04:57:34 am
content: I'm going thru the same thought process right now on a project that is also for the home and remote control of 'things'.let me give my 2 cents worth, if I may, since I don't see a lot of discussion about this. tcp/ip. is this really needed?I am a software guy, too, and have done lots of network mgmt over the years. let me get right to the point; ip stacks are not chippable and they need to be patched every so often. not constantly, like a microsoft os (lol) but you have to plan to have an update story IF you are going to deploy any kind of ip networks. anyone who tells you that its 'just an ethernet arduino board' is not at all aware of the fact that there's no encryption (ssl or otherwise) in that setup and there's no real way to patch the ip stack if/when security issues or DOS issues become know, as they always do. a complex software component that is 'connected' is going to need to be updated and be updateable. it has to have a security story, even if you are going to have captive wires and not use wireless. you need authentication and some way to manage the whole thing. that's a LOT of work for even a professional (gulp). I am not convinced I would put a home user thru this; hell, I would not put most small IT dept's thru thiswhat I'm looking into, to connect the various 'connectables' is something like xbee or another fairly simple and 'not routable' (not direct IP) so that its one less thing to have to worry about.if there needs to be ip reachability to the various things, then some central system (which I guess everyone now calls a hub) will proxy for the remote boxes and it can maintain the single ip stack instance for your whole local network of 'things'.that's my take on how to at least -try- to do things from a safety and controlled access POV. ip and wifi is very convenient, but is it really a great idea with all the trouble it brings?

author: LabSpokane
author_rank: Super Contributor
timestamp: July 03, 2015, 05:59:04 am
content: Another really simple option is to use a Lantronix XPort or XPico. They are complete device servers, so one sends the device UDP or TCP commands and it forwards the data locally over serial. Writing a command interpreter in the Arduino is trivial so all you need to do is send "ON" or OFF" to port NNNN and the arduino can pop a relay, triac, whatever.http://www.lantronix.com/device-networking/embedded-device-servers/xpico-wifi.htmlThe Lantronix devices also have a built-in web server, so you could throw up a web page with virtual switches. They are not cheap, but it's a compact, finished solution. I think that you could stuff it all into a 1 gang electrical box and use an extra USB power cube (or guts thereof) to run it all.

author: funkathustra
author_rank: Regular Contributor
timestamp: July 03, 2015, 08:55:09 am
content: A few months ago, I built a WiFi-enabled, mains-powered, capacitive-touch gesture-sensing TRIAC dimmer and crammed it into a 1 x 2.3 x 1.5" enclosure designed to be similar in size to a traditional dimmer. To get everything in there, I built a stack with three separate single-sided PCBs. I probably could have gotten it down to two PCBs if I did double-sided assembly, but I hate hand-soldering that stuff. Do yourself a favor and don't be afraid to split the design onto multiple stacked PCBs -- otherwise, you'll pull your hair out!As for powering it, I've used Linear's PoE portfolio before. Expensive, but super easy to use (kinda sums up Linear's PMIC stuff, in general).I also have a bit of a rant for you about MCUs:Microchip and Freescale are the companies I'd turn to for embedded Ethernet projects. Microchip's stuff has a very short learning curve if you're trying to do something simple, but I feel like their architectures and tools are really clunky once you're in the zone trying to get stuff done -- though I will say they're making a good effort to modernize their PIC32 development ecosystem quite a bit, and they do have aPIC32 Ethernet boardthat looks quite reasonable.Having said that, I'd probably pick Freescale over Microchip for a variety of reasons: The ARM Cortex-M4 architecture found in Freescale's Kinetis K-series MCUs is a much nicer, more modern architecture than anything Microchip has (except maybe their PIC32 stuff), their development boards are nicer and cheaper, and their development environment is easier to set-up and more productive than the NetBeans-based MPLAB X that Microchip uses.MQX (Freescale's RTOS) has excellent support for TCP/IP, and an easy-to-use tasking library that will make someone who's used to developing PC software feel quite comfortable. Pick up a low-costFRDM-K64Fdev board, download Kinetis Design Studio (Freescale's open-source Eclipse-based IDE), the latest version of the Kinetis SDK, and get rocking.In general, I've found Freescale's ARM portfolio and development ecosystem to be highly underrated by hobbyists -- not sure why. Their FRDM boards are really low-cost, and cover everything from $0.80 ARM Cortex-M0+ little guys to 150 MHz Cortex-M4F beasts. They all have built-in full debuggers on-board, and, somewhat confusingly, actually allow you to upload different debugger firmware images to the debugger, (so you canmake your $14 FRDM board "look like" a $300 Segger J-Link, for example)Since your background is PC software development, you may want to look at the .NET Micro Framework ecosystem, specifically theGHI Electronics G120 SoM, which has full ethernet support. All the .NET Micro Framework (NETMF) boards connect to your computer over USB and are programmed in C# in Visual Studio, so if you've done any .NET before, you'll feel right at home. NETMF "feels" like you're writing desktop software -- since it's C#, you get built-in threads, events, exceptions, sockets, and all that other lovely high-level stuff that desktop developers are used to.I have no idea why anyone would recommend Arduino (or any of the Atmel 8-bit MCUs), since none of them have an ethernet PHY? You'd have to solder down a crazy-expensive Ethernet controller IC just to get it on the network. Yuck.Arduinos are great for people who have never done any programming before, but it sounds like you've got a strong background in software development -- I'd go with something a bit more advanced if I were you.

author: daybyter
author_rank: Frequent Contributor
timestamp: July 03, 2015, 12:46:11 pm
content: I would take a look at the stm32duino platform. Arduino simplicity with arm32 power. Just learning it, and I like it so far.

author: nathon
author_rank: Contributor
timestamp: July 03, 2015, 03:31:20 pm
content: Wow! I just came back to this thread the following day and am thankful for all the great information!I have considered the issue of mains voltage. One thing I'm trying to avoid is having to rewire the house. However, I'm not going to just throw something unsafe together and I do have experience doing quite a bit of electrical.Thank you funkathustra! A .NET based solution would be perfect since that's what I do for a living. I also appreciate all the other advice and specific MCU information you gave me!Labspokane, I'll take a look at that Ethernet port. That looks really neat and compact. My only concern is the amount of memory and library support it would have. I'm thinking of an MQ based messaging service back to a centralized server so that really shouldn't take that much room though. Thanks for the info about the relay board as well.linux-works, unfortunately I won't consider a wireless solution for this for several reasons. First is reliability. Wireless, especially in the ranges we're talking about, is subject to all kinds of interference. Things like lighting, safety systems, etc. must always be functional. I find wired connections would be more reliable than wireless in this application. My idea is to isolate from mains by PoE and go fully wired. Second is security. I can get over most security issues with IP by isolating the network properly. I understand about OTW security, stack security, maintenance, etc. and plan to ensure I take that into consideration. Thanks for the input!Thanks rerouter! I agree that simpler is better. I plan on making most of the processing happen on a home management server (yet to be built). I'll probably simply have each unit run an MQ client that updates it's current state and listens to messages intended for itself. That should be light enough. The server will manage the higher level rules, states, etc.Thank you for your help everyone! This has given me a lot to consider and some great specific information on things to look into. It's exactly what I was looking for!

author: linux-works
author_rank: Super Contributor
timestamp: July 03, 2015, 04:04:29 pm
content: as I said, I'm going thru the same process right now. I'm trying to push wired poe as a way to deliver power and data to remote sensors and motors and things in a heating/air system. we can trust wired and we know wired works. wireless is so tempting (of some kind; some packet rf, not nec. wifi) but like you said, it could get kicked off the net or interfered with and that's not acceptable.but even with wired, this is NOT a security design! if anyone gets access to that wired lan, bad things could happen. to design a system and leave security hanging is not a good design.people have mentioned arm and microchip for ip stack devices. again, I ask you, WHO does the software updates, if anyone? if a problem is found on your little webserver or the ethernet or ip or tcp layers, who fixes it? who steps up? and how fast?that is what I like about the linux stack. I KNOW it will be supported pretty much forever. even the old 2.2 kernel had security patches for a long time and the 2.4 kernel and so on. android EOL's things (so I would not even THINK about using an android box as an ip-stack system!) but a pure linux software ip stack is supportable and generally safe. it has a good 'security story' and you can get updates simply by apt-get update (or equiv).so, I strongly suggest people rethink the ip-stack-on-a-chip solutions or ones that come from vendors who are really not that great at ip networking (ie, almost everyone, sad to say).for me, the search still goes on. I won't design an industrial quality system using hacker parts; so the rasp pi is not going to be the solution and even the beaglebone (which I consider much better hardware) is not going to be around for a real long time. I'd like to get an industrial quality system that runs an open source version of a recent linux kernel, does not have binary blobs for anything and will be around 5 or 10 years from now, so that you can still get parts. that does bring up another issue: if you design for a system, how long WILL you be able to keep getting support and parts?all that matters to me. this isn't a science project, its controlling real things and has to live a long time and be supportable, updatable and repairable/swappable with shelf spares.and with a regular linux ip stack, you can do ip-tables, lots of permit/deny statements, web based access control, ssl encryption layer, even a vpn tunnel if you really need it. and if you do run a webserver (REST apis are all the rage) then you DO want to have a good update story for any web tech components you are relying on.the wiznet ethernet/ip chip that I often find in arduino systems is nothing I would even take seriously. again, how the hell do you update it? you don't! that's why its a dead-end to me.

author: eneuro
author_rank: Super Contributor
timestamp: July 03, 2015, 04:53:10 pm
content: Quote from: linux-works on July 03, 2015, 04:57:34 amProbably not since 1inch2 PCB simply cheap 433MHz RF modules easy had communication tens of meters and hundred or so at my yardWireless radio communication raises security concerns, so sometimes hard wire inside home wall can be better, but need to wire house and pay for additional copper, probably not worth it and now I'm looking for a ways to provide secure RF communications with one way passwords to authorize remote control over automated thing.Cheap Wi-fi might be interesting option too for smaller distances and as management tool, since there are many such ICs with builtin small WWW server, so one can configure and talk to MPUs from browsers, which means simply and easy interfaces, available from tablets and even TV sets have WWW browsers those days, so one could change home automated system settings without need to play with small screens in their cell phone or tablets, but comfortable on huge TV screen...I've started automation from simply thing-home main doors ring bell-of course wireless and with builtin RTC and AVR MPU do encrypt radio communication and let me controll also other things like garage doors, outdoor lights, etc... It will be integral part of automation system, but visitors will see only simple button to.. knock the doors, but it will have hidden functionality after enterring one way password security code, which could blow their mindI've 433MHz RF modules for the moment to test my vision of wireless controled devices in home and near yard, so I need a few hundreds meters range, so probably simple RF repeaters powered from small solar PVs will do the job

author: linux-works
author_rank: Super Contributor
timestamp: July 03, 2015, 05:04:10 pm
content: I do, very much, believe in the current trend of using RESTful web services for remote mgmt of 'things'. if you want to have a human interface (html) and a machine interface (json over rest over port 80) then you get bonus pointsbut I'm thinking that having ONE ip stack is enough; one web presence that can be monitored and secured and kept updated. the rest of the leaf nodes could be rf connected (I agree its soooo convenient to go RF of some kind instead of dragging cables all over) but those rf links would not be running ip or web services, and so they are not directly attackable in the usual ways. to get to them, you'd have to get to the main webserver and hopefully that is well secured.so, put me in the camp where I think that each 'thing' having its own ip addr is silly and uncalled for. its too much and too risky. a single IP has to be there (at some point) but that does not mean every little thing has to carry around an ip stack.I see lots of IoT protocol talk when its ip to ip and a 'cloud' is involved. but I don't see a lot of talk about machine to machine using non-ip protocols and still having a good authentication and encryption story.

author: eneuro
author_rank: Super Contributor
timestamp: July 04, 2015, 08:50:06 am
content: Quote from: linux-works on July 03, 2015, 05:04:10 pmIt depends how many bits have to be exchangedYou can have flash memories with TRNG bits in each of those devices on encrypted RF network, and one time passwords created using this data, so this system can be even more secure than SSL/HTTPS since simply XOR encoding with those random bits will succesfully encrypt data and in theory there is no chance decrypt such messages.This simply cipher has some pitfalls and is of course not practical to encrypt megabytes of data in real time without shared huge TRNG bits database between devices, but what I might need to automate house is send from time to time a few bytes of messages to open/close switch, so with the help of a few GB flash memories can last for a long time before I will need aother TRNG datahttps://en.wikipedia.org/wiki/XOR_cipherIf the key is random and is at least as long as the message, the XOR cipher is much more secure than when there is key repetition within a message. When the keystream is generated by a pseudo-random number generator, the result is a stream cipher.With a key that is truly random, the result is a one-time pad, which is unbreakable even in theory.So, using TRNG one-time pads I can have really strong encryption and no worry someone finds a way to brake SSL/HTTP or other ciphers, since I have random bits as long as the messages send.This way, this what someone someone can pick in the air will look like RF noise - nightmare even for NSA