Portenta+breadboard i2c connection to Nano schematic need

Hey folks, again I need your help. I am trying to connect my Portenta H7 lite to Arduino Nano using I2C. At this point I understand that Portenta use 3.3 V white Nano works on 5. So I took a converter and did try this.(uploaded image) unfortunately It did not work, I also tryed on the tree i2c slots, and also connected voltage to them, but nothing seems to work. Can anyone assist me? What is the right way to hook them up? Do I need to add these pull up resistors? In Youtube i saw a video of one making a connection between Raspberry PI and Arduino, at one point he stated that the master is giving the voltage, so one can safely connect 3.3v master to 5v slave. Any help will be much appreciated, I am kind a lost here.

Thanks!

The level converter module cannot work because it has no power. You need to connect HV to 5V pin of the Nano and LV to to 3.3V pin of the Portenta.

But there is an even better solution. Don't connect them. Using 2 Arduino in a project is almost always unnecessary and always difficult.

Please explain why you want to do this and we can suggest better ways to achieve it.

1 Like

Hey Paul thanks, I did try that. I was not sure about it, since both Arduinos are connected to the PC. But I will try it again do you think that it will be enough?

I wish to use I2C since the plan is to hook up rotary encoder, maybe even two, and GPS on one Arduino, that is separate from the system. I wish the separation for two reasons. One is to keep these sensors about 1 meter above the Portenta, so that hey work better (a bit higher GPS antenna, girouette, and if possible anemometer). The other reason is that I wish Portenta to be free for course calculations (it is for a boat). M4 will be used for controlling the actuators. I am also hoping for one more I2C connection with ESP SIM800ML.

Enough for what?

User longer wires. No need for Nano.

2 encoders and a GPS will use a few % of the computing power of Nano. Let's be pessimistic and assume it uses 10% of the Nano's computing power.

Portenta has at least 50x more computing power than Nano, so 10% of a Nano's computing power will be, at most, 0.2% of the Portenta's computing power. Do you think that will have a noticeable effect on the course calculations? I suspect the Nano could do those calculations fast enough with the other 90% of its computing power. We are taking about a boat, not a supersonic jet.

Sorry if this sounds dismissive. My point is that your Portenta is already a huge overkill for the project. Adding another Arduino will only make your project more complex and difficult for you to achieve successfully.

1 Like

Enough to make it work, I was wondering will there be need of pull-up resistors. Unfortunately it did not work :frowning: I added the recommended connection, and tested it on all three slots for I2c but I could not make it work.
About the Nano: it is a bit off topic. My mind is made, and I do not really plan to change the setup. Yah it is complicated, and make matters harder, but where would we be if we sicked only to known, and working solutions? My reasons are this: overkill - probably, but resources are still limited. There are interruptions from the encoders, both will move a lot, one will move at pretty good speed. Keep them aside = good idea plus Portenta needs to calculate navigation that works with wind direction, wind speed, mast position, rudder position, travelled distance, bearing, possible bearing, current position, destination, and many more. Also I like to keep my options open for camera, maybe sound recorder, and others.
No problem if sounds dismissive, I am happy for the opportunity to chat on the project, and respect direct people.

The Portenta H7 Lite has a STM32 chip with two cores and Arduino is a layer on top of Mbed.
You can run a beautiful multitasking system, and still use Arduino code with a few Mbed multitasking additions. That would be a good solution.

Do you have the newest versions of the software ?
Was there something special to do to make the I2C bus work and are there also I2C chips on the "Lite" board ? I forgot.
Can you run your Arduino Nano at a lower voltage ? So the 5V pin has 3.3 to 3.6 V ?
Then you can test it without the level shifter.

As soon as you run the Wire.begin(0x20) on the Nano, then it can be seen with a I2C Scanner sketch.

void setup()
{
  Wire.begin(0x20);
}

void loop() {}

Then run a Scanner sketch in the Portenta in the first I2C bus.
Do you have another I2C module or sensor ? Can you check if a I2C Scanner on the Portenta can see something on the I2C bus at all ?

