Compare commits

...

11 Commits

Author SHA1 Message Date
Miguel Angel Califa Urquiza
c927504bf5 Update readme and contributing files 2023-10-04 16:21:25 -05:00
Miguel Angel Califa Urquiza
337d962862
Merge pull request #64 from adrcunha/master
Allow setting the ADC pin of a MQUnifiedsensor object.
2023-05-16 11:21:45 -05:00
Adriano Cunha
f7f2c1f3f4 Allow setting the ADC pin of a MQUnifiedsensor object.
The ADC pin can only be set when using the full/long constructor, causing the short constructor (name/type only) useless because the pin is unset.

Also default the ADC pin to 1 for consistency sake.
2023-04-11 14:30:49 -07:00
Miguel Angel Califa Urquiza
1c131eed65
Merge pull request #61 from adrcunha/master
Cleanup general definitions in MQUnifiedSensor.h
2023-04-11 07:13:18 -05:00
Adriano Cunha
b6bff185f3 Cleanup general definitions in MQUnifiedSensor.h
ADC_RESOLUTION is unused, and retries and retry_interval are only used by getVoltage().
Thus, remove ADC_RESOLUTION and move retries and retry_interval to MQUnifiedsensor.cpp.
Furthermore, these three definitions have generic names so it's easy to have them
conflict with a user's sketch that imports MQUnifiedSensor.h.
2023-04-03 08:53:13 -07:00
Miguel Angel Califa Urquiza
a7e89570fd
Merge pull request #53 from SMH17/patch-1
Update README.md
2023-03-15 16:35:38 -05:00
Miguel Angel Califa Urquiza
35180270ac
Merge pull request #56 from PsySc0rpi0n/patch-2
Update MQUnifiedsensor.cpp
2023-03-15 16:35:26 -05:00
Miguel Angel Califa Urquiza
52bccfbff1
Merge pull request #57 from PsySc0rpi0n/patch-3
Update MQUnifiedsensor.h
2023-03-15 16:35:12 -05:00
PsySc0rpi0n
3368613dd7
Update MQUnifiedsensor.h 2022-09-07 22:24:54 +01:00
PsySc0rpi0n
9f41530cda
Update MQUnifiedsensor.cpp
Change the `_type` array size from 6 to 7 so that it can display sensor name's with 6 characters or more.
2022-09-07 22:23:27 +01:00
Silvio Marano
e862774fe0
Update README.md
These sensors are all made by HANWEI Electronics, Sparkfun etc. are just resellers.
2022-08-03 01:53:49 +02:00
5 changed files with 27 additions and 18 deletions

View File

@ -12,6 +12,8 @@ Please delete options that are not relevant.
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] I have updated the version in `library.properties` to reflect my changes (advance by 0.01 for minor changes, or a whole number for new features)
- [ ] I have submitted the pull request
# How Has This Been Tested?

View File

