// Agrinovo ULM-100 ultrasonic level meter // Prints level or distance every 5 seconds. // // Sensor terminals // 1 supply +, 24 V DC // 2 supply ground, joined to the board's ground // 5 RS485 A // 6 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/sillo/ulm-100-ultrasonic-level-meter/ #include #include const int DE_PIN = 4; // transceiver DE and RE, tied together AgrinovoBus bus(AGRINOVO_PORT, DE_PIN); AgrinovoULM100 sensor(bus); // Modbus address 1 void setup() { Serial.begin(115200); agrinovoPortBegin(9600); bus.begin(); } void loop() { if (sensor.read()) { Serial.print("Level or distance: "); Serial.print(sensor.level(), 0); Serial.println(" cm"); } else { Serial.println(sensor.errorText()); } delay(5000); }