where to modify code if you want to add a relay control

Im really new to emontx and arduino programming . I was wondering if i can modify the code and allow a relay control or compare current measurements .I dont know if its possible . I am planning to link this data to MakerPlot . please help 

calypso_rae's picture

Re: where to modify code if you want to add a relay control

1. The emonTx can measure currents using several CTs, and it should be easy to compare the resulting values. 

2. By setting an IO pin to be either high or low, it should be easy to control a relay. 

Does this answer your questions?

nigel91's picture

Re: where to modify code if you want to add a relay control

Can I modify the code in any of the scripts. Or just in the main script written voltage and current.. And is there any code modifications needed for me to use arduino mega 2560 .

Robert Wall's picture

Re: where to modify code if you want to add a relay control

You can modify whatever you like. Everything published here is subject to the Open Source philosophy.
You will want to modify it in the most appropriate place. Where that is, is for you to judge. Only you know what you wish to achieve.

You may have to change some things to work with an Arduino Mega. I don't know how that differs from our emonTx. I'm sure that when you understand what the sketch is doing, you will see what you need to change. It will probably be limited to some I/O designations.

nigel91's picture

Re: where to modify code if you want to add a relay control

Thank you soo much. I read some more and have gotten some results. Have started running it on my mega. Seems to be somewhat correct. But I am having problems with the power factor and when I take 4 readings all the power readings become mixed. I'm getting a power factor of 1.35 sometimes.. Do you know what might be my problems

Robert Wall's picture

Re: where to modify code if you want to add a relay control

I have absolutely no idea what you are doing, and neither has anyone else, so how can I or anybody know what your problem might be? One thing is certain, something that you have done is wrong. Part of the learning process is finding out what that is and correcting it. What you need to do is take one of our published sketches from Github. We know those work on the emonTx, make the absolute minimum changes needed to make it run on your Mega and give credible results; then pause. You now have a basic working sketch. Carefully analyse exactly what it is doing and work out why each line of the sketch is there and what it does. There is a lot of good information in Building Blocks that will help you there. Only when you are confident that you know exactly how it works should you go on to introduce features of your own.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.