RUI I2c mosture connection

Hello,

I currently making some test with RAK5205 with the mosture detector in I2C

I have write a mokeup with RUI to read the data based on your example.

When I try to just do a write to reset the device, I receive a error code 6, also If I try to read it.

I’m a newbie with i2c, so any tips or help is welcome

Hi @litbos , Welcome to RAK forum :slight_smile:

I had a quick check on your code and I saw that the length is zero. That should be some value depending on the size of data you transmit

I know you are working with RAK5205 but I suggest to make it work first with RAK811. A simple I2C demo is here - Products_practice_based_on_RUI_v2.0/app_RAK811.c at master · RAKWireless/Products_practice_based_on_RUI_v2.0 · GitHub

This way, it won’t have any conflict on the other sensors. If you make it work now on RAK811 alone, then you can integrate it into your RAK5205 code.

Study the RAK811 I2C demo code and see how you can implement the Arduino code from the github repo you shared - GitHub - Miceuz/i2c-moisture-sensor: I2C based soil moisture sensor to the RUI.

Hello.

Thanks for your response. I was finally able to read. But write is still difficul. I still receive code 6.
I set 0 as length because the sensor juste require a write on the register that’s all. It for a reset

Do you have an exemple of a write without value ?

Thanks

Ps: I have update my fork with running code except write

Hi @litbos ,

I see your code. Sadly, we do not have RUI API that can cover your requirement of writing only on the address of the device but not on a specific register address. If you need the reset command and very critical on your application, doing via RUI might not be the best solution.

It’s a bit weird doing a write to a register without having any data, so I can’t say I’m surprised there isn’t an RUI command that supports that instance - I’ve run up against similar in the past.

I see that the sensor is actually based on an ATtiny414 so I guess the I2C command sequence is individual to the creator.

With RUI we can actually call the HAL commands, so there may well be a HAL_I2C command in the STM32 API that can do the job.

1 Like

Hello,

Thanks for your response, I write on the device but also on the register (0x00), but my point is to write nothing.
It’s quite common as far as I see on sparkfun stuff to write 0 bytes on a register, to activate it or to tell it to go to slepp, and it works nicely.

I’m currently evaluation RAK for a customer project with i2c sensor, I have just pick one sensor that work well with Arduino stuff.

Hi @litbos ,

I believe you that it is not uncommon (but at the same time not too common).

Can you share with me a specific device datasheet so I can have a look? I can’t find the datasheet of your moisture sensor device.

I am not sure if it is the same with your application. To reset your moisture sensor you have, you are not writing nothing on a specific register but you are writing the register address on the I2C device address then end the I2C bus. I am not sure if we are on the same page but that features is not something we support at the moment and have no plans yet.

For which I can’t find anything in the I2C spec about doing that (I checked) which means that it is unlikely any of the major firmware API’s like STM32 are going to have support for “write to register but don’t actually send anything to write”.

I use I2C as a comms mechanism between MCU’s and Pi’s and it has never occurred to me to try that sort of sequence.

Maybe @litbos could evaluate a mainstream sensor with more mainstream I2C support? It would be a shame to rule the RAK range out, as I can’t image you’ll find another vendor range that uses well supported API’s that will enable this.

PS, Arduino based I2C doesn’t count, I can hack that as much as the next hacker to warp time & space.

Hello

Thanks for your response. And sorry for my newbies question. I m more used to python and business apps.
If if not common and not supported. We can close this topic.
I will clean my code to remove those write functions.

Thanks again for your help on this topic

@carlrowan

I have seen that on the rui.h

If I initialize my i2c with this magic reg, it seems to be able to write on the device, but perhaps it’s not yet supported by RAH811

Thanks for your help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.