I2C Driver Scheduling and publishing uORB messages

Hello everyone,

I was trying to write a driver for my ADS1015/1115 sensor. I was able to successfully set-up and talk to the sensor via I2C. However, I cant figure out what I am doing wrong when I try to schedule to sensor and publish the data via the uORB messaging system.

So basically the initialization of the sensor goes well, but it seems like the command:

ScheduleOnInterval((1_s / _sample_rate), 10000);

Does not really schedule the sensor. I have tested the reading of the sensor. So the functions: measure(), collect() do work and read the sensor data. Then I have included both functions in the Run(), so in principle that one should work fine too. So do not really know what I am doing wrong here. I have attached the hpp, cpp and main file in the attachment if someone wants to have a look through the whole code, much appreciated.

Another problem I am facing is that I cant get the data to be published via the uORB messaging system. I thought it was straightforward to do and done with the following command:

sensor_angleraw_s datapublish = {
.timestamp = hrt_absolute_time(),
.angle = angl
bool success;
success = _angle_pub.publish(datapublish);

No success, so anyone a thought what I might be doing wrong?

I was testing the driver using the Mavlink console and starting the driver using the following command: ads1015_angle start (specified in the cmakelist). It provides me feedback through the PX4ERR and devicelog functions. So I dont really run into an error, but the data is not published and the sensor is not scheduled, so there must be a mistake! However, cant really find it.

So anyone any idea what is going wrong here?

Thank you in advance,

(To bypass the file extension upload restrictions, I changed the file extension to pdf. Please change them back to .cpp/.hpp to analyze).
ADS1015hpp.pdf (5.0 KB) ADS1015cpp.pdf (5.7 KB) ADS1015_maincpp.pdf (4.5 KB) Preformatted text

1 Like

Hi, have you solved the problem? Iā€™m facing at the same situation with a custom UART driver!

1 Like

I did solve the problem at the end. It was a long time ago though. If I remember correctly the task was actually scheduled, but it went wrong in the publication of the uORB message.

If I look through my code now I publish it with the following line (where the sensor_sideslipraw_topic is advertised beforehand)
orb_publish(ORB_ID(sensor_sideslipraw), _sensor_sideslipraw_topic, &report);

This might be a quick fix, definitely not clean. Might have to clean it up a little. The only thing what I can think of right now, is that I should have passed a reference as a argument to the .publish function. The rest should in essence do the same as I do now,