I am trying to figure out if there is a way I can monitor a 0-10v signal using an emonTx V3.4.
After some searching around, I found that the analog inputs of Arduinos, and presumably the Atmel ATmega328 used in the emonTx V3.4, can only measure up to 5 volts, meaning I would have to use a voltage divider to bring the 0-10 volt down to 0-5 volt.
I thought about somehow re-purposing the battery voltage monitoring input (https://wiki.openenergymonitor.org/images/EmonTx_V3.4_portmap.png) because it is already set up in the sketch, but that would mean disconnecting it from the actual power rail.
Another thought was to use pin 8 of the RJ45 socket. As far as I can tell, it is not used for anything else - but I don't know how I would modify the sketch to measure said pin. Can I just change
const byte battery_voltage_pin= 7;
to
const byte battery_voltage_pin= 6;
and rename the battery voltage input (on emocms.org) to 0-10 volt input?
I could simply try it out, but I'd rather ask first before I start desoldering components and potentially break something.
edit
I've managed to get it working.
I've attached the emonTx V3.4 sketch. It worked fine when using the serial monitor using the USB to UART adapter, but I had trouble getting the readings through to emoncms.org and configuring the node decoder in the emonBase (using the web interface).
Eventually I took the easy route and disabled the emontx.Vrms= battery_voltage and set Vrms as the 0-10 volt signal instead (0 to 3 volt with 10K ohm and 4.4K ohm voltage divider, but multiplied back up to 0 to 10 volt in the sketch) and renamed the input and feed on emoncms.org.
Re: Monitoring a 0-10v signal using emonTx V3.4 [SOLVED]
A major mistake there - the emonTx runs off 3.3 V so the maximum input is that. Feed it 5 V and you risk damaging the input. You should always look at the circuit diagrams etc, which can be found under "Resources", rather than reading inapplicable data from elsewhere.
I think you can indeed use ADC6 (which is wired to Pin 8 on the RJ45, or ADC5 on the terminal block if you're not using that for power to the temperature sensor. It's not hard to slot in an "Vin = analogRead(whatever_pin_you_choose);" into the loop() section of the sketch, and probably a lot easier than converting something else, like battery voltage. If you do use ADC 5, you need to remove all references to D19 - the switched power to the DS18B20.
Re: Monitoring a 0-10v signal using emonTx V3.4 [SOLVED]
Looking at https://raw.githubusercontent.com/openenergymonitor/Hardware/master/emonTxV3/emonTx_V3.4/schematic.png again, I see I read it wrong yesterday. The +5 volt from the USB input (or the 3 × 1.5 volt from the batteries) is fed to a voltage divider, and then to the ADC.
To get (max) 10 volt down to 3 volt I'll have to use two different value resistor in my voltage divider. A quick look around suggest 470K and 200K would do the job, but I'll try things out and check.
I'm going to try and use the RJ45 just so I don't have to take to the PCB out the housing which is a bit annoying since I've put it in another enclosure aswell.
Re: Monitoring a 0-10v signal using emonTx V3.4 [SOLVED]
I don't think that 470K/470K divider you posted is a good example to follow. You really want the source impedance of the signal you're measuring to be less than 10K. Attached is a picture of an ADC input pin being driven by a 470K/470K divider between Vcc (5V in this case) and GND. I've removed the DC offset so we can zoom in on V.
You can see at the instant analogRead() is called, the voltage at the pin sags by a good 384mV. It then slowly climbs back up to where it's supposed to be, and takes about 80 usecs to get there. That's how long it's taking to charge the ADC's sample-and-hold capacitor. From memory the ADC starts its sampling 1.5 ADC clocks (or 12 usecs) in. So effectively you need to drive that ADC input pin hard enough to ensure it's stable within 12 usecs. In this picture, at 12 usecs it's still 206mV below where it should be, and climbing.
The result of all of this is that the value returned by the first call to analogRead() will be quite different from a second call immediately after it. The effect is also impacted by what analog signal you read before reading this one. In the picture below I read a pin that was at 0V. But if you're reading an AC signal just before you read your battery monitor voltage divider, there'll be significant crosstalk between the two.
Re: Monitoring a 0-10v signal using emonTx V3.4 [SOLVED]
Had some trouble getting the readings to emoncms.org, but managed to find a work-around. Not the best solution, but it works for me.