Arduino and Raspberry Together

Hello guys,

I was wondering if I can connect my arduino to my raspberry pi 2, in order to grant Internet access to my arduino.
I checked that you can grant internet access to the arduino through USB/Serial, however don’t know if this functionallity works with raspberry.
This would be awsome since a lot of sensors are available for raspberry and not for arduino, and with this I wound’t need a wifi/ethernet shield to have a dashboard for my arduino.


It’s not really recommended to use the USB modem drivers but it is certainly possible. Hooking up to a raspberry pi is something that I want to do in the near future, I’ll let you know how I make out if someone doesn’t beat me to it.

Ok, please let me know then if you made any progress.
I will try the usb drivers today too so I’ll update this post as well.


I’ve been able to connect my Arduino Uno to my RPi 3 over USB and finally to Cayenne. All you have to do is run the “” shell script on the Pi while the Arduino is connected and have the CayenneSerial.h library running on your Arduino. My Arduino sketch looks something like this:

I believe, upon first running the script, the command line will prompt you with a command to install a utility called “Socat.” Once you have installed Socat, run the script again and it should give you this:

Here, all you have to do is type in the address of your USB-Arduino connection (which it should give you in the brackets). So in my case, it is /dev/ttyACM0, so i would type it after the colon.

If all goes well, your terminal should look something like this:

Hopefully this is what you’re asking and hopefully this helps!


WOoooW Thanks a lot Ken!!!

Was two hours testing this, since I have a Pi Zero and it is very slow but finally I manage to do it :smiley:
With this I can now finish my project :blush:

Really…you are the man !

Again thank you for your help. It works like a charm :smiley:

Hey @akers.kenneth66 ,

I agree with @joaoduarte_89, you are da man! Thanks a lot for posting this to the Community and sharing your work. I hope many other Cayenne members will be able to benefit from it.

@joaoduarte_89 be sure post your project once you are finished to the Projects Made With Cayenne category. The Cayenne team reviews the submitted projects at the beginning of each week.

Love to see this kind of stuff, thanks guys!


Hey @bestes and @akers.kenneth66.

This is what I archived so far with the tutorial posted above:

  • I connected my arduino to my raspberry and I managed to add it to Cayenne.
  • Also connected a DHT11 Sensor and now I can keep track of Temperature and Humidity using Virtual Pins :slight_smile: ([Dashboard values don't update] (Dashboard values don't update) thanks to @ats1080s )
  • After that I hooked another arduino, edited the file to look for this second arduino and run another instance of the script.

Guess what… I have now two arduinos connected to the Raspberry PI and both can be controlled using Cayenne!!! :smiley:

Here is a picture of what I changed in the script to manage to have multiple arduinos connected to the raspberry.

You just need to change /dev/tty to the usb port.

I will post my entire project once I finish it for sure.



I have an Arduino Nano linked to a Raspberry Pi with multiple analog sensors. I use the Pi for Ethernet connectivity, data collection and for the Pi Camera to keep an eye on the sensors.

I’d love to use Cayenne as my dashboard but it seems that I need some sort of Arduino networking shield in order to “register” the device and get a token before I can connect to Cayenne using Kens method above? Is that correct?

Ethernet and Wifi on Arduino seems particularly clunky and especially with a Nano. Is there not a way to register via a PC or Pi without the Arduino needing its own Wifi or Ethernet?

Also if I added more Arduinos would they need to be individually registered?

Any help / guidance is much appreciated.


Hello @peter_dieck,

I’ll try to explain the whole method I used (guys please correct me if I say some barbarity :wink:)

There are multiple ways to integrate arduinos in Cayenne dashboard.
In cayenne if you go to Add New → Add Device/Widget → microcontrollers → Arduino, you will find all the possible connections to get your arduino connected to cayenne.

The method in the replies above describe how to connect your arduino to caynne, by connecting it to your PI by USB.

  1. First you add a Arduino to your dashboard. Note that there is a token writen on upper right corner. When you choose usb connection there will be a popup with the example code, and after you will see a “Waiting for Board to connect” loading.

  2. After you need to upload to your arduino the code regarding the Serial USB connection. ( It is in Ken’s reply or you can just upload the Sketch example).

(Also note that in this code you will need to write “YOURTOKEN”, the code regarding your sensors, and also add Cayenne Libraries. You can find the libraries here

Here is what I have uploaded to get a DHT11 sensor working:

define DHTTYPE DHT11
define DHTPIN 8

include <CayenneSerial.h>
include “CayenneDefines.h”
include <DHT.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “YOURTOKEN”;

float humidity, temp_f; // Values read from sensor

DHT dht(DHTPIN, DHTTYPE); // 11 works fine for ESP8266

void setup()


void loop()


// Send the command to get temperatures.
// This command writes the temperature in Celsius to the Virtual Pin.
//Cayenne.celsiusWrite(VIRTUAL_PIN, sensors.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));

// Check if any reads failed and exit early (to try again).
do {
humidity = dht.readHumidity(); // Read humidity (percent)


} while (isnan(humidity));

Cayenne.virtualWrite(V0, humidity);



// Send the command to get temperatures.
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN, sensors.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));

// Check if any reads failed and exit early (to try again).
do {
temp_f = dht.readTemperature(true); // Read temperature as Fahrenheit


} while (isnan(temp_f));

Cayenne.virtualWrite(V1, temp_f);

After that, you download the script that Ken mention in his reply and run it. You will see a arduino connected to your dashboard (you can also find it in that link).

In the end you just add widgets regarding your project/sensors/actuators.

As response to your other question: Also if I added more Arduinos would they need to be individually registered?
I only have tried with different tokens, but I will try to register more than one arduino with just a single token and I will let you know.

Hope I was clear enough, and let me know if I can help you somehow.


Hello joaodduarte_89

Thank you very much for the detailed response, that makes a lot more sense to me now. Unfortunately I’m not able to test this until the weekend but I feel much more confident about the process.

Many Thanks

Hi @peter_dieck

Good to know that :slight_smile:
I can only work on this in the weekend as well, so I will try to check if it is possible to configure multiple arduinos with a single token using this method.


How do you get this script to run automatically on boot of the RPi 3?

How do you get this script to run automatically when the RPi3 boots up?

Is this what you are looking for?

1 Like

Hello @joaoduarte_89 ,
I have a question: Where do you take “” file, and where do you put it. I download the whole library but I can not run the file. It gives me that “command is not found”.

Can you help with a little more explanation about running this script? Do I need to install Arduino IDE on the raspberry ?

Thank you in advance.

I make the file executable with chmod +x and then everything is OK.

Thank you!

I have failed adding the script starting automatically after a reboot. So now my raspberry is LOOPING :slight_smile:
I edit the /etc/rc.local adding /home/pi/Downloads/ || exit 1
exit 0

Hello @ognqn.chikov

I have found this link here that might help you:


If your command runs continuously (perhaps runs an infinite loop) or is likely not to exit, you must be sure to fork the process by adding an ampersand to the end of the command, like so:

python /home/pi/ &
Otherwise, the script will not end and the Pi will not boot. The ampersand allows the command to run in a separate process and continue booting with the process running.


yes I know @joaoduarte_89 , all my starts at the crontab are with “&”, but here in this content, I don’t know where to add it ?

Can you please past your /etc/rc.local file?
Sorry but I’m not able to test it anymore since I’m using all my Pis :frowning:
If you want a more elegant soluction try a NodeMCU ESP-12E… you will only need Arduino if you need analogue IN/OUTs.