Hi,
So far I have connected a 3 in 1 sensor to an arduino yun rev 2. The sensor works on I2C communication.
My code so far allows me to connect to the arduino and read the values in the serial monitor. The next step is setting up modbus tcp on the arduino so I can connect it to a field agent that will read the data.
I only really have basic knowledge on arduinos so learning as I go along here. I've seen many libraries where people have connected sensors through digital or analogue to modbus tcp. But not many examples with I2C and modbus tcp
Any help is appreciated.
Thanks
/*
This example prints the current CO2 level, relative humidity, and temperature in C.
Click here to get the library: http://librarymanager/All#SparkFun_SCD30
*/
#include <Wire.h>
#include "SparkFun_SCD30_Arduino_Library.h"
SCD30 airSensor;
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.println("SCD30 Example");
airSensor.begin(); //This will cause readings to occur every two seconds
}
void loop()
if (airSensor.dataAvailable())
{
Serial.print("co2(ppm):");
Serial.print(airSensor.getCO2());
Serial.print(" temp(C):");
Serial.print(airSensor.getTemperature(), 1);
Serial.print(" humidity(%):");
Serial.print(airSensor.getHumidity(), 1);
Serial.println();
}
else
Serial.println("No data");
delay(1000);
}