LowPowerLab Forum

Hardware support => Moteino => Topic started by: odiephd on April 19, 2017, 06:48:27 PM

Title: E2 CO2 sensor integration (how to refer to I2C pins)
Post by: odiephd on April 19, 2017, 06:48:27 PM
I want to integrate a CO2 sensor from E+E (https://www.epluse.com/en/products/co2-measurement/co2-sensor/ee871/) with the Moteino.  The sensor requires a modified I2C bus called E2 bus.  The main difference is that the bus runs at 500Hz-5KHz instead of 100KHz, and the setup requires 100KOhm pull-up resistors instead of the standard 4.7KOhm for I2C. 

I'm using a library downloaded from github.  Of course, I'm having issues getting it to work.  I have access to an oscilloscope next week to see if the code is really working properly creating this E2 bus, but I have a ROOKIE question first that I hope can be answered. 

In the loop() section code, I setup my E2 device = Sensor(4,5) where SDA pin = 4 and SCL pin =5.  Is this how we reference the I2C interface on the moteino?? 

Thanks in advance,
Jim
Title: Re: E2 sensor integration (how to refer to I2C pins)
Post by: Felix on April 19, 2017, 07:08:42 PM
Two things.

- the SCL and SDA are on A4 and A5 which are NOT the same as D4 and D5. It's an easy mistake which ive done myself several times.
Basically the Digital pins go up to 13 and then the Analogs start (prepended with A). So A0 would be equivalent to D14 and so A4 and A5 would correspond to D18 and D19.
OR you can simply pass A4 and A5 directly in the sketch, which will be replaced with 18 and 19 behind the scenes.
This of course is marked in the Moteino pinouts above the Analog pins are the equivalent digital numbers:

(https://farm4.staticflickr.com/3818/10585364014_df2e1604bc_o.png)

- I would really check why they want 100K instead of the more "standard" 4.7K. There is a good reason why generally I2C pullups have those low K values. In most cases you should not have to change them, and if you did it should not be such a huge value. At least based on my experience. Others please comment if this is wrong.
Title: Re: E2 sensor integration (how to refer to I2C pins)
Post by: odiephd on April 19, 2017, 08:45:19 PM
Hi Felix,

Thanks for the quick reply.  The library is looking for int so should I pass 18 and 19?  Would that work?

To answer your other questions regarding the 100Kohm resistors, here is the E2 spec document
http://downloads.epluse.com/fileadmin/data/sw/Specification_E2_Interface.pdf

Thanks
Jim
Title: Re: E2 sensor integration (how to refer to I2C pins)
Post by: Felix on April 19, 2017, 08:54:03 PM
Does passing A4 and A5 not work? Those are really substitutes definitions for 18 and 19.
Title: Re: E2 sensor integration (how to refer to I2C pins)
Post by: odiephd on April 19, 2017, 08:57:16 PM
I'd have to change the library definition as the pinSDA and pinSCL are defined as int.  I can change the definition and try it. 

Should I pass them as char or what?
Title: Re: E2 sensor integration (how to refer to I2C pins)
Post by: odiephd on April 19, 2017, 09:15:06 PM
I modified the library and pass A4, A5 as char.   I also took out the Arduino.h library as I have the RFM69.h included.

Still didn't work.  I have access to a scope tomorrow morning.
Title: Re: E2 sensor integration (how to refer to I2C pins)
Post by: Felix on April 20, 2017, 02:14:44 PM
I hate libraries written like that, why would they define pins as INTS ??? Do they ever expect a negative pin number?
Maybe you could just box them as ints like (int)(A4) or (int32_t)(A4), and pass them like that.