Transferring Data of Sensors from one Arduino to another Arduino/Controllino

Hi. I am having problem to transfer my data obtained from sensor through Arduino Mega 2560 to Controllino Maxi.

I am planning to use <Wire.h> library. Is it possible for anyone to get advice from anyone for it?

What have you tried so far ?

The Wire library has examples that can help you get started.

a bit more information would help us help YOU :wink:

  1. Is it correct to assume that you are successfully acquiring you sensor data connected to your Arduino Mega?

  2. Your issue lies with transfering data between the Mega and Maxi controllers. is this correct?

  3. the Wire library is for I2C communication. Are you trying to transfer data between the controllers over I2C?
    If that is the case, I2C works best when units are close to each other. For longer distances, Serial communication (or RS485 of even longer distances) would probably be better suited to transfer data between the controllers.
    You may want to have a look at this good tutorial on using Serial communication for transfering data between controllers:
    Serial Input Basics

hope that helps...

I am so relief for getting some response here. And I am sorry for the insufficient info on my issue.

Currently, the task I am working for is using an ultrasonic sensor called JSN-SRO4T-V3.0 and Arduino Mega 2560. I am using Mode 0 for the sensor.

  1. Yes, I have managed to get data that I wanted to from the sensor using Arduino Mega 2560. ( Supposedly I was tasked to use the the sensor with Controllino Maxi. However it doesn't work. Leading me to switch it to Arduino Mega 2560 and it works.)

  2. Yes, that's correct. I wanted to get the data transfer to Controllino Maxi. I tried to do some basic tutorial like in the following link ;[https://create.arduino.cc/projecthub/chandran0303cn/transferring-data-from-one-arduino-to-another-cdd58f] and it's okay. Tried to implement it to mine but I got lost. Any other github/project hub here that I can learn for to do it?

  3. I just knew about this. I am planning to use the sensor in a long distance. Yes, I've thought of using RS485 ports but the RS485 port for Controllino Maxi is unavailable as I have used it for another Modbus Rtu sensor. My question for this concern, is it possible to use SPI library instead of Wire library or RS485?

I would be glab to provide more info if needed.

You could set your Mega 2560 up as a Modbus RTU slave device and then use the same RS485 bus that you are already using. In case you didn't already know, you can have more than 1 device on an RS485 bus.

Not a very complete problem statement. Perhaps you would be better off getting the sensor work with the Controllino Maxi than introducing complexities a second processor.

I get what you've said. I have tried it but didn't work. Should I try to post my Arduino sketch for the ultrasonic sensor here? So that you guys can advice me on which part have I done wrongly?

Cause in my understanding, Arduino Mega 2560 and Controllino Maxi actually have a quite similar physical pin. And I should be able to get the sketch ran on Arduino Mega 2560 runs on Controllino Mega but it doesn't work.

Is there any reference that you have with you that I can refer to?

Thank you for this @groundFungus . But I just knew that Wire library can be used for short distance only. So yeah. Thanks again!

Have a read of this web page:

Please do.

I would also provide a simple drawing of how the sensor is connected to the Arduino/Controllino.
Describe in detail what the issues were with the execution of the code on the Controllino. Post any Serial output if there was any.

Is this a reference for on how to connect multiple rs485 modbus serial communication onto one rs485 port (cause in my understanding there is only 1 serial port for RS485 on Controllino Maxi ?

The web page I linked to discusses using an Arduino as a Modbus slave device using RS485. The Controllino Maxi may only have 1 RS485 port, but you can daisy-chain quite a few RS485 Modbus devices together on the 1 port.

Here's an image that I found on the Innon website that should demonstrate how the devices are connected:


Your Controllino Maxi takes the place of the big device on the left.

Here is the code that I used for the ultrasonic sensor;

<

/*
   JSN-SRO4T-V3.0 Ultrasonic Sensor Mode 0 Demo
 srt04-mode0.ino
 Uses JSN-SRO4T-V3.0 Ultrasonic Sensor
  Displays on Serial Monitor
  Mode 0 is default mode with no jumpers or resistors (emulates HC-SR04)
  DroneBot Workshop 2021
 https://dronebotworkshop.com
*/

// Define connections to sensor
#define TRIGPIN 11
#define ECHOPIN 10

// Floats to calculate distance
 float duration, distance;

 void setup() {
 // Set up serial monitor
 Serial.begin(9600);

 // Set pinmodes for sensor connections
 pinMode (ECHOPIN, INPUT);
 pinMode (TRIGPIN, OUTPUT);
}

 void loop() {

 // Set the trigger pin LOW for 2us
 digitalWrite(TRIGPIN, LOW);
 delayMicroseconds (2);

 // Set the trigger pin HIGH for 20us to send pulse
 digitalWrite(TRIGPIN, HIGH);
 delayMicroseconds (20);

 // Return the trigger pin to LOW
 digitalWrite(TRIGPIN, LOW);

 // Measure the width of the incoming pulse
 duration = pulseIn(ECHOPIN, HIGH);

 // Determine distance from duration
 // Use 343 metres per second as speed of sound
 // Divide by 1000 as we want millimeters

 distance = (duration / 2) * 0.343;

 // Print result to serial monitor
 Serial.print("distance: ");
 Serial.print(distance);
 Serial.println(" mm");

 // Delay before repeating measurement
 delay(1000);
}```

/>

Ohh really? We can do that?

Yes. I just edited my previous post whilst you were replying. See the image in reply #14.

The dronebot tutorial seems pretty comprehensive
https://dronebotworkshop.com/waterproof-ultrasonic/

If the Controllino is Arduino compatible as it claims, then the sensor should work like it does on the Mega.

I would try using the device in Mode1 and Serial1 input to the Mega/Controllino.

Perhaps there is something strange about pulseIn() on the Controllino. Have you tested it with a different external signal.
Perhaps you can use the Mega to send a pulse to the Controllino and see if you can read it.

Okay I see there's possibility for this. But I am still clueless on how to control the device/sensor since we're getting some data right? It is possible to get data from multiple at one type if we code it properly?

Yeah supposedly. But it doesn't work.

I would love to try this right away but I don't have solder tool with me at my room. As to use Mode 1, a blob is needed for it.

May I know what did you mean by external signal?