Raspberry Pi to Arduino GPIO wire length - arduino

I want to connect a Raspberry Pi 3 to an Arduino via there IO pins so the Pi can send control commands to the Arduino.
The distance between the two devices is around 10 feet (around 3 meters), is this viable using the IO port or is the gap too long? I haven't been able to find the specific specifications for this when I searched.
Thank you in advance xx

The length of the wires is not an issue, but be careful because the GPIO pins of the Pi are 3.3V and the pins of the Arduino are 5V. So be sure to use a level converter between the Pi and the Arduino or you will probably fry your Raspberry.
If you want to send the commands over Serial you also have to connect the RX of the Pi to the TX of the Arduino and vice versa.

Related

I2C on ESP32 or Arduino: what's the max number of slaves using the BMP388 sensor

BMP388: what is the maximum of slave addresses in I2C mode
In I2C mode with one master how many BMP388 as slave can be connect to an Arduino UNO?
From the datasheet I understand that there are only 2 adresses possible in I2C mode (0x76 or 0x77) as designated by bit 7 in the device address and configured via the SDO (pin 5) port to ground or plus.
In SPI mode, as I hope to understand well from the datasheet, it's up to 128 BMP388 addresses.
My questions are:
-Am I understanding well that in I2C mode the maximum number of slaves is two?
-Of course I can connect a lot of BMP388's in series to the Arduino, but how can I address them in I2C mode. Or should I use SPI mode?
-Is there any documentation, except the datasheet, that makes this more clear?
-Is there any example Arduino code for the I2C situation?
You understood the i2c addressing correctly. There can only be 2 addresses for
BMP388 controlled by SDO pin in i2c mode.
If you want to use more than 2 BMP388 units with a single microcontroller, go with SPI. You can use as many BMP388 units as you have GPIO pins on microcontroller to control Slave Select pin.
This is the example from Adafruit BMPxxx library.
Here is permalink to the line where you can pass Slave Select (CS) pin of each unit to each unique object.
Later in the code you can use each object of the Adafruit BMPxxx library to get the readings.

Interrupt based communication between arduino and raspberry pi

I have 6 Arduinos and 1 raspberry pi B+.
I need Arduino to communicate with pi based on interrupts. For example, if 1 Arduino has to communicate with pi, it sends interrupt and then pi asks the Arduino to send data. On the other hand, Pi can communicate directly without any interrupt.
You can configure the Raspberry GPIO pins as Rising/Falling edge interrupts.
Raspberry GPIO
Then you can use one of the digital ports in your Arduino to generate Rising or Falling edge so it will trigger the Raspberry interrupt.
If you have several Arduinos and you don't want to waste several Raspberry pins, you can connect all Arduinos to a single GPIO pin of the Raspberry (using pullup resistors so when one Arduino Triggers you will not create a short circuit).
You will then need some kind of protocol for the Raspberry to know which Arduino triggered the Interrupt.
Hope this helps

Power on a Raspberry Pi with Arduino

I am working on a project which involves to power on/off a Raspberry Pi with an Arduino. In fact the project contains several sensors like a motion sensor and the Arduino will be supplied with a 10kmA battery.
The motion sensor is connected on the Arduino device.
Once the sensor detects a movement, the Arduino will receive the instruction to deliver the 5V to the Raspberry Pi.
How can I supply the Raspberry Pi with the Arduino? GPIO? USB?
I have already seen solutions to power an Arduino with a Raspberry Pi, but never the opposite.
Powering on is easy: just use a small relay that you control with your Arduino, and which switches the 5v from the battery to the RPi.
Shutting down the Pi should be done in two steps:
Setting a GPIO connection to the GPIO header of the Pi, that "sends" the signal to shut down. The RPi must receive this signal as an interrupt on the GPIO and can execute a shutdown-script
The second step should be to wait until the RPi has completely shut down. Maybe you can observe that with the help of the RPi LEDs or something like that (otherwhise, an unclean solution would be to wait XX seconds). After you know that the Pi is shut down, you can open the 5V relay again.

Program an Arduino from a Raspberry Pi using UART

I am trying to program an Arduino mounted on a breadboard using a Raspberry Pi.
For the setup of the Arduino I have been following this tutorial, except from the USB-serial device. Instead I have the Raspberry Pi connected through a level converter. I designed the level converter myself using a 4066 analog switch and an op-amp as a voltage follower to supply a stable 3.3V voltage. The 3.3V from the Pi is converted to 5V on the Arduino pins, and vice versa. I am not getting any response from running avrdude in the shell or through the Arduino IDE on the Pi.
Both the Pi and the Arduino are driving their TX pins to high value (3.3V and 5V). The Arduino has been flashed with a bootloader in a stk500 development board. The command I have been running is:
/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega8 -carduino -P/dev/ttyAMA0 -b9600 -D -Uflash:w:/tmp/build4533291593992176675.tmp/sketch_mar21a.cpp.hex:i
LED connected to pin13 flashed aproximately every 6 seconds.
Can anyone tell me how I can get the Raspberry Pi talking to the Arduino?
Fairly stumped. First thing I'd try is just to check that RX/TX communication is working. Write a simple program to read and write on arduino pins 2 and 3 and something similar on the PI.
Other things to look at http://arduino.cc/en/Main/StandaloneAssembly. You might be able to do things using AVR see http://arduino.cc/en/Hacking/Programmer.
There is a new arduino stack exchange https://arduino.stackexchange.com/ it might be worth asking there.

How do I wire a 9 pin serial connection to an Arduino?

My question is pretty straightforward. I've got a big old machine that has an RS-485 connection on the back and I've got a converter from RS-485 to 9 pin serial.
The device I'm connecting to sends out an ACK signal to see if anything is connected. How do I wire up my Arduino (Uno) to the 9 pin serial connector so that I can read the ACK (and in future write back) and display the ACK signal in the Serial Monitor?
I would first check the voltage of the data lines coming from the RS-485 converter. The arduino ports are expecting 0 to 5 volts. Also, look-up the standard for RS-485 to determine what should be on the lines from the RS-485.
Notice, the arduino does NOT directly implement an RS-232 port. Rather, it has a USB port for connecting to a PC. I know that the RS-232 connection does NOT use TTL or 0 to 5V signals, and would question what signal levels are produced by an RS-485.
If the RS-485 does NOT generate 0 to 5 volts, then you will need to get an arduino RS-485 shield.
Finally, in fact, this is what you need to do. I just searched on "RS-485 Arduino" and found multiple hits.
Now, this is the good news, because once you have installed a RS-485 shield then you connect the shield to pins 1&2 on the Arduino and you have a serial connection!!
In most cases you need to wire only RX, TX and Ground signals (RX of Arduino to TX of RS-232 and vice versa). But it really depends on your RS-485 converter, if you need any additional lines. If this converter is half-duplex, may be you will also need to control it with DTR signal. You can use any digital IO on UNO then, and control it in software. Also you need to know the speed of serial port of this old machine, and configure UNO serial port accordingly.

Resources