If you want a working project, then follow the KISS rule.
We see projects fail on this forum that has two boards with a I2C bus in between. The I2C is a weak bus, because the high level is made with the pullup resistor. With long wires and motors, it might never work. The software has to be just right to use a I2C bus between two boards. It still would be a bad solution. The I2C bus was not designed for communication between processors.

Conclusion: You can choose between "good" and "bad". If only every decision in life was that simple :wink:

1 Like

Thanks Koepel, I got your point.

There are 3 I2C chips on Lite but I do not know if they have a pull up resistors, I think they do not. Also I do not know if there is something special to it.
I am not sure if Nano can run on lower voltage, but in the spirit of the KISS rule maybe I should try with some 3.3 V Arduino. However I have seen the video tutorial on DroneBot Workshop, in YouTube, he states there that the master command the voltage, so it should be save to connect 3.3 V master to 5V slave, but anyhow he use logic level converter to make a connection between Raspberry PI, and Arduino Uno, and I would not risk to connect them directly. The scanner example, is very nice idea, at least I will know that it is not code issue!

Would you please suggest another way for a communication between processors?

For the separate Arduino: the issue is about multitasking, but (as I understand it) more about interruptions. The rotary encoders continuously interrupt the processes with their input. One of them is rotated from the wind, the small radius of the mechanism is equal to fast RPS. I forgot how much divisions it have, but I think they were 720, so this is 720 interruptions per rotation, equals to over 2000 interruptions per second in slow wind of 1 meter per second, and that easily gets to 5 or more, which is 10 800 interruptions per second form only one rotary encoder+there is the GPS that is constantly spilling its data, and another encoder. So this could be problematic. I understand that a lot can be done, encoder with lower number of divisions, bigger radius of the device, hooking up the GPS to the Lite, get ride of the anemometer. However at this point I recognize that the need to connect additional board/processor to the system, and learning how to do it will make me more versatile with this or other project. So at the end of the story it is not only about the project, but also a learning endeavor.

One hundred percent pure nonsense :poop:

Communication can be done with Serial RX / TX. Those are strong signals, and the Serial library uses interrupts with a buffer. That is a normal situation, but only with a hardware Serial port. If you use SoftwareSerial, then all the interrupt response and timing has gone overboard.

About ten-thousand pulses per second ? Are you sure ? Can you confirm that ? I'm thinking about a few hundred maximum.
Even ten-thousand interrupts should be no problem for the Portenta and reading the GPS data is no problem at all.
There happens to be a good library for the Nano to measure a frequency: https://www.pjrc.com/teensy/td_libs_FreqCount.html.

Meanwhile, you could keep trying to make the I2C bus work. I suppose that you going to add a few sensors anyway.

Do you use the right initialization code ? The Arduino IDE has sometimes extra settings for the hardware, which are automatically included. That is why I asked if you use the newest software.

1 Like

Tx again Koepel,
I will see to it.
About 10 000 pulses per second, yes my calculations are a bit wrong. The circumstance of the rotator is 45 cm, lets round it up to 50, this is 2 rotation per second in wind speed of 1 meter per second. That is 1440 pulses/interuptions per second, and 7200 for 5 mps wind speed. However It just so happens that I took this encoder to measure wind direction, so it have a bit better accuracy. But in anemometer I just need to measure one tick, and time needed to reach the same (360 degree rotation). So something with very low number of ticks should do the job, is that what you mean with "few hundred maximum"?
I will test the library.
OK this drastically change the situation, I guess that I will (tray) to create board connection using Serial RX / TX. And make I2C with something with same voltage, so that I try with the pull up resistors. I have TTGO T-Call ESP32 SIM800L maybe I can try with it.

I am using Arduino IDE 2.0.2, it seems to be the last version.

I was just guessing for the wind speed pulses.

The I2C level shifter has pullup resistors on both sides (on the HV side and on the LV) side.

Keep the wires of the I2C bus short (no more than a meter) and keep SDA away from SCL. The I2C bus can not deal with crosstalk between SDA and SCL.

A I2C Scanner sends a command to write data to a Slave, with no data-bytes. When the Slave acknowledges to its address then the Master knows that there is a Slave at that address. However, Arduino is on top of Mbed and Mbed can not send a I2C write command with zero data-bytes. I don't know the latest status of this.

1 Like