MQ3 sensor code

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <MQUnifiedsensor.h>
#include <LiquidCrystal_I2C.h>

SoftwareSerial mySerial(10, 11);
Adafruit_Fingerprint finger(&mySerial);
MQUnifiedsensor alcoholSensor(A0, A1);
LiquidCrystal_I2C lcd(0x27, 16, 2);

const int powerPin = 13;

void setup() {
  Serial.begin(9600);
  finger.begin(57600);
  lcd.begin(16, 2);
  lcd.print("Place finger...");
}

void loop() {
  if (finger.fingerPresent()) {
    lcd.clear();
    lcd.print("Finger detected");

    if (finger.verify()) {
      lcd.clear();
      lcd.print("Fingerprint matched");

      float alcoholConcentration = alcoholSensor.read();
      lcd.setCursor(0, 1);
      lcd.print("Alcohol: " + String(alcoholConcentration, 2)); 

      if (alcoholConcentration >= 0.03) {
        lcd.clear();
        lcd.print("Power off");
        digitalWrite(powerPin, LOW);
        delay(1000);
        digitalWrite(powerPin, HIGH);
      }
    } else {
      lcd.clear();
      lcd.print("Fingerprint not matched");
    }

    delay(2000);
  } else {
    lcd.clear();
    lcd.print("Place finger for enrollment");
    finger.addModel();
    delay(2000);
  }
}

when I compile this code, error like this "Compilation error: conversion from 'const uint8_t {aka const unsigned char}' to 'String' is ambiguous"
please solve this problem OTL

Your question is more than likely not related to a problem with the IDE; hence moved to a more suitable location on the forum.

I'm not sure but see if changing

lcd.print("Alcohol: " + String(alcoholConcentration, 2));

to

lcd.print("Alcohol: ");
lcd.print(alcoholConcentration, 2);

solves the issue.

PS

There is not such a thing; in future please post the complete error message using code tags; IDE 1.x (where you posted this) gives a button "copy error messages" at the right above the output window to make life easy for you; the only thing it does not do is adding the code tags.

C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino:9:37: error: conversion from 'const uint8_t {aka const unsigned char}' to 'String' is ambiguous
In file included from C:\Users\���¿�\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:232:0,
from C:\Users\���¿�\AppData\Local\Temp\arduino\sketches\CBEFCE95EFD67073B85F38719F1EAF5C\sketch\sketch_nov23a.ino.cpp:1:
C:\Users\���¿�\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/WString.h:61:2: note: candidate: String::String(const __FlashStringHelper*)
String(const __FlashStringHelper str);
^~~~~~
C:\Users\���¿�\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/WString.h:61:2: note: conversion of argument 1 would be ill-formed:
C:\Users\���¿�\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/WString.h:59:2: note: candidate: String::String(const char
)
String(const char *cstr = "");
^~~~~~
C:\Users\���¿�\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/WString.h:59:2: note: conversion of argument 1 would be ill-formed:
In file included from C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino:4:0:
C:\Users\���¿�\Documents\Arduino\libraries\MQUnifiedsensor\src/MQUnifiedsensor.h:16:5: note: initializing argument 1 of 'MQUnifiedsensor::MQUnifiedsensor(String, float, int, int, String)'
MQUnifiedsensor(String Placa = "Arduino", float Voltage_Resolution = 5, int ADC_Bit_Resolution = 10, int pin = 1, String type = "CUSTOM MQ");
^~~~~~~~~~~~~~~
C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino: In function 'void loop()':
C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino:22:14: error: 'class Adafruit_Fingerprint' has no member named 'fingerPresent'; did you mean 'fingerSearch'?
C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino:26:16: error: 'class Adafruit_Fingerprint' has no member named 'verify'
C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino:30:50: error: 'class MQUnifiedsensor' has no member named 'read'
C:\Users\장태영\AppData\Local\Temp.arduinoIDE-unsaved20231023-26684-lk55mw.ybhbj\sketch_nov23a\sketch_nov23a.ino:51:12: error: 'class Adafruit_Fingerprint' has no member named 'addModel'; did you mean 'loadModel'?

exit status 1

Compilation error: conversion from 'const uint8_t {aka const unsigned char}' to 'String' is ambiguous

This is all that error.
and I try using this code

lcd.print("Alcohol: ");
lcd.print(alcoholConcentration, 2);

but it doesn't work
can you help me please..?
really need someone help

Explain what that means. What did you expect to happen, and what happened instead?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.