I copied it and paste it into the code section in particle WEB IDE.
When I try to verify the code it states DFRobot_EC.h: No such file or directory
How do I include this library?
Here is the full code
/*
* file DFRobot_EC.ino
* @ https://github.com/DFRobot/DFRobot_EC
*
* This is the sample code for Gravity: Analog Electrical Conductivity Sensor / Meter Kit V2 (K=1.0), SKU: DFR0300.
* In order to guarantee precision, a temperature sensor such as DS18B20 is needed, to execute automatic temperature compensation.
* You can send commands in the serial monitor to execute the calibration.
* Serial Commands:
* enter -> enter the calibration mode
* cal -> calibrate with the standard buffer solution, two buffer solutions(1413us/cm and 12.88ms/cm) will be automaticlly recognized
* exit -> save the calibrated parameters and exit from calibration mode
*
* Copyright [DFRobot](https://www.dfrobot.com), 2018
* Copyright GNU Lesser General Public License
*
* version V1.0
* date 2018-03-21
*/
#include "DFRobot_EC.h"
#include <EEPROM.h>
#define EC_PIN A1
float voltage,ecValue,temperature = 25;
DFRobot_EC ec;
void setup()
{
Serial.begin(115200);
ec.begin();
}
void loop()
{
static unsigned long timepoint = millis();
if(millis()-timepoint>1000U) //time interval: 1s
{
timepoint = millis();
voltage = analogRead(EC_PIN)/1024.0*5000; // read the voltage
//temperature = readTemperature(); // read your temperature sensor to execute temperature compensation
ecValue = ec.readEC(voltage,temperature); // convert voltage to EC with temperature compensation
Serial.print("temperature:");
Serial.print(temperature,1);
Serial.print("^C EC:");
Serial.print(ecValue,2);
Serial.println("ms/cm");
}
ec.calibration(voltage,temperature); // calibration process by Serail CMD
}
float readTemperature()
{
//add your code here to get the temperature from your temperature sensor
}
If the library doesn’t already exist in the library repository of Web IDE ( ) you’d need to add some extra files to your project via this button in the top right corner and copy/past the respective code for .h and .cpp.
The original Arduino library may require some slight porting.
You have named your new files lib1.h and lib1.cpp but you are including DFRobot_EC.h - naming the new files the way you intend to include them or include them as you have named them would be a good idea
When done that right, you should remove all #include <EEPROM.h> lines - as they are not needed with Particle.h already included - and your code should build.
Thank you for the advice now I cancelled all the include <EEPROM.h> lines. Now the IDE is complaning about not including the 'EEPROM_read' was not declared in this scope and 'EEPROM_write' was not declared in this scope shold i also delete does?
It’s not complaining on my side tho’
These macros are defined in DFRobot_EC.cpp and that should also be the only place where they are used, so I wouldn’t see why you get these errors (unless you also deleted these definitions )
However, you can use any serial terminal program (e.g. PuTTY) or even Particle CLI particle serial monitor --follow to see the output of the device - although the latter is only a monitor and cannot send data to the device.
Hi ScruffR, thank you so much for all the guidance! I have now tried to edit the serial.print out with the Particle.publish. I now get alt of error messages when I try to compile?
You may want to read the docs for Particle.publish() again.
The first and second parameter can only be string types. You are using numeric datatypes - that’s what the error messages mean: “There is no function that would take these types there”.
And you can only publish at a rate of 1 publish per second on average (burst of 4 back to back publishes is possible with a 4 second cool down).
What you want to do there would be best done with a single publish like this