Project tutorial
Arduino + Raspberry Pi + Ubidots Made Easy

Arduino + Raspberry Pi + Ubidots Made Easy © GPL3+

Create an IOT dashboard using Arduino & Raspberry Pi.

  • 15,088 views
  • 4 comments
  • 43 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
Python IDLE 2.7
Ubidots
Ubidots

About this project

Want to connect your Arduino sensors to Raspberry Pi? This guide will serve as an easy how-to for beginners. I'm new to Arduino so I wanted to create something for everyone to be able to complete in a short amount of time.

Getting Started 

  • Assemble all needed equipment & supplies

Raspberry Pi Setup

  • Make sure Pi is connected to internet via WiFi or Ethernet
  • In terminal run "sudo apt-get update" & "sudo apt-get upgrade"
  • Install Pyserial "pip install pyserial"
  • Install Arduino IDE on your Raspberry Pi

Board Setup

  • For this example, I used Arduino Uno R3. Follow the Fritzing diagram provided for breadboard setup.
  • Plug the USB cable from Arduino into the Raspberry Pi
  • Copy the Arduino sketch to the IDE and upload to the board
  • Open Python 2.7 IDLE and copy the file provided, press F5 to run (need to save first)

You will see new readings every 10 seconds (default, can be changed in Arduino). Create your dashboard in Ubidots to display the data in whatever format you want.

Code

Arduino IDEArduino
upload to Arduino IDE
/*
 * Project: Temperature Reading and uploading value to Ubidots
 * Created by: David Escobar
 */


 const int analogTemp = A0; //temperature input pin


 void setup()
{
  //start serial communication
  Serial.begin(9600);
}

void loop()
{
  int tempRead = analogRead(analogTemp); //read analog value
  float voltage = (tempRead/1024.0) * 5.0; //convert to voltage
  float tempC = (voltage - .5) * 100; //convert voltage to celsius
  float tempF = (tempC * 1.8) + 32; //convert to fahrenheit
  Serial.println(tempF); //print value to serial port
  delay(10000); //wait 10 seconds before new reading
}
Python CodePython
Python serial connection, and uploading to Ubidots
import serial

from ubidots import ApiClient

print("Program Started")

api = ApiClient(token ='Insert your API token here') #update token

my_temp = api.get_variable('Insert your variable token here') #update variable ID

ser = serial.Serial('/dev/ttyACM0', 9600) #update with port for Arduino

while True:
    read_serial = ser.readline()
    tempReading = (float(read_serial)) #convert to float 
    new_value = my_temp.save_value({'value': tempReading})
    print(read_serial) #prints serial reading to python

Schematics

Arduino + Raspberry Pi
Fritzing Diagram

Comments

Author

Daescobar
David Escobar
  • 6 projects
  • 37 followers

Additional contributors

  • Serial communication tutorial by AdrieSentosa

Published on

September 12, 2016

Members who respect this project

DefaultAdambenz13906636 1741649412760149 5074724905676395177 n12986942 985572601513192 4543009080505206172 nDefault14183737 337168606673009 4249894841753023817 nDefaultNewweek

and 35 others

See similar projects
you might like

Similar projects you might like

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 322,402 views
  • 101 comments
  • 778 respects

Alexa Controlled LEDs Through Raspberry Pi

Project tutorial by vincent wong

  • 7,105 views
  • 6 comments
  • 29 respects

Raspberry Pi - Powered Candy Dispenser

Project tutorial by Arduino “having11” Guy

  • 7,399 views
  • 1 comment
  • 13 respects
Add projectSign up / Login