How complex can a sketch be? Energy Usage Monitoring and Control

I am hoping to be able to use an Arduino (or a number of them) to control energy usage. I want the software to be able to count the pulses on five electricity meters (optically) and calculate various electricity usage through each mains circuit by powering on/off various devices attached to those circuits - I want to use excess solar power I generate to power things like a heat pump when excess power is being generated. I also want to be able to measure temperature at a number of locations (approximately 35 of them over a 1 or 2 wire bus) and switch on/off various (maybe 10 of them) heat sources and ancillary equipment like pumps plus a further 24 valves etc. according to what is required by the software I want to write. This is just the beginning really because I'd like the software to be able to dynamically map the thermo and energy usage dynamics of individual heated areas/circuits and climate compensate etc. accordingly (by 'learning').

My questions are:

  • Is the Arduino powerful enough (alone or in combination with other Arduino boards) to perform this level of control?
  • Is the space available to load software going to allow a sufficiently complex program to be written and stored for execution to perform these sorts of tasks?
  • Will something like Xbee provide enough communications ability (through walls over relatively large distances) to enable communications between (say) separate boards in different physical locations - for example the meters are located some distance away from the rest of the building?
  • I am new to hardware, but have a programming history from the early nineteen eighties - but I've not done much since back then. From what I have read I believe I can do the programming, but am I deluding myself?

TIA of any thoughts offered.

jumping straight into all of that at once is probably a bit of deluding yourself. Maybe try making on a smaller scale and arduino that handles 1 portion of your mission, then having that share info with another arduino you make later that handles another part.

