Solar divert showing as export

am i assuming correctly by looking at the file src.ino the sampling time frame is determined by the sampling rate x number of samples taken. The sampling rate is the speed at which the program cycles.
As I haven’t found any reference to 200ms time frame and the number of samples taken is 1480.
There is a reference ‘178 samples takes about 20ms’ in startup.ino .
So changing the sampling window would be a case of changing the sample no. , compiling the and then upload to the pi before using the pi to upload the hex file to the emon.

I take it you’re looking at emonLib. That part of the library is only used when you don’t have the a.c. voltage reference to count mains cycles. You need to be looking at calcVI( ), and that counts half-cycles of the voltage input.

So in the emonPi sketch, you should be looking at the file src.ino and the line
const byte no_of_half_wavelengths= 20;
- that’s 20 half cycles, or 200 ms.

That’s correct. I think it’s spelled out here, but you only want the last 3 lines (stopping emonhub, transfer with avrdude and restart emonhub)
https://wiki.openenergymonitor.org/index.php/RFM69Pi_V3#Upgrading_RFM69Pi_Firmware_Direct_from_the_Pi
and even then, the file locations might have changed with the recent updates to emonCMS.

ok, thanks
so just need to change 20 to 100 and then it should take a 1 second sample, which then should average out what the ApolloGem is doing.
I know enough about SSH and the RaspberyPi and arduino to be dangerous.
so just need to compile the src.ino to a hex file, copy to pi and use the last 3 lines from RFM69Pi V3 - OpenEnergyMonitor Wiki.

If it all goes wrong then flash a fresh SD and start again.

That plus all the other files that are in the same directory with it - that’s the weird thing about the Arduino system, they didn’t know about Make / Batch / Command files to drive the compiler and linker, so it tries to compile and link everything in the directory.
The list of files is

├── interrupt.ino
├── lcd_serial.ino
├── rf.ino
├── src.ino
├── startup.ino
└── temperature.ino

after some effort sorting out the libraries in arduino IDE, I used the links in the code not the links in the Learn section on using Arduino IDE. Also needed to add "static void showString (PGM_P s); " in the global variables section due to using a newer version 1.8.7 of the Arduino IDE.

I changed the number of half cycles to 25 (250ms time frame) and not much change to before. changed this to 100 and got the following.

this looks a lot better.

Is there any downside to having a longer sampling window?

the spike is the kettle for another cup of tea

Quite understandable :grin:

The only thing really to consider is that emonLib samples the channels sequentially, so you’re sampling the grid for 1 s, then the PV for 1 s, then pausing for 10 s (I think - there are some unexplained hard-coded numbers that I need to think about).

I think it might be worth trying a little longer still - that fine ripple might still be a left-over from the burst-fire switching.