Hi I'm using nRF5 SDK for mesh. with DK PCA10040.
I want to read the temperature sensor reading on button press. Please give me guidelines on implementing this.
Thank you.
Hi I'm using nRF5 SDK for mesh. with DK PCA10040.
I want to read the temperature sensor reading on button press. Please give me guidelines on implementing this.
Thank you.
In the nRF5 SDK (non-mesh), the BSP provides events on button press - is that not available in the mesh version?
If it isn't, then look at how the non-mesh SDK does it ...
In the nRF5 SDK (non-mesh), the BSP provides events on button press - is that not available in the mesh version?
If it isn't, then look at how the non-mesh SDK does it ...
I tried the following
static void button_event_handler(uint32_t button_number)
{
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
switch (button_number)
{
/* Pressing SW1 on the Development Kit will result in LED state to toggle and trigger
the STATUS message to inform client about the state change. This is a demonstration of
state change publication due to local event. */
// Read Temperature Sensor
case 2:
{
_ __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Temperature \n" );
uint32_t temperature;
sd_temp_get(&temperature);
__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Temperature is = %d \n" , temperature/4);
break;
}
default:
break;
}
}
this gives the temperature of the board and prints on the RTT Viewer
How to properly post source code:
static void button_event_handler(uint32_t button_number) { __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number); switch (button_number) { /* Pressing SW1 on the Development Kit will result in LED state to toggle and trigger the STATUS message to inform client about the state change. This is a demonstration of state change publication due to local event. */ // Read Temperature Sensor case 2: { __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Temperature \n" ); uint32_t temperature; sd_temp_get(&temperature); __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Temperature is = %d \n" , temperature/4); break; } default: break; } }
And note the 'Language' setting - to get syntax highlighting:
It seems that you have figured this out. Do you want to read the temperature on the nrf52 or on your own temperature sensor that you hook up to the dev kit?