It is in the emonTx where you must change the sketch.
Download the source files from Github.
I’m giving the line numbers for the copy of the sketch I have here. Yours might be different if there has been a change that I don’t know about.
[Edit - line numbers had changed.]
First, remove everything concerning A5 / D19 & A6 / D20.
These are
Line 120: const byte DS18B20_PWR= 19;
Line 182: pinMode(DS18B20_PWR, OUTPUT);
Line 292: digitalWrite(DS18B20_PWR, HIGH); delay(100);
Line 304: digitalWrite(DS18B20_PWR, LOW);
Line 452: digitalWrite(DS18B20_PWR, HIGH);
Line 460: digitalWrite(DS18B20_PWR, LOW);
I don’t think A6 / D20 is used in the default sketch.
Note: You must connect your temperature sensor using the RJ45 socket, or move the power connection to the 3.3 V power on the screw connector. The screw connector labelled “ADC5 / Dig19 DS18B20 PWR” will become one of your inputs.
Now you need to add some code to read the new inputs and send the data. I you don’t want the current, simply leave that out:
In lines 145 - 146, add two new variables. I’ll call them Ipv & Vpv:
int power1, power2, power3, power4, Vrms, Ipv, Vpv, temp[MaxOnewire];
unsigned long pulseCount;
Before line 463 if (pulseCount)
add these new lines:
emontx.Vpv = analogRead(A5);
emontx.Ipv = analogRead(A6);
If you wish, in the next section you can add:
Serial.print(",Ipv:"); Serial.print(emontx.Ipv);
Serial.print(",Vpv:"); Serial.print(emontx.Vpv);
Compile and reload the sketch into your emonTx. This will give you the PV voltage and current not scaled - you will get a raw number 0 - 1023 representing the input voltage over the range 0 - 3.3 V. You can adjust the scale in emonHub to read Volts & Amps.
I cannot test this, because I do not have your PV.
Now change emonhub.conf to match. If your emonTx is Node 8, it will be this (change whichever node is your emonTx):
[[8]]
nodename = emonTx_3
firmware =V2_3_emonTxV3_4_DiscreteSampling
hardware = emonTx_(NodeID_DIP_Switch1:OFF)
[[[rx]]]
names = power1, power2, power3, power4, Vrms, Ipv, Vpv, temp1, temp2, temp3, temp4, temp5, temp6, pulse
datacodes = h,h,h,h,h,h,h,h,h,h,h,L
scales = 1,1,1,1,0.01,1,1,0.1,0.1, 0.1,0.1,0.1,0.1,1
units =W,W,W,W,V,A,V,C,C,C,C,C,C,p
It is the two numbers “1” that you added in ``scales = …" that you change to give the correct current & voltage. Example: if 1023 represents 46.7 V, you put the number 0.04565 (= 46.7 ÷ 1023)
Note: when you have loaded the new sketch and before you change emonhub.conf, it will not receive any data from your emonTx.
I think that will work, but I don’t have your set-up so I cannot prove it.
Remember, unless you know that your PV system is isolated from everything else, you must NEVER connect anything except the a.c. adapter and the 5 V USB adapter to the emonTx. The only exception is when the thing you connect is also completely isolated from everything else, so you can connect a laptop running on its internal battery. Also, be aware that any metal parts may be live.