Tags

, , ,

I made a PCB with the Si7006 on it.  This post is my bumblings encountered as I successfully got temperature and humidity readings from a Si7006 using the PCB I designed.

In summary, the Si7006 is easy to work with.  It is relatively easy to solder and very easy to access via I2C.  I like the ease of use and “connect the chip” capability of chips that use the I2C interface.  It has become my interface of choice because of it’s simplicity and support on Arduino and micro python platforms.

The second aspect of this post that I found useful is evolving Arduino scripts for readability and reusability.  Implementing Tabs and an Si7006 within the Arduino scripts is a step up to how I have been programming examples and tests to interact with chips.  I also evolved handling error messages to work off error codes that are then resolved to strings that are stored in Flash.  It took me awhile to get this technique going.  I see it as a stepping stone to more robust/cleanable/readable code.

Thanks To Those That Went Before

OSH Park – THANK YOU for your exceptional PCB fabrication service at a fair price.  THANK YOU for the quality and cheerfulness of your employees.  THANK YOU for being kind and caring.  I am a very loyal customer.

Adafruit – THANK YOU as well for being kind and caring.  The knowledge folks like Tony D has shared has been a very valuable way to increase what I know how to do.

Open Source

The Arduino code that tests the Si7006 using tabs (Arduino IDE feature) and puts the getting the temperature and humidity within a class is located at this GitHub location.

The Kicad project I reference is located at this GitHub location.

Arduino IDE

I am currently using Arduino 1.6.11.  I keep getting these pesky WARNING messages…:

WARNING: Category ” in library EEPROM is not valid. Setting to ‘Uncategorized’
WARNING: Category ” in library SPI is not valid. Setting to ‘Uncategorized’
WARNING: Category ” in library SoftwareSerial is not valid. Setting to ‘Uncategorized’
WARNING: Category ” in library Wire is not valid. Setting to ‘Uncategorized’
Warning: platform.txt from core ‘Arduino AVR Boards’ contains deprecated recipe.ar.pattern=”{compiler.path}{compiler.ar.cmd}” {compiler.ar.flags} {compiler.ar.extra_flags} “{build.path}/{archive_file}” “{object_file}”, automatically converted to recipe.ar.pattern=”{compiler.path}{compiler.ar.cmd}” {compiler.ar.flags} {compiler.ar.extra_flags} “{archive_file_path}” “{object_file}”. Consider upgrading this core.

Geez…

ChallengesBringOpportunitesYIPPEE!!! Looking at the Arduino downloads page – to my surprise the latest is 1.8.2…so I upgrade and the warnings go away. 

Code Readability

Tony D presented some great tips on Arduino coding with readability in mind. These techniques are based on Tony D’s Youtube video: CircuitPython: Converting Arduino Arc Reactor Sketch to CircuitPython with Tony D!   Tony posted the code he discussed at this GitHub location.

Multiple Tabs

The first technique is the use of multiple files.  Tony discusses this here.  I did this for this version of Si7006Test.ino.  It is a nice way to test how a library will work within an Arduino environment without having to create a library within a C/C++ IDE environment (I use XCode).  Unfortunately, the files within an Arduino project are specific to the project. In order to use the Si7006 within another .ino file, I’ll have to create an Arduino library. A bit of a pain but no big deal.

Si7006 Class

Tony discusses defining a class here.  It’s a nice way of arranging an interface to a chip or logical grouping of functions. 

 Si7006

       NewImage

Schematic, Layout, PCB

Github location

NewImage  NewImageNewImage

Simpson DOH Umm…C1…really?  There is a reason the capacitor symbol has a space between it…electrons don’t go across… This isn’t the first time I’ve made this fairly gross mistake.  I recall Mike at Adafruit support providing an excellent/detailed explanation.  Hopefully, the embarrassment I feel after making this basic mistake will train my brain to solidify a stronger conceptual/practical model into designing in bypass/decoupling capacitors. For now, I’ll remove the capacitor and bridge the pads.  

NewImage

NewImage

 

 

Good better best 

  • Fix the bypass capacitor schematic/layout to actually be correct :-).  Whoa…seriously embarrassed on what I did based on my learnings from Contextual Electronics.  But perhaps the way I should look at it was my mistake became obvious when I started testing.  Yes, I should have picked this up during design.
  • The 0805 footprint I used is larger than I would like (although usable).  I picked the one for easy soldering.  I’d like one that better fits the pins.
  • Add an LED that lights up when the BoB is powered.

Si7006 Firmware

I2C Arduino Pins

I used pins A4 and A5 on the Arduino Uno to handle the I2C conversation with the Si7006:

NewImage

Logic Analyzer

Isn’t it just like chips not to talk the first time they are put together over an I2C bus?  This is what happened to me the first time I ran the Arduino code.  The first time the Arduino couldn’t even find the Si7006.  Who knew this chip was so shy?  This link gives us the error codes -> 0 = Success, 1 = data too long to fit in transmit buffer, 2 = received NACK on transmit of address, 3 = received NACK on transmit of data, 4 = other error.  I was getting error code = 2…couldn’t find the darn chip.

And looking at the traffic on the ever trusty Saleae logic analyzer:

NewImage

I noticed wire traffic shows an address of 0X80.  The I2C address of the Si7006 ix 0x40.  This reference by robot-electronics (see I2C device addressing) helped me understand this stuff about bitshifting the I2C address by 1 bit.  Here is a bit shift calculator to use.  

As the error code let me know, the NAK means the I2C chip with address 0x40 couldn’t be found. Hmm…

Looking closer at the chip:

NewImage

There doesn’t appear to be enough solder on the SDA pin.  Putting on more solder, I now get:

0X84 + ACK

0X88 + ACK

Setup Read to [0x81] + ACK

0x20 + NAK

 

ChallengesBringOpportunitesOutput from the Arduino sketch:

********Si7006 example sketch**********

Humidity: 41.86
Temperature: 19.71

Code

I am thrilled to have evolved Arduino Firmware testing to include:

  • tabs
  • use of a class instead of calls to function to represent access to the S7006.
  • error messaging.
Instead of copy/pasting code, the code is available at this GitHub location.  For Leaf Spa purposes, Si7006.
  float humidity, temperature;
  si7006.getHumidityAndTemperature(humidity, temperature);

is the only function needed to be used.

Error Messages

To save on SRAM, I wanted to put error messages into Flash. The Arrays of strings example on Arduino’s PROGMEM web site was just what I needed to understand in order to get this to happen.  VERY useful.

 

…all this took awhile.  Meanwhile, I need to fix a few leaks.  I’m learning A LOT from maintaining the Leaf Spa….while I will continue to evolve, at some point I am excited to start on version 2 which will take into design consideration all I have learned.

 

 

 

 

Advertisements