@ -20,3 +20,7 @@ Pull request will be check by three main authors who are linked in
[REAMDE.md](https://github.com/miguel5612/MQSensorsLib/README.md) and they determine to merge to
master branch. Later than assessment and debbuging procedures was completed, the contribution
will be released.
## Versioning
When making a pull request, please remember to update the `library.properties` file to reflect the changes you've made. If your change is minor, consider advancing the version by 0.01. If you're adding a new feature, you may want to advance the version by a whole number.

View File

@ -121,15 +121,15 @@ You'll need Arduino desktop app 1.8.9 or later.
### Sensor manufacturers:
| Sensor | Manufacture | URL Datasheet |
|----------|----------|----------|
| MQ-2 | Pololulu| [datasheet](https://www.pololu.com/file/0J309/MQ2.pdf) |
| MQ-3 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf) |
| MQ-4 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-4.pdf) |
| MQ-5 | parallax | [datasheet](https://www.parallax.com/sites/default/files/downloads/605-00009-MQ-5-Datasheet.pdf) |
| MQ-6 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-6.pdf) |
| MQ-7 | Sparkfun | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-7.pdf) |
| MQ-8 | Sparkfun | [datasheet](https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Biometric/MQ-8.pdf) |
| MQ-9 | Haoyuelectronics | [datasheet](http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf) |
| MQ-131 | Sensorsportal | [datasheet](http://www.sensorsportal.com/DOWNLOADS/MQ131.pdf) |
| MQ-2 | HANWEI Electronics| [datasheet](https://www.pololu.com/file/0J309/MQ2.pdf) |
| MQ-3 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/MQ-3.pdf) |
| MQ-4 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-4.pdf) |
| MQ-5 | HANWEI Electronics | [datasheet](https://www.parallax.com/sites/default/files/downloads/605-00009-MQ-5-Datasheet.pdf) |
| MQ-6 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-6.pdf) |
| MQ-7 | HANWEI Electronics | [datasheet](https://www.sparkfun.com/datasheets/Sensors/Biometric/MQ-7.pdf) |
| MQ-8 | HANWEI Electronics | [datasheet](https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Biometric/MQ-8.pdf) |
| MQ-9 | HANWEI Electronics | [datasheet](http://www.haoyuelectronics.com/Attachment/MQ-9/MQ9.pdf) |
| MQ-131 | HANWEI Electronics | [datasheet](http://www.sensorsportal.com/DOWNLOADS/MQ131.pdf) |
| MQ-135 | HANWEI Electronics | [datasheet](https://www.electronicoscaldas.com/datasheet/MQ-135_Hanwei.pdf) |
| MQ-136 | HANWEI Electronics | [datasheet](https://github.com/miguel5612/MQSensorsLib_Docs/blob/master/Datasheets/MQ136%20-%20Hanwei.pdf) |
| MQ-303A | HANWEI Electronics | [datasheet](http://www.kosmodrom.com.ua/pdf/MQ303A.pdf) |

View File

@ -1,9 +1,12 @@
#include "MQUnifiedsensor.h"
#define retries 2
#define retry_interval 20
MQUnifiedsensor::MQUnifiedsensor(String Placa, float Voltage_Resolution, int ADC_Bit_Resolution, int pin, String type) {
this->_pin = pin;
Placa.toCharArray(this->_placa, 20);
type.toCharArray(this->_type, 6);
type.toCharArray(this->_type, 7);
//this->_type = type; //MQ-2, MQ-3 ... MQ-309A
//this->_placa = Placa;
this-> _VOLT_RESOLUTION = Voltage_Resolution;
@ -11,7 +14,7 @@ MQUnifiedsensor::MQUnifiedsensor(String Placa, float Voltage_Resolution, int ADC
}
MQUnifiedsensor::MQUnifiedsensor(String Placa, String type) {
Placa.toCharArray(this->_placa, 20);
type.toCharArray(this->_type, 6);
type.toCharArray(this->_type, 7);
}
void MQUnifiedsensor::init()
{
@ -38,6 +41,9 @@ void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
{
_VOLT_RESOLUTION = voltage_resolution;
}
void MQUnifiedsensor::setPin(int pin) {
this->_pin = pin;
}
void MQUnifiedsensor::setRegressionMethod(int regressionMethod)
{
//this->_regressionMethod = regressionMethod;
@ -233,4 +239,4 @@ float MQUnifiedsensor::getRS()
float MQUnifiedsensor::stringTofloat(String & str)
{
return atof( str.c_str() );
}
}

View File

@ -6,10 +6,6 @@
/***********************Software Related Macros************************************/
#define ADC_RESOLUTION 10 // for 10bit analog to digital converter.
#define retries 2
#define retry_interval 20
class MQUnifiedsensor
{
public:
@ -26,6 +22,7 @@ class MQUnifiedsensor
void setB(float b);
void setRegressionMethod(int regressionMethod);
void setVoltResolution(float voltage_resolution = 5);
void setPin(int pin = 1);
void serialDebug(bool onSetup = false); //Show on serial port information about sensor
void setADC(int value); //For external ADC Usage
@ -51,7 +48,7 @@ class MQUnifiedsensor
private:
/************************Private vars************************************/
byte _pin;
byte _pin = 1;
byte _firstFlag = false;
float _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
float _RL = 10; //Value in KiloOhms
@ -61,7 +58,7 @@ class MQUnifiedsensor
float _adc, _a, _b, _sensor_volt;
float _R0, RS_air, _ratio, _PPM, _RS_Calc;
char _type[6];
char _type[7];
char _placa[20];
};