### Openhab nRF24L01+ energy monitor

Hello All,

First of all i would like you to know that i am a very beginner in programming and making different circuits using Arduino, Rasberry Pi and so on.

In the same time i would like to ask the Admin to move this post / topic or to delete it if is discussed somewhere else and to lead me through a link to it.

I have the following mats:

-SCT-013-000 - 1 piece

- Arduino -2 pieces (Mega and UNO)

-Rasberry Pi model 2 - 1 piece

What I would like to do?

Using the above mats to monitor the energy consumption in my house and to export this to Openhab (which already is showing me the temp and humid) and to display the following:

1. the instant watts consumption

2. the Kwh consumption calculated from a certain date as for example starting from the beginning to the end of the current moth and to start counting from the beginning when the nest month begins

3. to display the total Kwh since the program was uploaded in the Arduino.

To accomplish this do i need to use only the SCT sensor or is necessary to use the AC-AC transformer too according to the diagrams shown on the site.

DragosC

### Re: Openhab nRF24L01+ energy monitor

I shall only answer this one question: "do I need to use only the SCT sensor or is necessary to use the AC-AC transformer too?". There are others here who can answer the other questions better than I can.

NO, you do not need to use a transformer to measure the voltage, but this is what happens:

The voltage at your house will vary according to how much power you and your neighbours are taking from the supply, and 'neighbours' may include your city or a large part of your country.

With a transformer, you know the voltage all of the time. Also, you know the phase relationship between the voltage and the current. Taken together, these things mean that you can calculate power, and therefore energy, to the best accuracy.

Without a transformer, you must guess the average voltage that you receive, and you must guess the power factor (see Building Blocks if I use a term you do not understand) and so the power you calculate will be less accurate. Over time, and by carefully adjusting the calibration, the inaccuracies might even out.

You do not say anything about your electricity supply or which country you are in, so I cannot guess what sort of supply you have. I do guess that you have only a single phase supply because you have only one current transformer. If you have a three-phase supply, you really must measure the current of each phase, that means 3 CTs, and ideally you measure the voltage of each phase also (but many people are happy to measure only the voltage of one phase because generally the three vary together).

### Re: Openhab nRF24L01+ energy monitor

As you already guessed i live in my apartment and i have a single phase power supply but this is not the point.

I asked if i may use only the CT without the transformer because transformer i bought even if it is labeled to convert 240V-9V Ac-Ac when i measure it with my tester it shows me 12V on the output so i was afraid not to burn the Arduino board using it! On the other hand if you use a transformer than you need to use another analog pin of Arduino and so less memory available.

​I know very well that this topic is a very complex one because it suppose that you need to combine and to know two different things like: Programming the Arduino board, programming the rules in Openhab which is different than Arduino.

I want to use the serial gateway communication between the two Arduinos (those who worked already with Openhab know what is all about) so my ask would be that if can i find somewhere here or else an example for this kind of request: instant power consumption, kwh to date, total kwh.

The second part although I know this is not maybe the right forum to ask (Openhab) would be to find some Openhab rule example for this Arduino code thinking that in this huge community maybe there is one guy who did it.

Thanks All!

### Re: Openhab nRF24L01+ energy monitor

No, you won't harm your Arduino. The input circuit in Building Blocks is designed for that 12 V output on no load, which is quite normal for a small 9 V transformer! The transformer is designed to give you 9 V at full load, and without a load the voltage will rise significantly, as you've found.

Hopefully, someone who knows Openhab will answer your other questions. I think you should be able to use emonHub on your Raspberry Pi. EmonHub is designed to accept radio (with an RFM69Pi module from our shop) or wired data from your emonTx/Arduino and send it via Ethernet to your router and then to emoncms.org. But I know that it can be used to send data to other places too. Hopefully Paul "pb66" will tell you about that.

### Re: Openhab nRF24L01+ energy monitor

Thanks again for your reply, ill try to use this schemes found on this site to see what can i read on the Arduino serial monitor using this CT sensor.

The bad thing is that i don't know how to make the Arduino sketch to display these three values: instant watts, kwh to date and total kwh!

Please i need a little help here from those who tried this combination of Openhab, nrf24l01 Arduino and serial  gateway communication!

### Re: Openhab nRF24L01+ energy monitor

I haven't been around much and I missed this thread (sorry Robert) In theory it is possible to write a reporter for openHab and I would be keen to do so but I do not use openHab and therefore have zero experience of using it.

I would be happy to assist an experienced openHab'er bring openHab to emonHub but wouldn't try and tackle it alone. I recently looked into it and it appears each value would need sending individually (happy to be corrected there) when using the htttp/rest api and since openHan is on the cusp of v2 (as is emonHub) I felt it would be better to see how that panned out and try to implement a v2 to v2 solution at a later date.

If you or anyone wants to pursue this now though I will chip in where I can :-)

Paul

### Re: Openhab nRF24L01+ energy monitor

Hi guys, I've managed to display instant power in Openhab, don't ask me how, long story.

I would like to ask you why when i test the current only sketch with every thing connected according to the diagram when i turn on the bulb which is labeled with 46W i get some values between 46 and 98 or near and when i turn of the bulb i get around 59-61!

All the mats are those explained on the site except that there no explanation how many volts the capacitor has to have but it is 10uf and so i bought some with 63 volts. The sensor is SCT-013-000.

How to calibrate the CT sensor to see on the serial monitor that when the bulb is off the displaied value is zero and when ON to see the right value?

