How to tell when the sun is out

In my line of work (energy auditing), I come across the need to know when the sun is out and have that logged to a feed for overlay on graphs. A good example is a client who suspects their solar hot water pump is running even when the water running through it is colder than the water in the storage tank. In this case, the DC pump is directly controlled by a solar PV panel on the roof, so when the sun is out, the pump is running, even if it’s freezing (a glycol closed system).

For my analysis, ideally I would have some way of knowing when and how long the sun was out. I’ve considered doing this with a typical AC photosensor and a light bulb or other small load and then monitoring that current with a CT to the EmonPi. But would it be possible to simply get a low voltage DC photosensor that could simply plug into one of the USB ports on the EmonPi (with a really long cable) and read the data (on/off) with calibration in the emonhub file? Even better still would be wireless…

Update: On further thought, I’ve considered using a simple solar collector and monitor the voltage. With this method, I could take advantage of varying levels of voltage, equating higher voltage with higher direct sunlight. So how would I make this happen? Wire directly into a serial port on my TX3? I also already have a emonTx RJ45 to Terminal Block Breakout, so can I wire the DC from the solar panel into that? I’ve been using Open Energy Monitor products since they first came out, but I’m still a newbie when it comes to the programming aspect of this tech, so detailed help is greatly appreciated.

Any thoughts and help would be greatly appreciated!

Your problem with using OEM kit is, between the demise of the emonTx V2 and the introduction of the V4, there’s been no easy way to get a direct connection to an analogue input anywhere. And the RPi has no analogue input at all.
This changed when the emonTx V4 appeared, it has on the front panel and duplicated on the RJ45 connector a connection via a solder link internally direct to a 0 - 1 V analogue input, so scaling the voltage from whatever down to 0 - 1 V will give an input which can be read in software and sent to emonCMS along with the other data. The details I don’t know - I’ve not had time to look into this aspect yet (though @TrystanLea almost certainly has done), but it’s clearly something that needs doing and incorporating into the system.

The ‘whatever’ could be a PV source, or a light-dependent resistor or photodiode and fixed resistor fed from 3.3 V.

You’re not interested in a speedy response (presumably) so some smoothing at the receiving end to remove any noise pickup should allow a very long lead to be used.

1 Like

Here’s the part of the documentation that details how to use the analog input with the emonTx4:

For the emonTx3 there is also an analog input available as well. The easiest way to make use of it would be to use the discreet sampling firmware and then use the standard arduino analogRead command.

The emonTx3 discreet sampling firmware can be found here:

I would probably add it in here:

creating a new entry in the struct used to transmit data, something like:

emontx.analog = analogRead(6);

here’s the pinout of the RJ45:


A weather station? There are several out that include a light sensor and there are various ways of accessing that data.

That’s a great idea for my home, but I was looking for a more portable solution, based on the fact that I’m moving my equipment to a new location every couple of weeks.
But you’ve inspired me to get one for my own house!

Thank you Trystan! It will take me quite a while to assimilate what you’ve suggested though.
Do you have a specific photo resistor you might recommend for this?

How about a BH1750 based sensor

connected to an ESP8266 (like a WEMOS D1 Mini) module and use ESPHome for the firmware

Send the data by MQTT to emoncms.

You could power the ESP off a rechargeable battery for a really portable solution (needs Wi-Fi of course).

1 Like

That sounds perfect! Thank you!
Connecting via RF or WiFi is definitely not my area of expertise though. Can you take a few more moments to give me a rough idea of how to do that?

This is not a finished product solution, though there are such things out there. You’d need to investigate ESPHome, it isn’t that tricky, but there would need to be some Wi-Fi where you put the sensor for it to connect.

I think the solution you’re recommending here is above my pay grade :stuck_out_tongue:
I’m sure realizing that I should have paid more attention in my electronics class in high school or should have taken some classes since then!

Hey Trystan, just to clarify…
I have a newer TX4. For this one, I would NOT need the emonTx3 discreet sampling firmware, correct? I simply need to wire a photosensor/resistor like the one @borpin recommended ( ) to accommodate the RJ-45 pinout, and then modify the struct as you recommended, right?

Also, what does your gut tell you as to maximum length of Cat 5/6 wire I could run to the sensor to get data without loss?