0

I am looking to buy some Raspberry Pi computers to do various tasks. For example, maybe one could water a plant when requested. The part I am struggling to find help with is creating a server where a Raspberry Pi can send and receive information from the other Raspberry Pi. For example, it may send a request to a Raspberry Pi to complete a certain task and another Raspberry Pi may send data back from a sensor. I haven't bought any of the products I will need yet but have a budget of around £150 (about 190 dollars) and was thinking of using Raspberry Pi Pico mini computers to control sensors, motors and servos etc whilst using a Raspberry Pi 4 as the hub where all the data goes to. Please can you show me a good way of doing this and also advise me on whether my budget is unrealistic or of any products I may need that I haven't considered. Below are the products I assume I will need:

  1. 1 Raspberry Pi 4 (not sure on what model)

  2. 1 Raspberry Pi Pico (just to get started I will buy more) - could an Arduino work better for this use case?

  3. 1 Breadboard

  4. A transceiver of some kind but I'm not sure

  5. Male/Female wire connectors

  6. GPIO hat for the Raspberry Pi Pico

  7. motor controller Raspberry Pi add-on boards

  8. Servos, motors, sensors etc

  9. Raspberry Pi Pico wifi adapter HAT

I'm not sure how well I explained that but I appreciate any help/advice that you can give. One of the tags I gave my post was "sockets" as I know this may be a potential solution. I am probably going to use sockets but would just appreciate an experts opinion before I invest.

Thanks

1
  • 1
    You would be better off asking on forums.raspberrypi.com as this site is not a discussion forum.
    – joan
    Mar 5, 2022 at 21:23

1 Answer 1

1

I have a similar setup at home using a RPi4 4GB as a server, with various microcontroller-based devices doing the hardware interfacing. I use a variety of cheap ESP32 or ESP8266 devices, either running a custom Tasmota firmware or programmed directly using the Arduino IDE. I don't see any reason why you couldn't use a RPi Pico or another RP2040-based board though, but for me, the advantage of the ESP-based boards I chose was that they came with built-in WiFi and USB ports, making it easy to power, program and connect them without additional hardware. The key thing though is to make sure whatever you choose has sufficient GPIO lines of the right type for your application. Your budget is probably ample, but it really depends how many devices you will want, and what type of sensors and actuators you decide to hook up to them.

To communicate between the RPi4 and the other devices, I use the MQTT protocol, which is a lightweight publish-and-subscribe protocol. You need to use a MQTT broker (server), which can either be cloud hosted or local. Your devices publish messages like sensor readings to the broker, and can subscribe to messages topics to receive commands. Eclipse Mosquitto is an open source broker that works well on my RPi4. Install it with sudo apt install mosquitto, but be sure to check its documentation on how to set up access control for your broker.

Once your broker is set up, you can use the mosquitto_pub and mosquitto_sub command-line tools to send and listen for messages on the RPi. I haven't tried it out, but the Paho MQTT library promises to do the same in Python. MQTT libraries are also available for other languages, including for Arduino-compatible devices, and the Tasmota firmware uses MQTT as its main means of communication.

Rather than writing all your own code on the RPi, you might want to use some kind of home automation app to record the data from your devices and handle the logic of controlling them. I use Home Assistant, installed on the same RPi4 as the MQTT broker. OpenHab and Node Red are other options - all of them support MQTT communications.

1
  • You can even use python on RP2040 processors. CircuitPython or MicroPython
    – NomadMaker
    Apr 6, 2022 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.