Go Down

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

teoqba

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:
https://github.com/teoqba/Si7020

I hope you will like it.




rogerClark

I think this needs to go in the Gallery section.  I will ask the moderators to move it
Freelance developer and IT consultant
www.rogerclark.net

robtillaart

#2
Dec 05, 2014, 08:22 am Last Edit: Dec 05, 2014, 08:32 am by robtillaart
@Roger

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


@teoqba
looks well done, some remarks

1)
makeMesurment()  => makeMeasurement()

2)
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;



3)
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() 

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

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

6)
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;
}



7)
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

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

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

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

12)
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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy