I am trying to read various measurements with a raspberry pi 4. I decided to use an i2c bus to keep the wiring clean and easy. For a soil moisture measurement I decided to go with the SEN-17731. Somehow I cannot find any sample code nor registers I need to address with i2c.
On the website mentioned above only the following is written:
Our Qwiic Soil Moisture Sensor utilizes the I2C protocol with the existing signals and the ATtiny85 MCU as the I2C gateway, which does all the nitty gritty stuff for you. The default I2C address is 0x28. The Qwiic connector should be self-evident, and this board also has pins broken out for SPI programming.
Apparently this code is the firmware on the ATtiny85, since they listed the git repo under "Documents".
It which defines:
#define COMMAND_GET_VALUE 0x05
and later uses this within:
if (command == COMMAND_GET_VALUE) {
ADC_VALUE=analogRead(ADC_PIN);
ADC_VALUE_L=ADC_VALUE;
ADC_VALUE_H=ADC_VALUE>>8;
TinyWire.send(ADC_VALUE_L);
TinyWire.send(ADC_VALUE_H);
command = COMMAND_HAS_BEEN_CHECKED;
}
Tinywire seems to be an Arduino library (equivalent to SMBus for python?) but how can I address it from outside the Arduino Universe? Am I on the right path here?
EDIT:
Actually it's the same kind of problem for the GY-521 sensor, the only difference is that I found a source with sample code on how to use this sensor. Another difference is that the GY-521 seems to have a quite specific MCU which has a datasheet which describes the different registers to be addressed. Still, I don't find these information sufficient to write a complete python script... How is this supposed to work? Did the manufacturer only consider this to be used within the Arduino Universe and whoever wrote the python code example just reversed engineered the library?
Python for SparkFun's Qwiic Connect System
, which promises to be able to allow to discover devices and construct their driver objects. Python allows good introspection, so even if you don't use it for the final system, it could be a good way of reverse engineering what you have. \$\endgroup\$