During long times of the cruise flight, is the internal light normally switched on or off inside the cockpit?
Knowing it is generally dark in the night would make a smartphone-based night time logger easy to write.
Aviation Stack Exchange is a question and answer site for aircraft pilots, mechanics, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityDuring long times of the cruise flight, is the internal light normally switched on or off inside the cockpit?
Knowing it is generally dark in the night would make a smartphone-based night time logger easy to write.
White lights are usually off in the cockpit in night flights to protect pilots' night vision. Red lights are sometimes used as these do not impact night vision.
One of the challenges you'll run into is knowing when it's night, as the start of night varies by latitude and the exact time. Phones generally set their time from the mobile network, which may be absent on long flights, especially those over water. A pilot flying a jet over the pacific may may have a phone that is hours off the local time.
Putting my (albeit old and tattered) mobile developer hat on I would suggest you look for ways the phone can tell you whether it thinks it is night or day and use that, plus a manual selection for day/night mode. Look at the Android UIModeManager as a way this could be done native.
If you are asking about logging night VFR -time, you are not concerned with lighting conditions. Night time is logged according to regulation based definition of night (at least EASA), tables for night time are usually available from local aviation administration websites.
Your logger simply needs to know your position, date and time, and refer to the official table or definition of night if table is not available. EASA defines night as
" ‘Night’ means the period between the end of evening civil twilight and the beginning of morning civil twilight or such other period between sunset and sunrise as may be prescribed by the appropriate authority, as defined by the Member State."
Not quite as informative as one might like, but this is how thing work in avaition...
To strictly answer the title question, at least in GA operations, we typically fly with the cockpit lights off to avoid ruining our night vision. We do sometimes use red lights to see stuff in the cockpit, though.
However...
It's unlikely that a photosensor will be very useful for determining which hours count as day vs. night. Lots of factors will affect the relationship between time of day and received light on a photosensor in the cabin. These include, but aren't limited to: position, altitude, heading, orientation of the phone, latitude, time of year, weather, etc. This is compounded even more by the fact that what counts as "night" varies, not only by country, but even within the same country depending on the purpose in question!
For example, according to this AOPA (Aircraft Owners and Pilots Association) article, the US FAA definition of 'night' for purposes of logged flight time for private or commercial certification is the one in 14 CFR 1.1:
Night means the time between the end of evening civil twilight and the beginning of morning civil twilight, as published in the Air Almanac, converted to local time.
It's highly unlikely that you'll be able to figure that out with a photosensor on a phone in the cabin. You'll instead need the aircraft's location and time (and the formulas for figuring out when civil twilight starts and ends.)
However, for purposes of being 'night current' in order to be allowed to carry passengers at night, the definition of night is defined differently in 14 CFR 61.57(b):
the period beginning 1 hour after sunset and ending 1 hour before sunrise
Indeed, it turns out that the FAA uses several different definitions for different purposes, as described in detail in answers to the question How does the FAA define day and night? And that's just the U.S.
So, what you'll really need to solve your problem is:
Thankfully, the first two should be easy with a modern smartphone. At least for the U.S. definitions, local time should be irrelevant. Your phone's system time (in UTC) and position should suffice, so crossing time zone boundaries shouldn't matter.