I made a PCB of MAX30205 by myself.I put a LD1117AL#33 to let 5V down to 3.3V.
This is my circuit.
I also use the I2C scanner to scanning of I2C bus.It is at addr 55.
But now I have a problem.
When I use PCB to connect the pin of 5V in Arduino YUN,YUN will have no power immediately.
These are the code what I used.
The first one is max30205demo.ino.
#include <Wire.h>
#include "ClosedCube_MAX30205.h"
ClosedCube_MAX30205 max30205;
void setup()
{
Serial.begin(9600);
Serial.println("ClosedCube MAX30205 Arduino Demo");
max30205.begin(0x55);
}
void loop()
{
Serial.print("T=");
Serial.print(max30205.readTemperature());
Serial.println("C");
delay(300);
}
Second is ClosedCube_MAX30205.h.
#ifndef _CLOSEDCUBE_MAX30205_h
#define _CLOSEDCUBE_MAX30205_h
#include <Arduino.h>
typedef enum {
TEMPERATURE = 0x00,
CONFIGURATION = 0x01,
T_HYST = 0x02,
T_OS = 0x03,
} MAX30205_Registers;
class ClosedCube_MAX30205 {
public:
ClosedCube_MAX30205();
void begin(uint8_t address);
float readTemperature();
float readT(); // short-cut for readTemperature
private:
uint8_t _address;
uint16_t readData(uint8_t pointer);
};
#endif
The last one is ClosedCube_MAX30205.cpp.
#include <Wire.h>
#include "ClosedCube_MAX30205.h"
ClosedCube_MAX30205::ClosedCube_MAX30205()
{
}
void ClosedCube_MAX30205::begin(uint8_t address) {
_address = address;
Wire.begin();
/*
Wire.beginTransmission(_address);
Wire.write(CONFIGURATION);
Wire.write(0x0);
Wire.endTransmission();
*/
}
float ClosedCube_MAX30205::readT() {
return readTemperature();
}
float ClosedCube_MAX30205::readTemperature() {
uint16_t rawT = readData(TEMPERATURE);
return (rawT * 0.00390625);
}
uint16_t ClosedCube_MAX30205::readData(uint8_t pointer) {
Wire.beginTransmission(_address);
Wire.write(pointer);
Wire.endTransmission();
delay(10);
Wire.requestFrom(_address, (uint8_t)2);
byte msb = Wire.read();
byte lsb = Wire.read();
return msb << 8 | lsb;
}
Can anybody help me with this?Thank you veery much.