External Sensor with DataLogger
Answer
8/8/18 1:06 PM

I'd like to save the data from an external sensor in a additional column in the .csv file. Does anyone tried that before, or can give me a hint how to implement the data loggin of the external sensor?

Thanks!

0 (0 Votes)
RE: External Sensor with DataLogger
Answer
8/8/18 5:32 PM as a reply to Alexander Ramsel.
Hello Alexander,

First of all, I would like to welcome you to the XDK community.

I will gladly give you hints regarding adding an external sensor into an additional column in the .csv file of the Data Logger demo.

Regarding that, were you already able to attach your external sensor to the XDK and did you already received data from it in your XDK application. If you were able to implement that, you would need to add a header and implementation in the same fashion as for the other sensors to the Data Logger demo.

Otherwise, I would ask you to go more into detail about which sensor you want to attach to the XDK by linking a data sheet, for example.

It would be very helpful if you could answer these questions first. Afterwards, I will gladly assist you in the further steps to add the external sensor into the Data Logger demo.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: External Sensor with DataLogger
Answer
8/9/18 7:28 AM as a reply to Franjo Stjepandic.

Hi Franjo,

thanks for your reply. Yes, i used the GPIO and ADC example from the extension bus user guide to read Pin PD5 and i am able to read values between 0 and about 4000.

Here is the code:

 

void appInitSystem(void * CmdProcessorHandle, uint32_t param2)

{

if (CmdProcessorHandle == NULL)

{

printf("Command processor handle is null \n\r");

assert(false);

}

BCDS_UNUSED(param2);

 

 

GPIO_PinModeSet(gpioPortD, 5, gpioModeInputPull, 0);

GPIO_PinOutClear(gpioPortD, 5);

ADC_InitSingle_TypeDef channelInit = ADC_INITSINGLE_DEFAULT;

channelInit.reference = adcRef2V5;

channelInit.resolution = adcRes12Bit;

channelInit.input = adcSingleInpCh5;

ADC_InitSingle(ADC0, &channelInit);

 

while(T==100)

{

uint32_t AdcSample = 0;

while ((ADC0->STATUS & (ADC_STATUS_SINGLEACT)) && (BSP_UNLOCKED == ADCLock));// @suppress("Field cannot be resolved")

__disable_irq();

ADCLock = BSP_LOCKED;

__enable_irq();

ADC_Start(ADC0, adcStartSingle);

// Wait while conversion is active

while (ADC0->STATUS & (ADC_STATUS_SINGLEACT));// @suppress("Field cannot be resolved")

AdcSample = 0xFFF & ADC_DataSingleGet(ADC0);

__disable_irq();

ADCLock = BSP_UNLOCKED;

__enable_irq();

printf("%d \n", AdcSample);

vTaskDelay(1000);

}

 

}

 

Next step is to use the datalogger to save the data from the external pin into the .csv file. The sensor will be a pressure sensor but it is not clear wich one i will buy.  

0 (0 Votes)
RE: External Sensor with DataLogger
Answer
8/9/18 5:25 PM as a reply to Alexander Ramsel.
Hello Alexander,

the code looks great and it is nice to view your success, connecting an additional sensor to the XDK.

In regards to add external sensors, I highly recommend you to take a look at the post from the 18 December in this thread . It covers for example the explanation about the way to add the acoustic sensor to the Data Logger demo. Since the sample principles also apply to an external sensor, you can simply use them to include your external sensor into the Data Logger demo.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)