Modern Nikon lenses have chips in them that contain some basic information:
- Lens ID (eventually stored by camera in EXIF Maker’s Tag) (see this site for IDs)
- Number of stops to minimum aperture
- Focal length at wide end
- Focal length at telephoto end
- Maximum aperture at wide end
- Maximum aperture at telephoto end
- Chip ID
- Lens type (pre D, AF-D, AF-G, AF-D VR, AF-G VR, AF-E, AF-E VR)
Older Nikkor lenses and some third party lenses lack this chip, though there is a source for buying something called the Dandelion chip that provides this information and which can be programmed and then installed in most such lenses.
As you might have noticed on the lens contact page, the protocol is basically a serial one. Nikon’s patents have described some of the data codes that are used between camera body and lens, but not all of them, and these codes have changed over time, so I’m reluctant to document those that I know. Moreover, it appears that the lens and camera body communicate in a continuous loop (which sort of explains dead battery syndrome, which was probably caused by one of the lines being pulled down unexpectedly due to power demands elsewhere). I will say that the body speaks first and the lens responds, and that the RW pin is used to initiate and control communication (e.g. one end pulls the RW pin to 0, and if the other doesn’t pull it back to 1 then a fixed time communication sequence follows).