Are there any resources out there or books that explain how to write code to connect to an unknown device (for example an i2c device that does not have a library) ? I know you need the data sheet for the device but I don't know how to set up the timings to actually use the device.
The data sheet should tell you everything you need to know. I2C is not generally very sensitive to timing. The chip will have a maximum data rate specified in the data sheet but any rate slower than that should work.
Have you got an example of a device for which you have been unable to find a library?
if the device is unknown, how would you know what datasheet to get?
there are ways to scan for devices on an I2C bus using a I2C scanner. i believe the bus timing may not be critical to accessing the device and i wonder if there are common registers to identify a device
I guess this will not work at all.
If a "unknown" device should be able to be identified in any way some kind of a known protocol to exchange information would have to exist. Though then the device is known somehow because it belongs to that devices that is able to exchange information using this protocol.
Your question was very very generalising. Rule of thumb: the more generalised a question is the more likely it is that you only get the answer "Yes" or "no" but no useful information.
Is I2C just one example or do you ask especially for I2C-devices?
starting from a I2C-Scanner that only can determine the I2C-adress you could go on using I2C-commands trying to get a reaction from the device.
Here it would be helpful to use a logic analyser in combination with a software called pulseView.
But if you have no information about the device how should you ever be able to analyse the response from the device??
You will finish any project faster by building everything new from scratch with well known components than doing millions of tries to make a device react at all and then next hurdle to analyse what the response does mean
You should describe very detailed if you have a very particular device to deal with
maybe then there is a chance to find the book that describe how to interact with this device
as paul already mentioned these books are called "datasheets"
There is a difference between a completely unknown device and one without a library. If it is completely unknown you are probably out of luck. How would you even know how to connect it?
If it is just missing a library and you have a data sheet it is just a matter of implementing the protocol in the data sheet. Just implementing the protocol can be easy to almost impossible depending on your skill and how weird the device is.
The only way you would be able to connect to a device that is currently unknown is if you had a list of all the possible devices it could be and the possible I2C addresses each type might have. Then, once you find a device with that address, you use the appropriate protocol to communicate with it. That is how firmware like Tasmota have the capability of connecting to so many I2C devices at the same time built in.
But if you don't know anything about the device, I2C doesn't support any type of "handshake" to communicate with the microcontroller about what it is or what it can do. It is assumed that you know what I2C devices you might plug into.
But as far as interfacing to a device without a library...odds are, if you are asking that question, you don't have the requisite skills necessary to interface to a device without the help of a library. Take it from someone who's tried. If a library doesn't do exactly what you want you can always tinker with it. But writing one from scratch, even for a relatively simple device, can be quite daunting.
Yes. If you started reading the datasheet and you have questions you can ask them too.
The main thing is whenever the other users can see you did a step or attempt on your own and know have questions you can ask all these questions about the datasheet if you provide a link to the datasheet or if you attach it to a posting
Speaking off-the-top, I would say "no", but...
Common devices have reasonably "known" device addresses. One Arduino OLED library automatically configures for 2 distinct addresses and essentially provides a "wrapper" API.
Finding I2C addresses is straightforward. One could assume that the unknown device was from a "standard grouping" and thus know how to communicate with the unknown subset of devices.