Compile Error for Nano IOT 33, but not for Arduino Uno

Wanted to use the VernierLibTutorialAnalogRead example code for the Arduino Nano IOT 33. The code won't compile for the Nano IOT 33, but does compile for the Uno. Can someone help me fix the error below to allow it to work for the Nano IOT 33?

C:\Users\Lauren Yamthe\Documents\Arduino\libraries\VernierLib\src\VernierLib.cpp: In member function 'void VernierLib::autoID()':

C:\Users\Lauren Yamthe\Documents\Arduino\libraries\VernierLib\src\VernierLib.cpp:74:19: error: invalid conversion from 'const char*' to 'char' [-fpermissive]

_sensorName[16]="1234567890123456"; // I am using 16 characters here, plus terminator.

^~~~~~~~~~~~~~~~~~

C:\Users\Lauren Yamthe\Documents\Arduino\libraries\VernierLib\src\VernierLib.cpp:75:18: error: invalid conversion from 'const char*' to 'char' [-fpermissive]

_shortName[12]="shortName ";//12 characters on name, plus terminator.

^~~~~~~~~~~~~~

C:\Users\Lauren Yamthe\Documents\Arduino\libraries\VernierLib\src\VernierLib.cpp:76:19: error: invalid conversion from 'const char*' to 'char' [-fpermissive]

_sensorUnits[7]="Units ";//7 characters units, plus terminator.

^~~~~~~~~

exit status 1

Error compiling for board Arduino NANO 33 IoT.

Post code, not pictures of code.

_sensorName[16]="1234567890123456"; // I am using 16 characters here, plus terminator. Seventeen into sixteen does not go.

How is this a bootloader issue?

Thread moved as requested.

That library is far from being usable. The error will produce warnings on an UNO, but only because the default compiler options used by the IDE for the UNO are set to be very permissive of errors.

TheMemberFormerlyKnownAsAWOL:
Post code, not pictures of code.

_sensorName[16]="1234567890123456"; // I am using 16 characters here, plus terminator.

Seventeen into sixteen does not go.

How is this a bootloader issue?

Here is the code:
#include "VernierLib.h" //include Vernier functions in this sketch
VernierLib Vernier; //create an instance of the VernierLib library

float sensorReading; //create global variable to store sensor reading

void setup() {
Serial.begin(9600); //setup communication to display
Vernier.autoID(); //identify the sensor being used
}

void loop() {
sensorReading = Vernier.readSensor(); //read one data value
Serial.print(sensorReading); //print data value
Serial.print(" "); //print a space
Serial.println(Vernier.sensorUnits()); //print units and skip to next line
delay(500); //wait half second
}
I counted 16 characters, do I need to change it to _sensorName[17] ?

david_2018:
That library is far from being usable. The error will produce warnings on an UNO, but only because the default compiler options used by the IDE for the UNO are set to be very permissive of errors.

Does that mean that this library will never work for the Nano 33 IOT???

Remove these lines from the library .cpp file, they are useless and wrong:

  _sensorName[16]="1234567890123456"; // I am using 16 characters here, plus terminator.
  _shortName[12]="shortName   ";//12 characters on name, plus terminator.
  _sensorUnits[7]="Units  ";//7 characters units, plus terminator.
  _sensorName[17]='\0'; // THESE MAY NOT BE NECESSARY
  _shortName[13]='\0';
  _sensorUnits[8]='\0';

Edit: this library contains some dangerous mistakes, like buffer overflows. Fix it, or don't use it...

I’ve made a few modifications to the library to hopefully get it working a bit better. If anyone with the actual hardware would like to test this out here are the files.

Still needs the addition of a begin() function to implement pinMode correctly, but that would break all the examples.

VernierLib.h (2.51 KB)

VernierLib.cpp (23.9 KB)

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