Go Down

Topic: Si7020 humidity sensor library + breakout board (Read 81 times) previous topic - next topic


Hi all,

I have written a library for Silicon Labs Si7020 relative humidity and temperature sensor.
It is first library I have created, mainly to learn stuff.

Along with the library I also attach Eagle design files for small PCB to play around with the sensor. The design is tested and it works.

You can find all at:

I hope you will like it.


I think this needs to go in the Gallery section.  I will ask the moderators to move it


Dec 05, 2014, 08:22 am Last Edit: Dec 05, 2014, 08:32 am by robtillaart

For me it is OK to have arduino related libraries here, imho the gallery is more for final projects.

looks well done, some remarks

makeMesurment()  => makeMeasurement()

several places
Code: [Select]

uint16_t RH_Code = makeMeasurment(RH_HOLD);
float result = (RH_Code * (125.0/65536)) - 6;  // now compiler can optimze math compile time
return result;

readTemp() and getTemp() are different, but the difference is not well reflected in the name

some suggestions
getPreviousTemperature()  - getLastTemperature() -getRHTemperarute()

the other just more descriptive getTemperature() 

getRH() ==> getHumidity()  // more descriptive name

changeResolution(uint8_t i);
you could make an ENUM for the parameter  RES_LOW  RES_MED   RES HIGH  RES_MAX

if the param is out of range you still change the resolution, think you should prevent that

Code: [Select]

bool Si7020::changeResolution(uint8_t resolution)
  if (resolution > RES_LOW) return false;
  return true;

Wire.endTransmission();  return a value <> 0 in case of error. You could use that for robustness.
See the Wire lib for the details. YOu can use a private error flag to hold the last error.

8 )
The timeout of the makeMeasurement() return 0 in case of an timeout.
Does this not interfere with real measurements?  better use the error flag

If the max delay = 22 msec you do not need to count to 100 msec for timeout,
25 or 30 should be enough.

in makeMeasurement you sometimes ask for 3 bytes but you only read the first 2.
is the 3rd byte the CRC?

(you could use less local memory making the footprint a few bytes smaller)

Track version, if not used it doesn't take memory

#define SI7020_LIB_VERSION "0.1.00"

think that's enough feedback for one iteration :)

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up