IoT Basics. Connecting a Raspberry Pi to Salesforce. Mark Williamson Salesforce Developer. Larry Allan Sr. Business Support Analyst

Size: px
Start display at page:

Download "IoT Basics. Connecting a Raspberry Pi to Salesforce. Mark Williamson Salesforce Developer. Larry Allan Sr. Business Support Analyst"

Transcription

1 IoT Basics Connecting a Raspberry Pi to Salesforce Larry Allan Sr. Business Support Analyst Mark Williamson Salesforce Developer Larryallan7 Larry.Allan@york.ca Mark_Willyson Mark.Williamson@york.ca

2 Larry Allan Sr. Business Support Analyst Larryallan7 Mark Williamson Salesforce Developer Mark_Willyson

3 Forward-Looking Statements Statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include but are not limited to risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

4 Solution What problem are we trying to address? Determine the right amount of collaboration space for our business How? % Utilization & availability Occupancy information Raw data collection Data analysis

5 Solution Raw data collection Data analysis Occupancy information % Utilization & availability

6 Solution Raw data collection Data analysis Occupancy information % Utilization & availability Live Demo Hardware Python code essentials Software & installation Salesforce objects

7 Demo

8 Hardware Raspberry Pi Micro SD Card 4 GB minimum /w adapter Passive Infrared Sensor (PIR) Female to female wiring harness Power supply (2 amp minimum) Case /w heat sinks USB mouse, keyboard and monitor

9 Install your Pi OS Raspbian is the officially supported OS An easy installer for Raspbian is NOOBS Download NOOBS and copy the extracted files to the root directory on your micro SD card preformatted for FAT32

10 Setup your Pi OS Insert your micro SD card into your Pi Connect your mouse, keyboard, and monitor You will need internet access in the next step. You may use the ethernet port or WiFi on newer models Boot up your Pi and follow directions to complete the initial setup

11 Install Simple Salesforce Open Terminal sudo apt-get update sudo apt-get install xrdp sudo apt-get install python3-pip sudo pip-3.2 install simple-salesforce Simple Salesforce* is a REST API client for Python Simple Salesforce documentation and package: github.com/heroku/simple-salesforce * Simple Salesforce written by Nick Catalano with newer features from community contributors

12 Connect your PIR sensor Out +5V +5V GND GND Pin 7

13 GPIO port numbering GPIO Pins Physical Pins

14 Python Code Import libraries for GPIO interface, time functions and Salesforce import RPi.GPIO as GPIO import time Pin 7 from simple_salesforce import Salesforce GPIO Port to monitor sensor input on Pin 7 GPIO.setmode(GPIO.BCM) PIR_PIN = 7 GPIO.setup(PIR_PIN, GPIO.IN)

15 Python Code Create a connection to Salesforce sf = Salesforce(username='me@york.ca', password='mypassword', security_token= BigUglyToken, sandbox=false) RooRoom Update a Salesforce record moccupancy #Update Occupied State of Room Record to True sf.room c.update('a0b odk', { Occupied c':true}) Create a Salesforce record #Create Occupancy Record Room Name (Room Number) Description Start Time sf.room_occupancy c.create({'room c':'a0b odk', 'Start_Time c':start_time, 'End_Time c':last_motion}) Text DateTim Text e Checkbo DateTim Occupied End Time x e Duration Formula

16 Getting Your Security Token sf = Salesforce(username='me@york.ca', password='mypassword', security_token= BigUglyToken, sandbox=false) Classic Setup Navigate to: [your name] > My Settings > Personal > Reset My Security Token Lightning Navigate to: [your name] > Settings > My Personal Information > Reset My Security Token

17 Referencing Salesforce Records #Update Occupied State of Room Object to True sf.room c.update('a0b odk', { Occupied c':true}) #Create Occupancy Record sf.room_occupancy c.create({'room c':'a0b odk','start_time c':start_time, 'End_Time c': Last_Motion})

18 Formatting DateTime Fields All Salesforce DateTime fields store data in Coordinated Universal Time (UTC) 24 hour format (originally Greenwich Mean Time) October :30:00 PM Greenwich, England T18:30:00Z Last_Motion = time.strftime("%y-%m-%dt%h:%m:%sz", time.gmtime()) #Create Occupancy Record sf.room_occupancy c.create({'room c':'a0b odk', 'Start_Time c':start_time, 'End_Time c':last_motion})

19 Using Our Source Code Download our source code from: github.com/yorkregion Save RoomMonitorDF16.py to /home/pi/ Running our code Launch Python 3 IDLE Open our file Provide your credentials and Room ID

20 Salesforce Objects Name (Room Number) Room Text Room Occupancy Description Text Room Master-Detail Occupied Checkbo x Start Time DateTim e DateTim Master End Time e Duration Formula Detail

21 Where to go from here?

22 Summary of Links Adafruit Hardware: Raspberry Pi OS Downloads Simple Salesforce documentation and package github.com/heroku/simple-salesforce Our source code github.com/yorkregion USA: Canada: elmwoodelectronics.ca Search for: PIR sensor 189 Female to Female jumper wires GPIO Port Numbering - Models 2 and 3 Project Box (for PIR sensor)

23 Thank Y u Larryallan7 Larry.Allan@york.ca Mark_Willyson Mark.Williamson@york.ca