Raspberry PI and Arduino / ESP working together

Hi guys!

I'm trying to make a small inventory control system as a new project. My idea is to have a Raspberry PI 4b with a touchscreen as the user interface. Attached are modules with lockers and locks. These need to open via the user interface. I will have a program running on the raspberry that talks to an API to register the people taking stuff.

I had several ideas, first would be to have the raspberry run MQTT and a WiFi network to access all the arduinos. However that option is not good, we don't want a WiFi network. So my next guess would be I2C. Every module (Arduino/ESP with lock and led light) will have a dipswitch (maybe) to identify itself.

There are some things I would like to have to work as well:

  • Registration of the object that has been placed in the locker
  • Available / Unavailable light in the locker
    Maybe more...

I'm not sure if the plan like I have now might be a good one. I would love to hear your suggestions!

The I2C bus is not plug and play, and it is a bad idea to use the I2C bus for communication between processors.
Could you draw a picture, and tell what the distances are. How many modules will there be ? What do you mean by talking to a API ? That can be almost anything. How are you going to detect a object in the locker ?

There are many wired solutions. Two that come to mind are CAN and RS485. My preference would be CAN, it is multidrop and multi master. It is an extremely robust system if put together correctly. As joint_pk states I2C is a bad choice, it was designed for ic to ic on a board never intended to be a communication bus.

Locker It would have this idea however, the size of the individual compartments could vary.. The distance would be short. As the idea is of the modules would be connected to each other.

There is a external API that will handle the registration of the tools that have been taken out to make sure we can track who has taken what tool.

We are thinking of RFID chips and readers in each compartment, however I'm not sure if that is a good idea. I am not sure if there are any other better options.

I will have a look into these options!

The word "short" means nothing, 1µm is short or 250 Million light years is short, depending on who you ask. That the size can vary also means nothing.
It really matters if those lockers are spread over a building or if they are all together. They are big enough to put a RFID tag in it, that is something.

They're all together, the max distance would be approximately 2 meters from Raspberry pi to a Module

Then I2C is definitely not an option.
Normal Serial/Uart might be possible, but Serial/UART over RS-485 is good. I know almost nothing about CAN.

Would SPI be an option as well? I'm just exploring my options, I would like to try to find a way to make it work without having to buy extra equipment.

It looks like RS485 will need a converter for each device. Where SPI could be directly connected to all nodes. It would have to work without the CS pin though.

No, not for a number of lockers at 2 meters distance.
The signal is leaving the board, put into a wire, to a other board.

Normal RX and TX signals (Serial/UART) can be put in a wire, if you take some care. It is possible to add diodes for plug and play, or cascade all the modules and write a library that handles all of that... if you go that far, then using RS-485 without thinking will be easier.

you could run the raspberry-pi-as-a-wireless-access-point - ESP32 or ESP8266 devices could then access it to upload/downlond information

The electrical characteristics of the CAN bus cable restrict the cable length according to the selected bit rate. You can use cabling up to max of 250 meters with the baud rate of 250 kbit/s. The maximum bus length with a bit rate of 10 kbit/s is 1 km, and the shortest with 1 Mbit/s is 40 meters. The number of nodes can exceed 100 depending on the drivers used on the Physical layer.

The Maximum length of RS485 bus without branching is about 1000 meters and is reduced to about 15 meters with branching . This will allow a few more then 30 nodes depending on bus parameters.

The IEEE1284 standard has 5-volt TTL signals on a 6 to 9 foot cable which is the level of SPI. Note: SPI needs some way of doing select if there is more than one node. The receiving node must have 0.8 volts or lower for a logic low. TTL is defined as fanout or how many loads it can drive. The majority transistor-transistor logic ( TTL ) gates have a fanout of 10 stating can feed up to 10 other standard digital gates or devices.

You could also use a 20mA current loop.

you could use USB - powered USB hubs placed at suitable intervals the remote devices appearing as virtual serial ports on the RPi

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.