Hello everybody, I have a sketch that runs fine on Arduino IDE. But i am trying to get it to work on IoT. I did go on IoT Library Manager and included AVR EEPROM library but I get the same error.
Here is the code. Thank you. Here is the error.
Start verifying
In file included from /tmp/1760111536/PH_ORP_oct09a/PH_ORP_oct09a.ino:3: /mnt/create-efs/webide/34/0a/340a6319dbe3aff94d7e2c9e1e026563:jimmy747/libraries_v2/EEPROM/src/EEPROM.h:25:10: fatal error: avr/eeprom.h: No such file or directory #include <avr/eeprom.h> ^~~~~~~~~~~~~~ compilation terminated. Multiple libraries were found for "EEPROM.h" Used: /mnt/create-efs/webide/34/0a/340a6319dbe3aff94d7e2c9e1e026563:jimmy747/libraries_v2/EEPROM Not used: /home/builder/opt/libraries/hello_drum_0_7_7 Not used: /home/builder/opt/libraries/arduino_nvm_0_9_1 Not used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/EEPROM Error during build: exit status 1
In file included from /tmp/1760111536/PH_ORP_oct09a/PH_ORP_oct09a.ino:3: /mnt/create-efs/webide/34/0a/340a6319dbe3aff94d7e2c9e1e026563:jimmy747/libraries_v2/EEPROM/src/EEPROM.h:25:10: fatal error: avr/eeprom.h: No such file or directory #include <avr/eeprom.h> ^~~~~~~~~~~~~~ compilation terminated. Multiple libraries were found for "EEPROM.h" Used: /mnt/create-efs/webide/34/0a/340a6319dbe3aff94d7e2c9e1e026563:jimmy747/libraries_v2/EEPROM Not used: /home/builder/opt/libraries/hello_drum_0_7_7 Not used: /home/builder/opt/libraries/arduino_nvm_0_9_1 Not used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/EEPROM Error during build: exit status 1
// EEPROM for avr - Version: Latest
#include <EEPROM.h>
#include "thingProperties.h"
#include "DFRobot_PH.h"
#define ESPADC 4096.0 //the esp Analog Digital Convertion value
#define ESPVOLTAGE 3300 //the esp voltage supply value
#define PH_PIN 35 //the esp gpio data pin number
#define orpPin 34 //ORP sensor
#define ArrayLenth 40
#define VOLTAGE 5 //system voltage
#define OFFSET 0 //zero drift voltage
double orpValue;
float voltage, phValue, temperature = 20;
int orpArray[ArrayLenth];
int orpArrayIndex=0;
int Rounded = 0;
int Positif=0;
DFRobot_PH ph;
float voltage,phValue,temperature = 25;
double avergearray(int* arr, int number){
int i;
int max,min;
double avg;
long amount=0;
if(number<=0){
printf("Error number for the array to avraging!/n");
return 0;
}
if(number<5){ //less than 5, calculated directly statistics
for(i=0;i<number;i++){
amount+=arr[i];
}
avg = amount/number;
return avg;
}else{
if(arr[0]<arr[1]){
min = arr[0];max=arr[1];
}
else{
min=arr[1];max=arr[0];
}
for(i=2;i<number;i++){
if(arr[i]<min){
amount+=min; //arr<min
min=arr[i];
}else {
if(arr[i]>max){
amount+=max; //arr>max
max=arr[i];
}else{
amount+=arr[i]; //min<=arr<=max
}
}//if
}//for
avg = (double)amount/(number-2);
}//if
return avg;
}
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
EEPROM.begin(32);//needed to permit storage of calibration value in eeprom
ph.begin();
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ReadPH();
PH=phValue;
ReadOrp();
ORP=Rounded;
delay(1000);
ArduinoCloud.update();
}
void ReadPH()
{ voltage = analogRead(PH_PIN) / ESPADC * ESPVOLTAGE; // read the voltage voltage = rawPinValue / esp32ADC * esp32Vin
phValue = ph.readPH(voltage, temperature); // convert voltage to pH with temperature compensation
ph.calibration(voltage, temperature); // calibration process by Serail CMD }
}
void ReadOrp()
{
static unsigned long orpTimer=millis(); //analog sampling interval
static unsigned long printTime=millis();
if(millis() >= orpTimer)
{
orpTimer=millis()+20;
orpArray[orpArrayIndex++]=analogRead(orpPin); //read an analog value every 20ms
if (orpArrayIndex==ArrayLenth) {
orpArrayIndex=0;
}
orpValue=((30*(double)VOLTAGE*1000)-(75*avergearray(orpArray, ArrayLenth)*VOLTAGE*1000/1024))/75-OFFSET; //convert the analog value to orp according the circuit
}
if(millis() >= printTime) //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
{
printTime=millis()+800;
//Serial.print("ORP: ");
//digitalWrite(LED,1-digitalRead(LED));
int Positif=(orpValue*-1);
Rounded=round(Positif/100);
}
}