Live logger for home power usage.
eagletalontim
Posts: 1,399
This is an interesting idea and I know it has already been done but..... I want to build a logger for how much energy I use based on what my power meter says. I have one of those "smart meters" which allows the electric company to read / monitor the usage any time of the day. My lovely power company has now put into affect this new system which charges more per kWh for 8 hours a day. The time the cost goes up is determined by the summer or winter. In the summer, the time is from 11AM to 7PM, and in the winter it is from 11PM to 7AM. They are able to read this usage due to the smart meter.
Interestingly enough, there is an IR light on the very top of this meter which flashes for every time a watt hour used. I tested this by using the camera on my phone to see the light blink and sure enough, it did. The flashes were closer together when the AC was running and when it turned off, the flashing was slower.
What I am hoping to do is to have an IR sensor pick up these flashes and send the information to one of my computers. Since either of my 2 computers are about 20 feet away, I am not sure if I should use wireless or wired communication from the sensor circuit to the computer. I am thinking wired since it would be less hassle in the long run, but I don't like climbing under my house Also, I need to figure out which chip would be best to use to read the IR pulses and send them via USB or Serial to my computer, SX28 or Prop. I am thinking the Prop would be better since it can handle more than 1 process at a time without possible timing issues and missing a pulse here and there while sending data to the computer. Any feedback on this?
I do have some VB6 programming knowledge and have built a computer control wired car a long time ago using the SX28. I am hoping to have a VB program that runs in the background which reads the information from the chip and send that information to my web server which will then store the information into my mysql database for later viewing with possible graphs and more.
A few questions I have.....
1) Is the SX28 capable of counting the IR pulses while sending information to a computer via Serial or USB at the same time?
2) Would the Prop be a better chip for this application or is there another "less powerful" chip?
3) Does VB6 recognize USB devices that don't have a specific driver? I am not familiar with RS232 or any type of USB communications.
4) Would Serial communication be easier, effective, and cheaper?
Interestingly enough, there is an IR light on the very top of this meter which flashes for every time a watt hour used. I tested this by using the camera on my phone to see the light blink and sure enough, it did. The flashes were closer together when the AC was running and when it turned off, the flashing was slower.
What I am hoping to do is to have an IR sensor pick up these flashes and send the information to one of my computers. Since either of my 2 computers are about 20 feet away, I am not sure if I should use wireless or wired communication from the sensor circuit to the computer. I am thinking wired since it would be less hassle in the long run, but I don't like climbing under my house Also, I need to figure out which chip would be best to use to read the IR pulses and send them via USB or Serial to my computer, SX28 or Prop. I am thinking the Prop would be better since it can handle more than 1 process at a time without possible timing issues and missing a pulse here and there while sending data to the computer. Any feedback on this?
I do have some VB6 programming knowledge and have built a computer control wired car a long time ago using the SX28. I am hoping to have a VB program that runs in the background which reads the information from the chip and send that information to my web server which will then store the information into my mysql database for later viewing with possible graphs and more.
A few questions I have.....
1) Is the SX28 capable of counting the IR pulses while sending information to a computer via Serial or USB at the same time?
2) Would the Prop be a better chip for this application or is there another "less powerful" chip?
3) Does VB6 recognize USB devices that don't have a specific driver? I am not familiar with RS232 or any type of USB communications.
4) Would Serial communication be easier, effective, and cheaper?
Comments
You'll also need to do some more research into the IR. It will almost certainly be regulated at a frequency (38KHz, 54KHz, etc.), and it probably includes some sort of data in the transmission. My guess is that each time it turns on it transmits the total. If you do find out more, please post. That's interesting (and useful) information.
The computer would recognize the port as a serial port. There are a number of examples here on the forums of using VB for serial port reading. In my work, I've used PySerial to do the same with Python.
I'm also curious, but on an ethical note: while it's unethical to trick the meter into thinking it's the opposite season or time of day (to get the lower rates), is it illegal? And is it technically possible?
A prop with an SD card could be the beginning of a home monitoring/automation system.
In general terms, I think the Propeller is the best chip. This project is just a bit too complex for arduino or picaxe, and Basic stamp. But it is overkill to run a PC all the time with the 30-100W it consumes.
So 1) I don't know about other chips, but I know the propeller with all those cogs is perfect for multitasking. You will end up with cogs to spare but who cares, at least you know you will never miss a pulse.
2) With some super smart coding maybe there is a "better" chip but with the prop you don't have to be super smart. Just plug in lots of obex code and a tiny amount of glue code you write. Which the forum will gladly help with as this is a cool project
3) vb6 and vb.net and C# can easily talk via RS232. USB is a little more complex, but I'd stick with RS232. It is boring and slow but safe and easy to debug. $2 will buy you a USB to serial adaptor on ebay, and at the propeller end, a max3232 will set you back about $1.
4) Yes I like serial comms. I've got a pile of code in vb6 and vb.net for serial and I can send you this if you like. I've also got free serial port sniffer software which is great because you can see the individual bytes going back and forth. Much easier to debug if you can see things.
If you don't like climbing under the house, there are lots of modules around that convert RS232 to wireless. Usually around $30-$40 a pair. I think they are that price because in China they are mass produced for remote monitoring of power use. Which is kind of appropriate considering what you want to do. So - at the PC end, a $2 USB to serial adaptor, then convert that to wireless serial at 1200 to 19200 baud. Then at the prop end, one of those wireless adapters going straight into the prop. A IR phototransistor and a RTC chip on the I2C bus of the propeller and you are set. Maybe an SD card if you want to be able to turn the PC off.
Just a thought.
Mickster
I decided due to cost to go with serial communication since I have tinkered with it in the past and I know there is no extra circuitry I would have to purchase to communicate with my computer. I also bought 50 ft of shielded 2 wire cable which will run to the IR sensor. The prop will be located close to the computer to be within range of the serial cable I have. If anyone has source code on how to communicate via serial to a computer using the Prop, please feel free to post it I am hoping to have my air conditioning replaced with the new R410 unit from my old R22 soon and would like to be able to monitor how much of a difference it is in power consumption. Hopefully this change will happen next week so I really got to get something working. I am doing my own research now, but any working code that I can use will be very helpful!
Here is my code so far :
I am not using the serial just yet as I am still learning about this.
There is something very interesting about the IR LED on the power meter... It is not a flash, it is a series of quick flashes. This is probably some sort of coded output that is used by the electric company. Not quite sure how to use it, but I may just add a delay that is long enough to pick up the first flash and ignore the rest. Not sure how accurate that will be, but I am sure I can figure something out.
For discovering the code (if any) the simplest would be to see if you can find the info on the meter manufacturer or your utility's web site. If it is not available you could try to decode it by using a quick and dirty 1 channel logic analyzer. That is once you detect the first flash you shift in bits one at a time at a fixed rate until there is no flash for a reasonable period of time. The fixed rate and reasonable time would have to be determined. The code could be almost anything, RS232 async ascii, IR remote, PWM232, one of the barcodes, or even morse code (yes, I saw that once in a circuit designed by an old ham radio enthusiast).
For the serial connection to the prop, I am using Figure 2.3.2 on page 5 of this document : http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PropellerDatasheet-v1.1.pdf
Here is the Prop Code :
And the VB6 Code :
It has been a long time since I have messed with VB6, but I am sure I have everything correct. Is there anything you might see wrong?
EDIT : VB6 Code changed. Still not working
Also, try not using the VB6 code just yet and just see if you can get the string on a regular terminal such as the Parallax Serial Terminal or the like.
I presume you have the polarities correct, max232 etc chips. Can you get data into the prop terminal to check the prop is sending?
Still not getting anything
This hangs the program
Here is my code so far :
It also seems to cut off some of the text, but I think that has to do with a timing issue. Any way to not hang the program while waiting for a serial communication?
For hanging, you could set up a loop with a timer, check the number of bytes in the buffer say once every second, then when there are enough, read them in. Also DoEvents is useful for things that hang because if you have multiple threads and one is in a tight loop you can put delays in that loop and DoEvents and then most of the time the program can go off and run other threads.
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PropellerDatasheet-v1.1.pdf
I don't think I need the DTR connection since I am not programming though this port, but it is wired up this way on my breadboard. I have checked every connection and it matches the schematic exactly. Same transistors used, Same resistor values used, and pins are not close to any "static" signals. Why would this work through the USB prop plug, but not through a straight serial connection?
You probably don't want to have the DTR line hooked up at all. Some COM programs I've used (Python, I'm looking at you!) always toggle the DTR line. This puts the Propeller into a reset, so you wouldn't see any serial data for a while, if ever.
Maybe this will make sense to someone, but here is my idea on how to do this. First, the Prop will time the interval between pulses and store the result in an array(?). After 1 minute or 30 seconds or even after X number of pulses, depending on which one will dump the array before it gets too big, it will then send that array to the VB program which will process the data. The data should be stored something like array('1000', '1500', '1500', ....). The VB program will count how many stored values there are and add up the values to get an over all time. If each pulse = 100 watt hour, then I can use a math formula to calculate how much power was used during that time period the Array stored. I am going to see if I can figure out this formula. If there is a better / easier way, please let me know!
"Interestingly enough, there is an IR light on the very top of this meter which flashes for every time a watt hour used. I tested this by using the camera on my phone to see the light blink and sure enough, it did. The flashes were closer together when the AC was running and when it turned off, the flashing was slower."
If each blink represents a fixed number of watt hours why not let the prop do a little preprocessing by having it count the number of pulses and sending a count at a fixed interval (say once per minute) or when the pulse rate changes by more than some amount. The PC can add the time and date to the count so you can graph power usage and identify power hogs or appliances that run during peak rate times.