Community news, upcoming events and general discussions
Threads: 36 Posts: 88
Get technical support from the community
Threads: 1416 Posts: 7560
Threads: 18 Posts: 64
Tell us how to make XDK better!
Threads: 36 Posts: 119
Share and discuss community member projects
Threads: 78 Posts: 343
I want to use a TMP 36 temperature sensor, and read the values that that sensor is generating, I read the Extension Bus Guide and I can not understand. Does anyone have a code on how to read analog values with that sensor?
I had a short look to the datasheet of the TMP36 sensor. It seems you first need a little electronic to adapt the voltage level. The sensor needs a supply voltage between 2.7 and 5.5 V. So you can use the 3.3V power supply pin of the extension bus. Please notice the normal GPIO pins are only endure a maximum voltage of 2.5 V. So you first have to calculate a voltage divider to adapt your measuring voltage to a range bewteen 0 and 2.5 V.
After that you can use one of the two available ADC channel of the extension board. The ADC pins are located at PD5 and PD6. To use the ADC controller i recommend the em_adc.h interface. You can find the interface in the following path:
The next step depends on your requirements for the measuremt. If you want to sample data really quick and accurate, i recommend the usage of a timer and the PRS bus system.
So i you have any further questions don't hesitate to ask. If you go more in detail about your requirements and use case i am sure we will find the best solution for you.
The first thing I want to do is read the values of any analog sensor, whether the temperature, or a photoresistor, or any analog sensor that exists, wanted to start with the TMP36 to make tests, then the second thing I wanted to do is that those I can see them on the web.
there are two possible ways to get and process data from the ADC. The first way is with a ISR. This is a nice solution because every time you have new data available the ISR function is automatically executed. The second way is with the DMA bus. You can store the new ADC data directly into the RAM storage without any CPU workload. You can decide which solution you implement recording to your use case and the related sampling rates.
1. Solution ISR
To implement the first solution you can use three modules from the EMlib library. The ADC, PRS and TIMER modules. You can configure the ADC with the interface em_adc.h. After that you can "connect" the ADC and TIMER via the PRS bus. You can configure the TIMER to count up and get an overflow after a defined value of time. This overflow event will trigger the ADC via PRS bus to start a conversion. You have to implement the ISR in your main code. The TIMER and PRS function are described in the em_prs.h and em_timer.h interfaces. The ISR for the ADC looks like:
2. Solution DMA
The second solution is based on the first solution. But insteed of implementing the ISR in your main code you have a look in the em_dma.h interface. Then you can configure the DMA to read out the new data directly from the ADC and store them into RAM storage. Please be aware of the fact that you have to modify the SDK to use the DMA bus. You have to add the dmactrl.h interface to your emlib directory in the "inc" folder. You can find the missing file on the internet.
I hope this was helpfull.
Yes, exactly, read the value of the sensor through the internet, that I can monitor the sensor from my home or office, and the sensor and the XDK that are in the factory.
Will they have an example code? I am new in this and I could not understand almost anything.
Do you have a code where you can read the values of the analog sensors?
Do you have images showing how to connect the sensor to the XDK gateway?