Pages: [1]   Go Down
Author Topic: [GITHUB] ARDUINO-SENSORS - Generic and Reliable Sensors Library  (Read 1987 times)
0 Members and 1 Guest are viewing this topic.
Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi folks!

Here is the library that I made to use with my robots, that includes a bunch of sensors for all kind of stuffs.

It's the ArduinoSensors (https://github.com/ivanseidel/ArduinoSensors) and it's available at GitHub.

All the sensors are implemented using the ArduinoThread (https://github.com/ivanseidel/ArduinoThread) concept, and ready to work with almost every micro-controller.

Included Classes:
  • AnalogIn Class
  • AnalogVoltage Class
  • MLX90614 Temperature Sensor
  • HMC6352 Compass sensor
  • EZ Ultrasonic Sensor
  • Ping Ultrasonic Sensor
  • HC-SR04 Ultrasonic Sensor
  • InvenSense IMU MPU9150
  • InvenSense IMU MPU6050
  • Sharp Infrared Short Distance Sensor (GP2D120XJ00F)
  • Sharp Infrared Medium Distance Sensor (GP2Y0A21YK)
  • Sharp Infrared Long Distance Sensor (GP2Y0A02YK0F)

Included Interfaces:
  • TemperatureInterface
  • DistanceInterface
  • VoltageInterface
  • AngleInterface

This library of libraries was made to target many others sensors, with it's generic Interfaces.

I'm still documenting, but that's going to take time. If there is anyone interested in doing that, I appreciate the help!

Also, take a look at my others libraries, they might help:
Arduino Thread | https://github.com/ivanseidel/ArduinoThread
LinkedList | https://github.com/ivanseidel/LinkedList
Due Timer | https://github.com/ivanseidel/DueTimer
Arduino Gaussian | https://github.com/ivanseidel/Gaussian
Arduino User Interface | https://github.com/ivanseidel/ArdUI
« Last Edit: March 10, 2014, 07:52:59 pm by ivanseidel » Logged


Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting links, bookmarked

BTW. I think that one link to your github repo in your signature will be enough
Logged

Rob Tillaart

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

Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting links, bookmarked

BTW. I think that one link to your github repo in your signature will be enough

Thanks! Comments are welcome =)

Changed it to a few ones...
Logged


Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

---------- NEW CLASS ----------
A new concept for Analog input pins: AnalogVoltage.

Whit this object, you can easily port almost every Analog sensor that requires a reliable Reference Voltage to work.

Let's say the Sharp sensor: It outputs up to 3.1V. It works on both 3.3V and 5V plataforms, but... You would need a library for each of them, since the default reference is different.

With this class, it knows the default AREF voltage of the Arduino, and can perfecly fit in both 5v and 3.3v without a line more of code...
Logged


Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

interesting thought to make it voltage independant!

some remarks:

static const long cachedMaxValue = 1023;     probably  int works well enough saves 2 bytes

float percentage = (((float) ADValue) / cachedMaxValue); 
could be
float percentage = ( ADValue * (1.0/cachedMaxValue);  // will become a compile time calculated value which is faster @ runtime + no casting need.


rewrote function    as I think there is a bug if only v2 was NO_VOLTAGE, please check
Code:

AnalogVoltage(int _inPin = -1, float minV = NO_VOLTAGE, float maxV = NO_VOLTAGE): AnalogIn(_inPin)
{
  voltage = 0;
  minVoltage = (minV == NO_VOLTAGE) ? 0.0 : minV;
  maxVoltage = (maxV == NO_VOLTAGE) ? defaultAnalogReference : maxV;
}

Think you can save some bytes more if you use integers representing milliVolts for the voltages, also the math will be faster.
Logged

Rob Tillaart

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

Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

static const long cachedMaxValue = 1023;     probably  int works well enough saves 2 bytes

float percentage = (((float) ADValue) / cachedMaxValue); 
could be
float percentage = ( ADValue * (1.0/cachedMaxValue);  // will become a compile time calculated value which is faster @ runtime + no casting need.


rewrote function    as I think there is a bug if only v2 was NO_VOLTAGE, please check
Code:

AnalogVoltage(int _inPin = -1, float minV = NO_VOLTAGE, float maxV = NO_VOLTAGE): AnalogIn(_inPin)
{
  voltage = 0;
  minVoltage = (minV == NO_VOLTAGE) ? 0.0 : minV;
  maxVoltage = (maxV == NO_VOLTAGE) ? defaultAnalogReference : maxV;
}

Will be added in the next version! Thanks!
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Thanks for the library. It saved me a lot of work and it looks nice with the threading but I'm having some trouble using it.

I looked at an example and did the same but for a SharpShort sensor. When I tried to compile it, I always got an error saying undefined reference to vtable in SharpInterface. To resolve that error, I had to make the function convertDistance a pure virtual (
Code:
virtual float convertDistance(float value) = 0;
)

Maybe something you could add...

Jasper
Logged

Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Thanks for the library. It saved me a lot of work and it looks nice with the threading but I'm having some trouble using it.

I looked at an example and did the same but for a SharpShort sensor. When I tried to compile it, I always got an error saying undefined reference to vtable in SharpInterface. To resolve that error, I had to make the function convertDistance a pure virtual (
Code:
virtual float convertDistance(float value) = 0;
)

Maybe something you could add...

Jasper

Thanks for the notice! I'm still coding some parts, and thinking about anothers... I think that next month the library will be more complete, but please, use and give me feedback, so that I can know what to improve.

Thanks,
Ivan
Logged


Pages: [1]   Go Up
Jump to: