From which side - central or peripheral?
If you're the central you are the one who initiates the connection, so you should be able to increment a counter when this happens.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
From which side - central or peripheral?
If you're the central you are the one who initiates the connection, so you should be able to increment a counter when this happens.
EDIT:
From peripheral side there are events for connect and disconnect:
https://www.espruino.com/Reference#l_NRF_connect
https://www.espruino.com/Reference#l_NRF_disconnect
This example will flash the green LED on connect and the red on disconnect:
It's easy to try with just the WebIDE as connecting central.