Skip to the content.

Date: 2024-06-26

Everything on the JSY

I am developing quite a few projects and librairies in the Arduino / ESP32 / Home automation landscape (https://oss.carbou.me), including YaSolR routing software as well.

Last year I created a specialized library for the JSY, which I wanted to talk to you about today in order to present its operation and use in the context of a solar router.

How the JSY is used in a solar router

A solar router needs to measure the current, to react to these measurements and propose a new duty cycle to apply to the dimmer, for a certain time, until it obtains a new measurement. So it depends on the speed at which these measurements are taken, and their precision, but also of course on the routing algorithm used and the precision of the steps (0-100, 8-bit, 12-bit, etc.).

It’s rare to find a solar router that correctly uses JSY at its full capacity, partly due to the severe lack of an effective library for JSY, and that’s why I created it.

Asynchronous operation

As JSY slows down routing, it is important to be able to retrieve its values ​​as quickly as possible. Most libraries use delays or read() in loops, which is non-blocking, good, but does not guarantee reading the data as soon as it is ready because these read tests depend on the speed of execution of the loop.

Not many people know this, but Arduino offers a serial read method (Serial.readBytes()), which is implemented differently from the non-blocking read(): readBytes() is blocking and directly uses the UART interrupts backwards to unlock as soon as the data is ready. This is the most effective method to be notified immediately of the availability of measurements. It is then enough to set up a reading loop in an asynchronous task on core 0 of the ESP32, to be notified as soon as the data is ready.

JSY reading speeds

The JSY speed can be changed from its default (4800 bps) to 9600, 19200 and 38400 bps.

So increasing the speed of your JSY from 4800 to 38400 potentially allows you to react 4x faster to these readings… But are these readings meaningful? Let’s see…

Internal workings of JSY

The JSY works with an Renergy RN8209G chip, which continuously measures by taking a rolling average and makes the results available on the UART. For example. if you read the JSY repeatedly:

So it is not possible to have a router that will make a correction to the routing faster than this minimum delay for the JSY to detect a change in the measurements. So the routing algorithm should apply for at least 300 ms.

Load Detection Time

The JSY has a load detection time. For example, when turning on a load of 0-100%, it takes a certain amount of time to start making its data available.

This is the minimum time that the JSY takes to make a measurement available after a load change.

Ramp-up Time

When a load is on from 0 to 100%, goes from 0 to 3000W for example, the JSY takes time to see the nominal power because it uses moving average.

This is pretty consistent, and it’s the JSY window duration, which is about 1 second.

Using JSY in remote mode

The library includes a Sender application and another Listener. The sender application is a standalone application to flash on an ESP32 connected to a JSY. It uses ESP-DASH, ElegantOTA, MycilaESPConnect, etc. and allows you to see all the JSY stats, reset the energy, and, above all, sends the measurements via UDP at a speed of 20 messages per second, which is as fast as than reading the data locally at 38400 bps on an JSY connected to the ESP32. The Listener application shows how to receive them at a processing speed of 20 messages per second.

Conclusion

MycilaJSY Library

The library is here, with performance tests based on speeds: https://github.com/mathieucarbou/MycilaJSY

It supports: