Arduino and Raspberry Pi Communicate over WiFI?

Hi and thank you in advance for your help. I will give a brief description of what I am trying to accomplish which will hopefully help us solve this together.

I have an Arduino Nano 33 iOT wired to take a temperature reading every minute and then turn a small fan on if the temperature is above a threshold (the fans are trying to keep a 3D printer cool). What I am trying to do it keep a record of that temperature data over long periods of time (30+ hours) so that we can monitor the fans performance and determine the time our print fails. The Arduino cannot be directly connected to a computer since the fans and board are placed on top of the printer.

I also have a Raspberry Pi 3 Model B which I assumed I could use to SSH into the Arduino to pull the temperature data from over wifi. Unfortunately I have been unable to find any information about using SSH into an Arduino. I then began looking up TCP Host/Client Protocols but I believe it is beyond my network/coding abilities. If anyone has done something similar to this who would be willing to point me in the right direction or provide some code that would be much appreciated.

I have been able to connect both the RPi and the Arduino to the network, but have been unable to make them communicate with each other.

If you don't think this will work also let me know, as I am beginning to wonder if connecting an SD card to the Arduino to store the data during a print would be a better option.

Your help is greatly appreciated.

Welcome to the forum.

Your easiest option is to:

  • use MQTT on the Arduino ether PubSubClient library or ArduinoMqttClient (my favourite)
  • install mosquito MQTT broker on your Raspberry Pi
  • use Node-RED (comes with Raspberry PiOS) to receive the MQTT messages from the broker
  • in Node-RED you can then store the data in a time series data base
  • Node-RED also has dashboard nodes to make a nice web page with gauges and diagrams

You can find plenty of tutorials about this using Google ether as Youtube videos are for reading. They are all slightly different but nothing is really difficult. When you get stuck we are here to help.

1 Like

Look at the sample code provided in reply #16 here

Make sure the IP addresses matches your Nano and Raspberry Pie. Then on your Raspberry Pie (or any Linux PC with a terminal), run the following command to listen for the messages

root@srv:~# nc -k -l -N -v -u 7000

Hi @Klaus_K and @hzrnbgy, thank you so much for your responses! After a couple days of troubleshooting I managed to get the MQTT and Node Red idea working. I really appreciate your responses as I had never even heard of MQTT before this (can you tell I'm a newbie?).

In case anyone finds this forum, here is a YouTube video that really helped me figure this all out: MQTT with a Raspberry Pi and an Arduino - YouTube

And I also used this Node Red Data Logger to capture the MQTT payloads: MQTT Data Logger -Node-Red

Thanks again!

1 Like