Go Down

Topic: [GITHUB] ARDUINO-SENSORS - Generic and Reliable Sensors Library (Read 2200 times) previous topic - next topic

ivanseidel

Sep 08, 2013, 04:47 am Last Edit: Mar 11, 2014, 01:52 am by ivanseidel Reason: 1
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
Arduino DueTimer | https://github.com/ivanseidel/DueTimer
Arduino Thread | https://github.com/ivanseidel/ArduinoThread

robtillaart

Interesting links, bookmarked

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

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

ivanseidel


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...
Arduino DueTimer | https://github.com/ivanseidel/DueTimer
Arduino Thread | https://github.com/ivanseidel/ArduinoThread

ivanseidel

---------- 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...
Arduino DueTimer | https://github.com/ivanseidel/DueTimer
Arduino Thread | https://github.com/ivanseidel/ArduinoThread

robtillaart

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: [Select]

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.
Rob Tillaart

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

ivanseidel


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: [Select]

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!
Arduino DueTimer | https://github.com/ivanseidel/DueTimer
Arduino Thread | https://github.com/ivanseidel/ArduinoThread

japus

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: [Select]
virtual float convertDistance(float value) = 0;)

Maybe something you could add...

Jasper

ivanseidel


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: [Select]
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
Arduino DueTimer | https://github.com/ivanseidel/DueTimer
Arduino Thread | https://github.com/ivanseidel/ArduinoThread

Go Up