Is there a way to get these two sensors to work together ? I believe they both want 0X60. Can they be changed ? Thanks
( I am guessing not )
MPL3115A2 and SI1145 Addreses
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPL3115A2 and SI1145 Addreses
Neither one exposes an address pin, so there's nothing you can do about the address.
You can use a pair of software I2C connections that share a common SCK line though. It will consume three pins rather than two, but will avoid address collisions.
You can use a pair of software I2C connections that share a common SCK line though. It will consume three pins rather than two, but will avoid address collisions.
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
Can you point me at an explanation / sample ? Does it have to be an analog pin ?
Thanks
Thanks
- egutting
- Posts: 297
- Joined: Wed Nov 14, 2012 12:57 am
Re: MPL3115A2 and SI1145 Addreses
I just looked at the data sheet. it looks like the SI1145 allows you to change it's address with the BUSADDR command (0x02 register).
From the data sheet:
From the data sheet:
BUSADDR
000 00010
—
—
—
Modifies I2C address
Specifies a new I2C Address for the device to respond to. The new address takes effect when a BUSADDR command is received.
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
Looking at the datasheet and your suggested code, this should have done it. But the address refuses to change.
wire.begin();
wire.beginTransmission(0x60); // the address with a conflict
wire.write(0x02); // busaddr 000 00010
wire.write(0x61); // new address
wire.endTransmission(); // force it to close
I also tried
wire.endTransmission(false); // just in case
and that didn't do either. The I2c scanner still picked up the 60.
The ONLY device on the I2C was the SI1145 since as near as i can tell, the MPL3115A2 isnt changeable.
wire.begin();
wire.beginTransmission(0x60); // the address with a conflict
wire.write(0x02); // busaddr 000 00010
wire.write(0x61); // new address
wire.endTransmission(); // force it to close
I also tried
wire.endTransmission(false); // just in case
and that didn't do either. The I2c scanner still picked up the 60.
The ONLY device on the I2C was the SI1145 since as near as i can tell, the MPL3115A2 isnt changeable.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPL3115A2 and SI1145 Addreses
Software I2C doesn't place any limits on what pins you can use.wdickenson wrote:Can you point me at an explanation / sample ? Does it have to be an analog pin ?
The Wire library requires pins A4 and A5 because those are the ones connected to the ATmega328P's built-in I2C hardware. Using those pins for I2C makes your code smaller because the chip itself handles all the signal clocking and so forth. All you need to do in your code is store the byte you want to send in the correct location and press 'Go'.
Software I2C handles all the mechanics of the connection in code, so it's bulkier than hardware I2C. It doesn't have any pin restrictions though, so it's more flexible.
There are several software I2C libraries out there, but we have a high opinion of this one: https://github.com/greiman/DigitalIO
All you need to do is create two SoftI2cMaster objects using different sets of SDA pins:
Code: Select all
SoftI2cMaster bus1( 3, 4 ); // 3 is SCK, 4 is SDA
SoftI2cMaster bus2( 3, 2 ); // 3 is SCK, 2 is SDA
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
Thank you. Thats very clear and would seem to do it. Not as elegant as changing the address on the SI1145 but workable. Can it co-exist with wire ? Most of the sensors in this set use wire and I would hate to have to redo that.
and can you tell me why the address change didn't work ? I am new to reading data sheets but looking at lots of other examples, I don't seem to have missed anything but I obviously did.
Thanks again
and can you tell me why the address change didn't work ? I am new to reading data sheets but looking at lots of other examples, I don't seem to have missed anything but I obviously did.
Thanks again
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPL3115A2 and SI1145 Addreses
Don't worry about not understanding the datasheet.. I've read many and this one looks like they took special effort to avoid putting in too much useful information.
It looks like the chip has two classes of IO: regular I2C reads and writes, and a 'command' interface controlled by a special set of I2C registers.
Setting the I2C address requires a set of Commands, so I think this would be the correct sequence:
It looks like the chip has two classes of IO: regular I2C reads and writes, and a 'command' interface controlled by a special set of I2C registers.
Setting the I2C address requires a set of Commands, so I think this would be the correct sequence:
Code: Select all
// write the address (0x61) to the PARAM_WR I2C register (0x17)
wire.begin();
wire.beginTransmission( 0x60 );
wire.write( 0x17 );
wire.write( 0x61 );
wire.endTransmission();
// write a PARAM_SET command into the COMMAND register (0x18)
wire.beginTransmission( 0x60 );
wire.write( 0x18 );
wire.write( 0xA0 ); // PARAM_SET command (0xA0) OR'd with the I2C_ADDR PRAM address (0x00)
wire.endTransmission();
/* tell the chip you want to read the command response register.
the first half is a "tell the chip what address I want by starting
a write but not sending any data" transaction.. regrettably common
in I2C
*/
wire.beginTransmission( 0x60 );
wire.write( 0x2E );
wire.endTransmission();
wire.requestFrom( 0x60, (uint8_t)0x01 ); // read one byte from the address just set
uint8_t reply = wire.read();
Serial.print( "return value from PARAM_SET command: 0x" );
Serial.print( reply, HEX );
/* now, having done all that, execute a BUSADDR command to use the address
we've stored in the PRAM
*/
wire.beginTransmission( 0x60 );
wire.write( 0x18 );
wire.write( 0x02 ); // BUSADDR command
wire.endTransmission();
// this time we find the result in the RESPONSE register (0x20)
wire.beginTransmission( 0x60 );
wire.write( 0x20 );
wire.endTransmission();
wire.requestFrom( 0x60, (uint8_t)0x01 );
reply = wire.read();
Serial.print( "return value from BUSADDR command: 0x" );
Serial.print( reply, HEX );
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
I will make a run at this tonight. Thank you
I also have to say that your writeup brought a chuckle. Not only was it educational and very clear, it made me smile at 7am before my coffee. Which is not a trivial feat in and of itself.
Thanks again. I will let you know how it goes tonight.
I also have to say that your writeup brought a chuckle. Not only was it educational and very clear, it made me smile at 7am before my coffee. Which is not a trivial feat in and of itself.
Thanks again. I will let you know how it goes tonight.
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
Worked perfectly. The new address is on the bus. It goes back to 0x60 when the power goes off but this is a huge step.
Thank you again.
Thank you again.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPL3115A2 and SI1145 Addreses
Wow.. getting it on the first try is a mild surprise. ;-)
Glad to hear it works, and now we can add this to the bag of tricks.
Glad to hear it works, and now we can add this to the bag of tricks.
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
I might need a tad more help here.
The address changes, no doubt. The I2CScan program picks it up.
So I went into the .cpp file and added the following methods.
I overloaded the init to take a new address
// original method
Adafruit_SI1145::Adafruit_SI1145() {
_addr = SI1145_ADDR;
}
// override
Adafruit_SI1145::Adafruit_SI1145(uint8_t naddr) {
_addr = naddr;
}
And I added a getADDR function so I could validate that things moved.
// get the address
uint8_t Adafruit_SI1145::getADDR(void) {
return _addr;
}
changes to the .h file as well obviously.
Eventually, I plan to incorpoate your code into the .cpp but for now, this should work. When I put 0x60 in all works fine.
When I put 0x61, I get 65535.
Is there an interaction I don't see ?
The address changes, no doubt. The I2CScan program picks it up.
So I went into the .cpp file and added the following methods.
I overloaded the init to take a new address
// original method
Adafruit_SI1145::Adafruit_SI1145() {
_addr = SI1145_ADDR;
}
// override
Adafruit_SI1145::Adafruit_SI1145(uint8_t naddr) {
_addr = naddr;
}
And I added a getADDR function so I could validate that things moved.
// get the address
uint8_t Adafruit_SI1145::getADDR(void) {
return _addr;
}
changes to the .h file as well obviously.
Eventually, I plan to incorpoate your code into the .cpp but for now, this should work. When I put 0x60 in all works fine.
When I put 0x61, I get 65535.
Is there an interaction I don't see ?
Code: Select all
/***************************************************
This is a library for the Si1145 UV/IR/Visible Light Sensor
Designed specifically to work with the Si1145 sensor in the
adafruit shop
----> https://www.adafruit.com/products/1777
These sensors use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h>
#include "Adafruit_SI1145.h"
#define NEW_ADDR 0x61
Adafruit_SI1145 uv = Adafruit_SI1145(NEW_ADDR);
void setup() {
Serial.begin(9600);
Serial.println("Adafruit SI1145 test");
Wire.begin();
Wire.beginTransmission( 0x60 );
Wire.write( 0x17 );
Wire.write( NEW_ADDR );
Wire.endTransmission();
// write a PARAM_SET command into the COMMAND register (0x18)
Wire.beginTransmission( 0x60 );
Wire.write( 0x18 );
Wire.write( 0xA0 ); // PARAM_SET command (0xA0) OR'd with the I2C_ADDR PRAM address (0x00)
Wire.endTransmission();
// tell the chip you want to read the command response register.
// the first half is a "tell the chip what address I want by starting
// a write but not sending any data" transaction.. regrettably common
// in I2C
//
Wire.beginTransmission( 0x60 );
Wire.write( 0x2E );
Wire.endTransmission();
Wire.requestFrom( 0x60, 0x01 ); // read one byte from the address just set
uint8_t reply = Wire.read();
Serial.print( "return value from PARAM_SET command: 0x" );
Serial.println( reply, HEX );
// now, having done all that, execute a BUSADDR command to use the address
// we've stored in the PRAM
//
Wire.beginTransmission( 0x60 );
Wire.write( 0x18 );
Wire.write( 0x02 ); // BUSADDR command
Wire.endTransmission();
// this time we find the result in the RESPONSE register (0x20)
Wire.beginTransmission( 0x60 );
Wire.write( 0x20 );
Wire.endTransmission();
Wire.requestFrom( 0x60, 0x01 );
reply = Wire.read();
Serial.print( "return value from BUSADDR command: 0x" );
Serial.println( reply, HEX );
if (! uv.begin()) {
Serial.println("Didn't find Si1145");
while (1);
}
Serial.println("OK!");
}
void loop() {
Serial.println("===================");
Serial.print("ADDR:");Serial.println(uv.getADDR(),HEX);
Serial.print("Vis: "); Serial.println(uv.readVisible());
Serial.print("IR: "); Serial.println(uv.readIR());
// Uncomment if you have an IR LED attached to LED pin!
//Serial.print("Prox: "); Serial.println(uv.readProx());
float UVindex = uv.readUV();
// the index is multiplied by 100 so to get the
// integer index, divide by 100!
UVindex /= 100.0;
Serial.print("UV: "); Serial.println(UVindex);
delay(1000);
}
Code: Select all
/***************************************************
This is a library for the Si1145 UV/IR/Visible Light Sensor
Designed specifically to work with the Si1145 sensor in the
adafruit shop
----> https://www.adafruit.com/products/1777
These sensors use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include "Adafruit_SI1145.h"
Adafruit_SI1145::Adafruit_SI1145() {
_addr = SI1145_ADDR;
}
Adafruit_SI1145::Adafruit_SI1145(uint8_t naddr) {
_addr = naddr;
}
boolean Adafruit_SI1145::begin(void) {
Wire.begin();
uint8_t id = read8(SI1145_REG_PARTID);
if (id != 0x45) return false; // look for SI1145
reset();
/***********************************/
// enable UVindex measurement coefficients!
write8(SI1145_REG_UCOEFF0, 0x29);
write8(SI1145_REG_UCOEFF1, 0x89);
write8(SI1145_REG_UCOEFF2, 0x02);
write8(SI1145_REG_UCOEFF3, 0x00);
// enable UV sensor
writeParam(SI1145_PARAM_CHLIST, SI1145_PARAM_CHLIST_ENUV |
SI1145_PARAM_CHLIST_ENALSIR | SI1145_PARAM_CHLIST_ENALSVIS |
SI1145_PARAM_CHLIST_ENPS1);
// enable interrupt on every sample
write8(SI1145_REG_INTCFG, SI1145_REG_INTCFG_INTOE);
write8(SI1145_REG_IRQEN, SI1145_REG_IRQEN_ALSEVERYSAMPLE);
/****************************** Prox Sense 1 */
// program LED current
write8(SI1145_REG_PSLED21, 0x03); // 20mA for LED 1 only
writeParam(SI1145_PARAM_PS1ADCMUX, SI1145_PARAM_ADCMUX_LARGEIR);
// prox sensor #1 uses LED #1
writeParam(SI1145_PARAM_PSLED12SEL, SI1145_PARAM_PSLED12SEL_PS1LED1);
// fastest clocks, clock div 1
writeParam(SI1145_PARAM_PSADCGAIN, 0);
// take 511 clocks to measure
writeParam(SI1145_PARAM_PSADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
// in prox mode, high range
writeParam(SI1145_PARAM_PSADCMISC, SI1145_PARAM_PSADCMISC_RANGE|
SI1145_PARAM_PSADCMISC_PSMODE);
writeParam(SI1145_PARAM_ALSIRADCMUX, SI1145_PARAM_ADCMUX_SMALLIR);
// fastest clocks, clock div 1
writeParam(SI1145_PARAM_ALSIRADCGAIN, 0);
// take 511 clocks to measure
writeParam(SI1145_PARAM_ALSIRADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
// in high range mode
writeParam(SI1145_PARAM_ALSIRADCMISC, SI1145_PARAM_ALSIRADCMISC_RANGE);
// fastest clocks, clock div 1
writeParam(SI1145_PARAM_ALSVISADCGAIN, 0);
// take 511 clocks to measure
writeParam(SI1145_PARAM_ALSVISADCOUNTER, SI1145_PARAM_ADCCOUNTER_511CLK);
// in high range mode (not normal signal)
writeParam(SI1145_PARAM_ALSVISADCMISC, SI1145_PARAM_ALSVISADCMISC_VISRANGE);
/************************/
// measurement rate for auto
write8(SI1145_REG_MEASRATE0, 0xFF); // 255 * 31.25uS = 8ms
// auto run
write8(SI1145_REG_COMMAND, SI1145_PSALS_AUTO);
return true;
}
void Adafruit_SI1145::reset() {
write8(SI1145_REG_MEASRATE0, 0);
write8(SI1145_REG_MEASRATE1, 0);
write8(SI1145_REG_IRQEN, 0);
write8(SI1145_REG_IRQMODE1, 0);
write8(SI1145_REG_IRQMODE2, 0);
write8(SI1145_REG_INTCFG, 0);
write8(SI1145_REG_IRQSTAT, 0xFF);
write8(SI1145_REG_COMMAND, SI1145_RESET);
delay(10);
write8(SI1145_REG_HWKEY, 0x17);
delay(10);
}
// get the address
uint8_t Adafruit_SI1145::getADDR(void) {
return _addr;
}
//////////////////////////////////////////////////////
// returns the UV index * 100 (divide by 100 to get the index)
uint16_t Adafruit_SI1145::readUV(void) {
return read16(0x2C);
}
// returns visible+IR light levels
uint16_t Adafruit_SI1145::readVisible(void) {
return read16(0x22);
}
// returns IR light levels
uint16_t Adafruit_SI1145::readIR(void) {
return read16(0x24);
}
// returns "Proximity" - assumes an IR LED is attached to LED
uint16_t Adafruit_SI1145::readProx(void) {
return read16(0x26);
}
/*********************************************************************/
uint8_t Adafruit_SI1145::writeParam(uint8_t p, uint8_t v) {
//Serial.print("Param 0x"); Serial.print(p, HEX);
//Serial.print(" = 0x"); Serial.println(v, HEX);
write8(SI1145_REG_PARAMWR, v);
write8(SI1145_REG_COMMAND, p | SI1145_PARAM_SET);
return read8(SI1145_REG_PARAMRD);
}
uint8_t Adafruit_SI1145::readParam(uint8_t p) {
write8(SI1145_REG_COMMAND, p | SI1145_PARAM_QUERY);
return read8(SI1145_REG_PARAMRD);
}
/*********************************************************************/
uint8_t Adafruit_SI1145::read8(uint8_t reg) {
uint16_t val;
Wire.beginTransmission(_addr);
Wire.write((uint8_t)reg);
Wire.endTransmission();
Wire.requestFrom((uint8_t)_addr, (uint8_t)1);
return Wire.read();
}
uint16_t Adafruit_SI1145::read16(uint8_t a) {
uint16_t ret;
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(a); // sends register address to read from
Wire.endTransmission(); // end transmission
Wire.requestFrom(_addr, (uint8_t)2);// send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= (uint16_t)Wire.read() << 8; // receive DATA
return ret;
}
void Adafruit_SI1145::write8(uint8_t reg, uint8_t val) {
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(reg); // sends register address to write
Wire.write(val); // sends value
Wire.endTransmission(); // end transmission
}
Code: Select all
/***************************************************
This is a library for the Si1145 UV/IR/Visible Light Sensor
Designed specifically to work with the Si1145 sensor in the
adafruit shop
----> https://www.adafruit.com/products/1777
These sensors use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
/* COMMANDS */
#define SI1145_PARAM_QUERY 0x80
#define SI1145_PARAM_SET 0xA0
#define SI1145_NOP 0x0
#define SI1145_RESET 0x01
#define SI1145_BUSADDR 0x02
#define SI1145_PS_FORCE 0x05
#define SI1145_ALS_FORCE 0x06
#define SI1145_PSALS_FORCE 0x07
#define SI1145_PS_PAUSE 0x09
#define SI1145_ALS_PAUSE 0x0A
#define SI1145_PSALS_PAUSE 0xB
#define SI1145_PS_AUTO 0x0D
#define SI1145_ALS_AUTO 0x0E
#define SI1145_PSALS_AUTO 0x0F
#define SI1145_GET_CAL 0x12
/* Parameters */
#define SI1145_PARAM_I2CADDR 0x00
#define SI1145_PARAM_CHLIST 0x01
#define SI1145_PARAM_CHLIST_ENUV 0x80
#define SI1145_PARAM_CHLIST_ENAUX 0x40
#define SI1145_PARAM_CHLIST_ENALSIR 0x20
#define SI1145_PARAM_CHLIST_ENALSVIS 0x10
#define SI1145_PARAM_CHLIST_ENPS1 0x01
#define SI1145_PARAM_CHLIST_ENPS2 0x02
#define SI1145_PARAM_CHLIST_ENPS3 0x04
#define SI1145_PARAM_PSLED12SEL 0x02
#define SI1145_PARAM_PSLED12SEL_PS2NONE 0x00
#define SI1145_PARAM_PSLED12SEL_PS2LED1 0x10
#define SI1145_PARAM_PSLED12SEL_PS2LED2 0x20
#define SI1145_PARAM_PSLED12SEL_PS2LED3 0x40
#define SI1145_PARAM_PSLED12SEL_PS1NONE 0x00
#define SI1145_PARAM_PSLED12SEL_PS1LED1 0x01
#define SI1145_PARAM_PSLED12SEL_PS1LED2 0x02
#define SI1145_PARAM_PSLED12SEL_PS1LED3 0x04
#define SI1145_PARAM_PSLED3SEL 0x03
#define SI1145_PARAM_PSENCODE 0x05
#define SI1145_PARAM_ALSENCODE 0x06
#define SI1145_PARAM_PS1ADCMUX 0x07
#define SI1145_PARAM_PS2ADCMUX 0x08
#define SI1145_PARAM_PS3ADCMUX 0x09
#define SI1145_PARAM_PSADCOUNTER 0x0A
#define SI1145_PARAM_PSADCGAIN 0x0B
#define SI1145_PARAM_PSADCMISC 0x0C
#define SI1145_PARAM_PSADCMISC_RANGE 0x20
#define SI1145_PARAM_PSADCMISC_PSMODE 0x04
#define SI1145_PARAM_ALSIRADCMUX 0x0E
#define SI1145_PARAM_AUXADCMUX 0x0F
#define SI1145_PARAM_ALSVISADCOUNTER 0x10
#define SI1145_PARAM_ALSVISADCGAIN 0x11
#define SI1145_PARAM_ALSVISADCMISC 0x12
#define SI1145_PARAM_ALSVISADCMISC_VISRANGE 0x20
#define SI1145_PARAM_ALSIRADCOUNTER 0x1D
#define SI1145_PARAM_ALSIRADCGAIN 0x1E
#define SI1145_PARAM_ALSIRADCMISC 0x1F
#define SI1145_PARAM_ALSIRADCMISC_RANGE 0x20
#define SI1145_PARAM_ADCCOUNTER_511CLK 0x70
#define SI1145_PARAM_ADCMUX_SMALLIR 0x00
#define SI1145_PARAM_ADCMUX_LARGEIR 0x03
/* REGISTERS */
#define SI1145_REG_PARTID 0x00
#define SI1145_REG_REVID 0x01
#define SI1145_REG_SEQID 0x02
#define SI1145_REG_INTCFG 0x03
#define SI1145_REG_INTCFG_INTOE 0x01
#define SI1145_REG_INTCFG_INTMODE 0x02
#define SI1145_REG_IRQEN 0x04
#define SI1145_REG_IRQEN_ALSEVERYSAMPLE 0x01
#define SI1145_REG_IRQEN_PS1EVERYSAMPLE 0x04
#define SI1145_REG_IRQEN_PS2EVERYSAMPLE 0x08
#define SI1145_REG_IRQEN_PS3EVERYSAMPLE 0x10
#define SI1145_REG_IRQMODE1 0x05
#define SI1145_REG_IRQMODE2 0x06
#define SI1145_REG_HWKEY 0x07
#define SI1145_REG_MEASRATE0 0x08
#define SI1145_REG_MEASRATE1 0x09
#define SI1145_REG_PSRATE 0x0A
#define SI1145_REG_PSLED21 0x0F
#define SI1145_REG_PSLED3 0x10
#define SI1145_REG_UCOEFF0 0x13
#define SI1145_REG_UCOEFF1 0x14
#define SI1145_REG_UCOEFF2 0x15
#define SI1145_REG_UCOEFF3 0x16
#define SI1145_REG_PARAMWR 0x17
#define SI1145_REG_COMMAND 0x18
#define SI1145_REG_RESPONSE 0x20
#define SI1145_REG_IRQSTAT 0x21
#define SI1145_REG_IRQSTAT_ALS 0x01
#define SI1145_REG_ALSVISDATA0 0x22
#define SI1145_REG_ALSVISDATA1 0x23
#define SI1145_REG_ALSIRDATA0 0x24
#define SI1145_REG_ALSIRDATA1 0x25
#define SI1145_REG_PS1DATA0 0x26
#define SI1145_REG_PS1DATA1 0x27
#define SI1145_REG_PS2DATA0 0x28
#define SI1145_REG_PS2DATA1 0x29
#define SI1145_REG_PS3DATA0 0x2A
#define SI1145_REG_PS3DATA1 0x2B
#define SI1145_REG_UVINDEX0 0x2C
#define SI1145_REG_UVINDEX1 0x2D
#define SI1145_REG_PARAMRD 0x2E
#define SI1145_REG_CHIPSTAT 0x30
#define SI1145_ADDR 0x60 // changed from 0x60
class Adafruit_SI1145 {
public:
Adafruit_SI1145(void);
Adafruit_SI1145(uint8_t _addr);
boolean begin();
void reset();
uint8_t getADDR(void);
uint16_t readUV();
uint16_t readIR();
uint16_t readVisible();
uint16_t readProx();
private:
uint16_t read16(uint8_t addr);
uint8_t read8(uint8_t addr);
void write8(uint8_t reg, uint8_t val);
uint8_t readParam(uint8_t p);
uint8_t writeParam(uint8_t p, uint8_t v);
uint8_t _addr;
};
- Franklin97355
- Posts: 23910
- Joined: Mon Apr 21, 2008 2:33 pm
Re: MPL3115A2 and SI1145 Addreses
Just off the top of my head but wouldn't 65535 equate to a uint -1? (possible return error)When I put 0x60 in all works fine.
When I put 0x61, I get 65535.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPL3115A2 and SI1145 Addreses
Did you add a signature for the overridden method to the class definition?
Code: Select all
class Adafruit_SI1145 {
public:
Adafruit_SI1145(void);
Adafruit_SI1145(uint8_t);
boolean begin();
void reset();
[...]
- wdickenson
- Posts: 184
- Joined: Fri Nov 16, 2012 8:43 pm
Re: MPL3115A2 and SI1145 Addreses
Yes.
and when I changed the default to 0x61, and ran the update code to change it to 60, it works fine. It just doesnt work from 60 to 61
and when I changed the default to 0x61, and ran the update code to change it to 60, it works fine. It just doesnt work from 60 to 61
Please be positive and constructive with your questions and comments.