I'm not particularly good at programming and electronics and out lecturer has given us some vague brief.
We're using Leonardo boards and the temp sensor is an MCP9801
The bit I'm struggling most with is:
Interface the I2C Temperature sensor
What do I do? and what does he mean be interface?
This is a component leading up to the next few instructions if that helps. They are as follows:
Check the setup of the ADC channels, how can you make them the most sensitive for your
application
Compare the analogue and digital temperature sensor and discuss their advantages /
disadvantages. (What temperature resolution can you archive, how do you set up for the
widest range of temperature.)
Wire the data and clock signals from the arduino to the sensor. Also put power and ground to the sensor. Wire a 4K7 pull up resistor on each of these two signals.
Read the data sheet to see what address the sensor is at and read the I2C examples in the IDE to find out how to read data from this sensor.
All this means interfacing the sensor to the arduino.
I would suggest that the vagueness lies with you rather than the lecturer.
Integrated Development Environment - it is the arduino application running on your computer. It has example code in it under the less confusing menu title of Examples.
#include <Wire.h>
int I2C_address = 0b1001000;
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}
void loop()
{
Wire.requestFrom(I2C_address, 1); // request 1 byte from address.
while(Wire.available()) // slave may send less than requested
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(500);
}
I think this is getting there, I think I have to now specify which register I want to take data for, my temp sensor has 4 registers. At what point in this code do I say which Register I want to take data from?