I have a working code now for C++ and the sensor is read well with that. So it is apparently because I am reading this sensor wrong with the Adafruit code. It works when I use smbus. I will now try to integrate it in PD. I see there are some examples, but I am not sure how to integrate everything when this is my render.cpp. I don't really see how I can easily replace the custom-render examples in the PD examples with what I use now. This is the render.cpp:
#include <Bela.h>
#include "MPL3115A2.h"
MPL3115A2 sensor;
bool setup(BelaContext*, void*)
{
return sensor.begin();
}
void render(BelaContext*, void*)
{
float pressure = sensor.getPressurePa();
float temp = sensor.getTemperatureC();
float altitude = sensor.getAltitudeM();
}
void cleanup(BelaContext*, void*)
{
sensor.stop();
}