// Agrinovo O2-100 soil oxygen sensor // Prints oxygen every 5 seconds. // // Sensor cable // Red supply +, 7-24 V DC // Black supply ground, joined to the board's ground // Yellow RS485 A // Green RS485 B // // The board talks to the sensor through an RS485 transceiver (MAX485 or // similar). AgrinovoDefaultPort.h lists the serial pins used on each board. // // https://agrinovo.io/products/sensors/soil/soil-oxygen-sensor/ #include #include const int DE_PIN = 4; // transceiver DE and RE, tied together AgrinovoBus bus(AGRINOVO_PORT, DE_PIN); AgrinovoO2100 sensor(bus); // Modbus address 1 void setup() { Serial.begin(115200); agrinovoPortBegin(9600); bus.begin(); } void loop() { if (sensor.read()) { Serial.print("Oxygen: "); Serial.print(sensor.oxygen(), 1); Serial.println(" %VOL"); } else { Serial.println(sensor.errorText()); } delay(5000); }