How to use SAUL?


I just want to use the DHT11 sensor. I know that RIOT has an abstraction layer for sensors, which is really nice. My problem is just: How to use it? I have a server on my device which accepts UDP packets. The server should read the sensor data on a regular base, caches them and sends them back when asked. So, simple as that. Probably I have add the modules for my driver and saul, right? So my Makefile should look like this



The dht driver already has confgurations, which I need to override, since the pins are not correct. Should I just do the following in my application?


#define DHT_PARAM_PIN (GPIO_PIN(0, 12))

or should I define the DHT_PARAMS? When the setup is done, I probably just need to use saul itself with:

const char temp_sensor_name[] = "dht"; phydat_t temp_data; saul_reg_t * temp_sensor_reg = saul_reg_find_name(temp_sensor_name); saul_reg_read(temp_sensor_reg, &temp_data);

right? thanks for the help :slight_smile:

Hi Philipp,

I created a similar simple data collection app [1]. It uses SAUL with an MCP9808 temp sensor (JC 42.4 compliant), and of course CoAP. :wink: Start with the README. Then look for ‘saul’ in Makefile and in main.c main() and _run_sensor_loop().



Thanks, works fine. I changed the PIN config in the driver. I am not really happy with it. So, where to place the pin config instead? Should I place it in my boards configuration?

Excellent! I defer to others on config location, as I have no expertise at that level.

Dear All, i tried to get temperature and humid from DHT11. I tried the information to have a makefile and to use saul for dht. However using physical phy variable i could only gather temperature. Dht also measures humidity. Do you know how to get more than one measurement if the sensor has multi purpose capabilities?

My code as follows;

static saul_reg_t* saul_dht; saul_dht = saul_reg_find_name(“dht”);

int res = saul_reg_read(saul_dht, &phy); if (res) printf(“temperature: %d %d %d %d %d C\n”, phy.val[0],phy.val[1],phy.val[2],phy.unit,phy.scale); else printf(“Sensor read failure: %d\n”, res);

I think that there must be humidity value in phyval 1 or phyval 2 ?

21 Mar 2019 Per 11:35 tarihinde Ken Bannister <> şunu yazdı:

Hi Burak,