I will recommend you to check the following code example, it is written in Python. I think you will find it very useful. The example is about the analogue read using MRAA. Please take a look at it: makers-examples/AnalogReadSerial.py at master · MakersTeam/makers-examples · GitHub
This example is like so many other examples and does not answer my question. On the Edison there are dedicated analog inputs A0, A1, A2 ... however, there are also some multiplexed on the GPIO 44, 45, 46, which when initialized/mapped can be used like A0, A1 (see the link I made to the MRAA library).
The problem that I am having and I have seen no examples of, is how to set-up these analogs so then I can use them in the normal way.
1 of 1 people found this helpful
I think there may be some confusion with what your reading in the docs.
first thing to note is that the Edison does not have a built in AtoD however on the Arduino break out board there is an SPI AtoD mapped to the normal Arduino pins A0 to A5 these pins can also be used as GPIO the same as they can on all Arduino boards.
so if you want these pins as ANin you use var a0 = new m.Aio(pin); where pin is 0 to 5
or you use these pins as IO which you do by var pin = m.Gpio(pin); where pin in this case is 14 to 19
so in the example you mentioned above to read Ain0 use var a0 = new m.Aio(0);
if you are using the mini breakout board there is no AtoD unless you ad one yourself.
Hope this helps
As Paul Bearne has explained, the way to define an IO as an analogue input or as a normal GPIO is the following:
- For analogue input: var a0 = new m.Aio(pin);
- For normal GPIO: var pin = m.Gpio(pin);
If you use the first one the pin will be configured as an analogue input, but if you use the second one the pin will be configured as a normal GPIO. For the pins A0 to A5, there is no need to use both definitions to use them as normal GPIOs. If you want to use the analogue feature then you have to use the definition for analogue input, and if you want to use the GPIO feature then you have to use the initialization for GPIO pin.
Many Thanks for your help and putting me on the correct path.
I have since ordered one of these :
I trust this is what I need to get me to be able to use A0, A1 ... via the var a0 = new m.Aio(pin); method?
This board is due to be delivered tomorrow:
I assume I can simply access these analog pins using the var a0 = new m.Aio(pin); method?
The module you are getting is sparkfuns own design of which i also have here it will not run directly with the a0 method but it will give you the ability to read an analog input i found this post useful when i brought that module https://communities.intel.com/message/290450#290450 by Joze Garza Rosado and it should help you get it up and running
i am trying to read A0 as analog pin from edison board using Intel XDK IoT IDE,but i am getting error ERROR: Error: Invalid AIO pin specified - do you have an ADC?
can you help me in this regard.Thanks in advance.