First, a disclaimer: I'm still learning as well ... I do NOT claim to be a guru.
Before going on, I will let you know that some of what you're asking is actually covered off in Chris Walker's book, "Getting Started with Netduino". He does discuss the differences between the digital pins and the analog pins and how to use them.
Digital vs Analog Pins
Basically, the digital pins are meant for doing discrete logic (i.e. on/off or "black & white") whereas the analog pins are meant for dealing with ranges of values. Each analog pin can discern between 4096 possible values. If you think of the digital pins as handling black & white situations (i.e. on/off or yes/no), the analog pins handle the grey area in between.
- You can connect on/off switches to the digital pins & turn things (e.g. LEDs) on/off with them.
- You can connect things like analog sensors & potentiometers to the analog pins.
Overloaded Usage of the Digital Pins
You will see in the referenced diagram that all of the digital pins can be used for MORE than just turning things ON/OFF (or reading when things have switched states). You will find that the certain subsets of the pins can be used in tandem to implement certain communication protocols. In particular, the board supports these communication protocols:
I have included in the above list links to the corresponding Wikipedia articles.
Your choice of which pin(s) you use will generally be governed by the requirements of whatever sort of device you wish to connect to the Netduino. For example, I have purchased a variety of temperature &/or humidity sensors from an outfit called Adafruit (they have good stuff). I've purchased other things from a company called SparkFun Electronics (good stuff also).
- My HTU21D-F temperature & humidity sensor communicates using I2C, so I have to use the 3V3, GND, SCL & SDA pins on Netduino to communicate with it
- My DS18B20 temperature sensor communicates using OneWire, so I have to use 3V3, GND and then ANY available Digital I/O pin
- I just got something called a BME280 (temperature, humidity & pressure) which can connect using either SPI or I2C, so this gives me options...
- There's a fellow on the Netduino Forums who's using a TMP36 (Analog Temperature Sensor) to read temperature & upload it to a database - he has to interface it using 3V3, GND & one of the analog pins.
You basically need to read the product descriptions when you're buying these things. Both of the companies mentioned above offer sample code (but it's written for the Arduino) and tutorials on making the connections. You will benefit from going and reading the datasheets as well... (I get my kicks from reading the Arduino code samples & translating them into equivalent code that runs under NETMF).
About the differences between the different communications protocols (I'm sure other people will have more to say about this or correct anything here that's not quite on the money):
- I2C is considered to be a low speed communications protocol - it's used when the amount of data to be transferred is generally small (I have found that sensors usually use I2C versus SPI). Usually you send a 1 or 2 byte command and get back a 2-4 byte response.
- SPI is a high speed communications protocol (I have found that things like high resolution LCD & OLED displays are frequently implemented using SPI).
- I2C & SPI are bus-oriented (i.e. you can connect multiple things to the bus / share communication lines). With I2C, devices are distinguished from one another by means of a hard-coded bus address. With SPI, an extra wire (one per device) is used to distinguish between devices.
- OneWire is also a bus-oriented communications protocol.
- I2C & SPI communicate using synchronous I/O (there is a separate clock signal)
- UART-based devices communicate using asynchronous I/O (there is NO separate clock signal)
- (I believe) that I2C & SPI peripheral devices need to be in fairly close proximity to the controller (i.e. the Netduino)
- UART & OneWire devices can actually be more distant from the controller (with UART you'd use a TTL to RS-232 converter for this purpose...)
I'll leave it here for now. My recommendation would be for you to buy a couple of temperature sensors and to read the various tutorials on how to use them / read the datasheets. As mentioned above, the code samples are almost invariably oriented around the Arduino. There's lots of benefit to be gained from "porting" the code over to NETMF (translating it).
If you want some particular recommendations, I'd suggest getting the following:
- DS18B20 (OneWire): $3.95 @ Adafruit
- TMP36 (Analog): $1.50 @ Adafruit
- MCP9808 (I2C): $4.95 @ Adafruit
That's 3 sensors for less than $11.00 US. (Not including the shipping costs).
I have working code for all of these; I can share it with you. There is working code for the DS18B20 posted in the forums also.