This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thingy 52 Sensor configuration

I am using Thingy 52 and I need to use multiple sensors on the board. But the API reference is really poor and there is no examples on this. So I don't know how to configure the sensors including: Humidity, Gas sensor and motion sensor.

1. I have started the humidity sensor but in the sample callback function. I used drv_humidity_get() to get the humidity data. But I always get 0 as a result.

2. I dug into the codebase and found the many configuration data are retrieved from the flash. I have used eraseall in nRFgo Studio. Does this erase the flash as well?

  • Hi,

    If you take a look at the Thingy source code (latest sdk v2.1.0), it seems that the thingy_init() function inside int main() is very important. Inside that function, the TWI manager gets initialized (which seems like the manager that enables communication between the sensors & the nrf52 if I am not mistaken). The section under initialize environment module also seems very important for your use case. Inside m_environmet_init(), the humidity_sensor_init() function is important for initializing the humidity sensor. Inside that function, the drv_humidity_init() function is called. 

    Assuming you only want to get the humidity sensor working first, my guess is you will need to call the drv_humidity_enable() function first & then start sampling, like in this function in m_environment.c

    /**@brief Function for starting humidity sampling.
     */
    static uint32_t humidity_start(void)
    {
        uint32_t err_code;
    
        m_get_humidity = true;
        m_temp_humid_for_ble_transfer = true;
    
        err_code = drv_humidity_enable();
        RETURN_IF_ERROR(err_code);
    
        err_code = drv_humidity_sample();
        RETURN_IF_ERROR(err_code);
    
        return app_timer_start(humidity_timer_id,
                               APP_TIMER_TICKS(m_p_config->humidity_interval_ms),
                               NULL);
    }

    Also take a look at static void drv_humidity_evt_handler(drv_humidity_evt_t event) in the m_environment.c file.

    Hope that helps to get started a bit.

    2) Yes, if you press eraseall in nrfgostudio, this does erase the flash as well.

Related