Assuming by what you read (though you probably meant more then this, correct me if I'm wrong)
Task list
1, Read temperature at several different points.
2, Read power consumption 5 different areas.
3, Based on the temperatures in the different areas control several heating sources to keep those temperatures at a desired level.
4, Able to shut off power in certain areas if the power consumption reaches a certain "too high" point. Or just shut things off at times they aren't needed.
I don't really understand the "excess solar power" and the heat pumps when the excess power is being generated. Though there are ways that you can measure that too. Maybe have another set-point for your heating system based on if there is excess power being generated.

Thing is, arduino can take some pretty complex programming (even more so for an arduino mega). In truth your more limited by the hardware of the arduino.
1 your going to have to turn every signal into something the arduino can take without breaking (shouldn't be too hard).
2 you need to get all that data to your arduino (well your pretty limited on pins).

Might end up wanting to use a few arduinos (heck they're pretty cheap), and designing each one to act as a controller for 1 part of your system. Then over wifi or however you want, have them send commands to each other as needed. That way you won't hit a wall with programming space (only 32k, which is surprisingly little though I'm not the most efficient coder) And it'd be easier to debug because it'd be a smaller segment of code all in one area that you could figure out if its causing a problem.

On regards to Xbees though. If you spend a bit of money, the higher power Xbees can cover fairly large distances (I've gotten over 1/4mi range in the woods using an XBee Pro 50mW) So I'm pretty sure unless you've got some 4ft thick concrete walls at your place it can probably go across your whole building.

Dunno though, I'm still pretty new to these electronics things (mechanical engineering student, 0 electrical training, and my boss showed up with a box saying "here build me this" a few months ago) so I really have no clue whats really "complex" cause about everything I do is to a degree complex for me.

Good luck though, probably if you could describe your needs a bit more, some of the more experienced members could point you towards the right parts youd need.

You'll need a mega for that number of inputs, or an Uno with some external multiplexing hardware. Unless you're going to want to run wire between your buildings though, you probably need at least two arduinos. An Uno should be able to handle reading the meters and it can send the data it gathers to a master mega either by wifi, or xbee. In my experience, the wifi shield I've used doesn't have much range - less than 100ft. You need to choose your xbees carefully too - my first one had little if any more range than the wifi, the pros I have now can do substantially more with brick walls in the way. Again, depending on how much wire you're prepared to run, you may need several more satellite Unos servicing sensors and transmitting their sensor data back. It may be possible to offload control of some of your outputs to some of these devices too.

The mega has enough program memory for a very complex program indeed, although depending on how much data you need to keep to feed your learning algorithm you may need to add external storage of some sort to supplement the 8K of RAM. You'll probably need this anyway in the end, so you can do some logging just for debugging purposes.

I'd start as small as you can - get a couple of Unos and xBee shields and have one read the power data and transmit it to the other for display. Get some DS18B20 temperature sensors and start reading them. Then build up to controlling heaters and valves.

All that is doable and as always there are many ways to do it. The guys above have presented some good info so I'll plug my pet idea.

I would use a network of Mega1284-based "Arduinos" connected with RS-485 in a redundant-ring topology. This is very robust and the ring topology allows you to remove/add/replace nodes or handle line faults/dead nodes without bringing the network down.

I would then add a custom bootloader to these 1284s that allows nodes to be modified/upgraded from a central point so you don't have to bring them back to base or take your laptop out to the shed.

I would also write a multi-master protocol based on the publishing/subscribing model which will make the application coding easier. For example a node with an LCD display that showed certain data could be duplicated and many of them could be placed around the network. Need another display in the garage, just plug one in using exactly the same code as the others.

I would then add a wireless gateway node to allow access to areas where running wires is difficult.

Whoa hang on...just by coincidence that's exactly what I'm working on now :slight_smile:

It's early days though, I've not written a single line of code but am just about to send PCBs off to be made.

I don't really understand the "excess solar power"

Once your batteries are charged the power generated by the panels is wasted, if you can put it to good use that's good.

I can do the programming, but am I deluding myself?

I doubt it, once you get back into the practice of programming you'll figure it out. Just don't try to do everything at once.


Rob

Many thanks for all your input. I am very encouraged. I think I'll get a couple of boards and start by making something that can count the LED pulses from the meters and log the data with a time profile on a local SD card, and expand form there. The control of the solar pv generation is most important to me right now as I'm in the Northern Hemisphere and so we are getting as much solar radiation as we are going to get during a year. Then onto temperature monitoring and control of heat sources etc. Thanks again.

I would also write a multi-master protocol based on the publishing/subscribing model which will make the application coding easier. For example a node with an LCD display that showed certain data could be duplicated and many of them could be placed around the network. Need another display in the garage, just plug one in using exactly the same code as the others.

I would then add a custom bootloader to these 1284s that allows nodes to be modified/upgraded from a central point

Is there an online resource/URL that you could recommend to expand/explain these further?

TIA.

Is there an online resource/URL that you could recommend to expand/explain these further?

Nothing online that's up to date, but if you email me (rob@robgray.com) I can send you a PDF that describes the system design as it stands now.

Warning: It's been simplified a lot over the last year or so but still seems to scare everyone off that reads about it, so it's either too bad to comment on or too complex for people's needs :slight_smile:

I've been living on solar for 12 years and a while back I decided I'd like some comprehensive monitoring and control of our system (as well as other stuff in the motorhome).


Rob

Biggest problem you will have is being efficient with you use of RAM. The Arduino has 2K of RAM and if you are used to programming in a Microcomputer environment you may not be used to considerring just how much RAM you are using. Variables, They are pretty easy to keep track of their memory usage, Stack usage can be a bit harder, the more function calls, and the more nested calls will quickly use up a lot of RAM. For a more complex system you need to consider efficiency of coding, and memory usage. In the old days these were things we always had to consider. With Microcontrollers we once again have to keep RAM usage in mind.

You may be able to develop some of your basic ideas in Arduino, and then go to Assembly to better control the system resources.

Yes it will not be possible to run this entire system on a single Uno, or even a Mega I would think (although I think the new Due would handle it). That's a good reason for using a model that has distributed processing.

Another reason is wires, with a single master you will have 100s of wires running all over the shop, with a network there's only a single wire. Also with a single master you are completely dead in the water if it fails, with a multi-master network many failures have little or no effect on the system.

But as always there are pros and cons either way.


Rob