Hans on IoT

ThingSpeak, MATLAB, and the Internet of Things

Uber Ride Analysis with ThingSpeak and MATLAB

Have you ever wondered how long it will take to get an Uber at your location? This project uses ThingSpeak to log the ETA for an Uber service based on your latitude and longitude. We will use ThingSpeak’s MATLAB Analysis and TimeControl apps to track Uber’s ETA over time.

Uber Ride Estimate

The Uber API allows you to pass a latitude and longitude to determine the estimated time of arrival for an Uber car. The API also allows you to schedule a car. I have made a button that requests an Uber car and also schedules an Uber at the right time.

MATLAB Analysis Code

% Read the ThingHTTP for 'Uber Ride Estimate'
data = webread('https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXX')

% Convert the response to a number
eta = str2num(data);

% Write the data to the 'Uber Ride Estimate Data' ThingSpeak Channel
thingSpeakWrite(Channel_ID,eta,'WriteKey','XXX');

Each time the MATLAB Analysis code is executed, it will write the estimated time of arrival (ETA) for Uber to your ThingSpeak channel. To track the ETA over time, schedule the MATLAB code with TimeControl. I am running the code every 5 minutes to get an idea of when the peak times are for Uber to pick me up at my office in Natick, MA. Check out the ThingSpeak channel number 840700 to see the estimated times.

Uber_Ride_Estimate_Data

Step-by-step project details are available at Hackster.io.

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。