UPDATE: i saw now if even the SCT is not connected to any wire it still display some values for the aparent power and Irms! It should show zero, isn't so?

Thank you!

### Re: Openhab nRF24L01+ energy monitor

I'm sorry, i read everything on get started and I know that all people ask different questions but I really don't understand how to calibrate this sensor.

If the diagram is ok and I test the current only eg, in my opinion it should display the right values! Right?

i really don't know what to change in the code! I tried to change different values according to my current 220v but nothing, I tried to make more spires on the sensor, still wrong values...

how is possible that without having anything connected to the sensor to get values like 15-25w ?

thanks.

### Re: Openhab nRF24L01+ energy monitor

Just a note about openHAB integration. I don't think we need to do anything special, since openHAB already has MQTT support. In my view MQTT is the perfect conduit for getting data from EmonCMS into openHAB and vice versa. I am currently doing this and it works very well. There is no need for either of the two systems to *know* about one another - they just have to publish/subscribe to the appropriate topics and that is it.

So my 2c would be, don't worry about any specific openHAB integration, but just focus on getting the MQTT side of things working so it is nice and easy for users to setup/configure/use. It also then becomes very easy to access that data in other systems, via MQTT as well (e.g. logging or monitoring systems).

I know there will be users who don't want the overhead of running their own broker and would like some sort of direct interface between the two systems, but as I say, that is just my 2c.

### Re: Openhab nRF24L01+ energy monitor

I'm using OPENHAB with mqtt and I can get some data sensors from my arduino through nrf24l01 to my raspberry but I don't know any programming.

I have this sct sensor for more than 1 year and I wasn't able to make it work well!

hobestly I didn't understand how did u make the connection between OH and Emoncms! Do you have the both software installed on your pi or how? Where are you connecting the sensor? To any arduino or directly to your pi?

as I said here somewhere above, I have no programming knowledge, the only thing I can do is to work with them.

could you please come with more details? I need to know how to get the kWh in OH.

thanks.

### Re: Openhab nRF24L01+ energy monitor

I have an Arduino Uno with an ethernet shield and the EmonTx shield on top. This is running a slightly modified sketch which takes sensor readings as normal, and then publishes them to my MQTT broker (on a different machine) over ethernet.

Once you get this working then it is a very simple task to setup an MQTT item binding in openHAB to subscribe to those topics and voila, you have your sensor data in openHAB.

In my case I don't actually send anything from EmonCMS to openHAB - I send the data to MQTT directly from my sensors (in my case the EmonTX Arduino). I then have another python script which monitors the same MQTT topics and forwards the sensor readings to EmonCMS via HTTP requests (using mqttwarn).

This is not the simplest system to explain, but it works very well since the sensor data is only published once by my EmonTX, but is consumed by both EmonCMS and openHAB.

There is work being done at the moment to add MQTT support to EmonCMS, which I haven't tried myself. But the idea should be that you get your sensor data into EmonCMS (which I presume you have working?) and then EmonCMS is responsible for publishing it out onto an MQTT topic. Slightly different to my approach, but no different in terms of how openHAB will receive the data - i.e. on an MQTT topic.

Edited: typo -> I HAVEN'T tried the MQTT support in EmonCMS.

### Re: Openhab nRF24L01+ energy monitor

"how is possible that without having anything connected to the sensor to get values like 15-25w ?"

The analogue part of the ATMega 328P is picking up electrical noise from the digital part. It cannot tell the difference between that and the the signal you want from the CT.

Remember that the maximum you can measure is 100 A, which is equivalent to about 23 kW, therefore the 20 W you are seeing is only 0.1% of the maximum reading. You cannot expect accurate values below 200-300 W.

### Re: Openhab nRF24L01+ energy monitor

@Robert Wall

Oh, so you say whatever I'll do I can't loose this noise?

At 23kw total, 0,1 noise is not so much but on my test with this 46w bulb to have 24w noise its a huge difference more like 50% error!

I saw a lot of movies on different sites where people tested the sct sensor with different apps and on their tests if the devices is unplugged the sct display 0 wh consumption and when plugged in whatever power the devices had, but they never show how they did the sensor calibration, only links to open energy (here) or nothing on the description.

@sumnerboy you use the Emontx and so you have a different approach on you installation. I want to use only the Arduino board directly to my Rasberry through this wireless nRF24L01 devices using the RF24 available libraries on git.

### Re: Openhab nRF24L01+ energy monitor

There is probably very little that you can do about the noise. If you make sure that you have good grounding, good screening for your (sensitive) analogue front end, a good noise-free power supply, that is probably all that you can do. I understand that some Arduino boards have a filter in the 5 V power supply between the analogue and digital sections, but that most do not.

If your noise value is always the same number (or nearly), you could subtract that number in the sketch.

Alternatively, you can use a multi-turn primary winding with your CT - you loop the wire through many times, and that multiplies the current that you read but not the noise (then of course you divide the answer in the sketch to give the correct result).

### Re: Openhab nRF24L01+ energy monitor

I am testing this on two different boards, Arduino Uno and Arduino Mega, both original bought from the official supplier.

Tell me please how can I substract this difference in the current only example? It should be something like minus the difference that the CT is showing without being connected to any alive wire?

I tried also multi-turn but still this huge noise and to do this in a panel where all cables are FYY = 8 or 10 it's kinda of impossible.

### Re: Openhab nRF24L01+ energy monitor

How are you powering the Arduinos?  A ripply 5V supply is a common cause for ADC noice.  Check out this thread too:  http://openenergymonitor.org/emon/node/10111