Hacking The Mixpanel API with Arduino UNO

Tapping into the Mixpanel API from my 'Duino Uno

2 Contributions Made
1 Milestones
4 Participating Countries

Tapping into the Mixpanel API from my 'Duino Uno

Anas Dalintakam
Electronics engineer,DIY thinkerer,arduino/raspberry pi/particle enthusiast,IoT researcher
Calicut, Kerala, India
Playing with new DIY components is my first hobby.And blogging simple tutorials on those is my second hobby.I am happy to help community

Project Overview

I continue to stress that Arduino is a real, yet amazing addiction. This weekend, I had an intensely strong urge to start a new Arduino Project. The thing is, I did not want this to be a meaningless project, even if it is primarily to learn.

My top 2 ideas initially

  1. Sling shot for the office

  2. A wifi + arduino + lcd project that could somehow tap into Mixpanel data

I decided to go with option 2 because it seems like a much more effective learning project, with knowledge we can apply later.

How the Project Will Work

It’s pretty simple to understand.

–> Wifi card taps into mixpanel’s api, pulls the most recent event to happen on Collaborizm Live Server --> Display on LCD.

how it will appear

circuit diagram


Current Task in Progress

There are 2-3 active tasks in Progress. The reason why I say “2-3” is because these 2-3 tasks will work together so they must be tackled at similar times. Please see the Project Outline Card below this section to learn about more details of the tasks in progress.

Teammates & Contributors I’m Looking For

Object Oriented Programming – I need an OOP experienced programmer to help me understand how OOP works

#Arduino – experts in WiFi connectivity and making HTTPS Requests **off the ‘Duino’

#LCD – experts in connecting to LCD

#C Programmers

#iOT People will also be extremely helpful for the overall assembly and execution of the Project

Understanding Mixpanel


Mixpanel is an extremely powerful data analysis tool for tech companies, specifically companies with web based/app based software, like Collaborizm 😃.

All you really need to know for this project are some basic things:

  • Mixpanel is passed EVENTS from whatever web/app you have – so for example on Collaborizm, one event we track, is “REPLY”.

  • You can track any event you want in your Projects

  • EVENTS are attached to EVENT PROPERTIES – like user city, device, country – eg. a REPLY event might tell us if the user was on an Android, in Mumbai, India when that REPLY event was executed.

For this Project that’s really all you need to understand. I will supply more information on mixpanel, and mixpanels API in Supporting Material Section below.



Why I’m Passionate About This Project

I am passionate about this Project because I am obsessed with the Internet of Things, Hardware, and Arduino, as well as data analysis.

Current Code File: Just a draft…to organize the different sections

Sections in Arduino File

Section 1: Import libraries
Section 2: Initialize Wifi Module and Connect to network, Send Proper Request to Mixpanel API
Section 3: Retrieve Request, Process Request, Store properly
Section 4: LCD

// Libraries Imported ------------------------------------------------------

~span~class~_1bcRJhiNTH8jh88VODldlE~#include~span~ <WiFi.h>
~span~class~_1bcRJhiNTH8jh88VODldlE~#include~span~ <LiquidCrystal.h>
~span~class~_1bcRJhiNTH8jh88VODldlE~#include~span~ <ArduinoJson.h>

// Define a New Class and Create Object ------------------------------------------------------

class Mixpanel
  // Class Member Variables
  // These are initialized at startup
  unsigned long eventName;      
  unsigned long eventCity;    


// Initialize and Connect to Wifi Network ------------------------------------------------------

char ssid[] = "WEWORK";     //  your network SSID (name) 
char pass[] = "[email protected]";    // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

void setup() {
  // initialize serial:

  // attempt to connect using WPA2 encryption:
  Serial.println("Attempting to connect to WPA network...");
  status = WiFi.begin(ssid, pass);

  // if you're not connected, stop here:
  if ( status != WL_CONNECTED) { 
    Serial.println("Couldn't get a wifi connection");
  // if you are connected, print out info about the connection:
  else {
    Serial.println("Connected to the WEWORK network");

void loop() {
  // do nothing

// Mixpanel API --> (1) Authenticate (2) Get Newest Event in this Critera Range on Mixpanel (3) Update mixpanelEventNow

// Search For Newest Reply Event --> Return Event Name, Country

// you are always sending your secret key with every request

//// sandbox

  Repeating Wifi Web Client

 This sketch connects to a a web server and makes a request
 using an Arduino Wifi shield.

 * WiFi shield attached to pins SPI pins and pin 7

 created 23 April 2012
 modified 31 May 2012
 by Tom Igoe
 modified 13 Jan 2014
 by Federico Vanzati

 This code is in the public domain.

~span~class~_1bcRJhiNTH8jh88VODldlE~#include~span~ <SPI.h>
~span~class~_1bcRJhiNTH8jh88VODldlE~#include~span~ <WiFi.h>

char ssid[] = "yourNetwork";      //  your network SSID (name)
char pass[] = "secretPassword";   // your network password
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

// Initialize the Wifi client library
WiFiClient client;

// server address:
char server[] = "www.arduino.cc";
//IPAddress server(64,131,82,241);

unsigned long lastConnectionTime = 0;            // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 10L * 1000L; // delay between updates, in milliseconds

void setup() {
  //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
  // you're connected now, so print out the status:

void loop() {
  // if there's incoming data from the net connection.
  // send it out the serial port.  This is for debugging
  // purposes only:
  while (client.available()) {
    char c = client.read();

  // if ten seconds have passed since your last connection,
  // then connect again and send data:
  if (millis() - lastConnectionTime > postingInterval) {


// this method makes a HTTP connection to the server:
void httpRequest() {
  // close any connection before send a new request.
  // This will free the socket on the WiFi shield

  // if there's a successful connection:
  if (client.connect(server, 80)) {
    // send the HTTP PUT request:
    client.println("GET /latest.txt HTTP/1.1");
    client.println("Host: www.arduino.cc");
    client.println("User-Agent: ArduinoWiFi/1.1");
    client.println("Connection: close");


    curl https://mixpanel.com/api/2.0/jql \
    --data-urlencode [email protected]_query.js

curl https://mixpanel.com/api/2.0/jql \
--data-urlencode params='{"from_date":"2016-01-01", "to_date": "2016-01-07"}' \
--data-urlencode script='function main(){ return Events(params).groupBy(["name"], mixpanel.reducer.count()) }'

function main() {
  return Events({
    from_date: '2016-10-08',
    to_date:   '2016-12-22',
    event_selectors: [{event: 'reply'},{event: 'discussion'},{event: 'chat_msg'},{event: 'approved_join_request'},{event: 'denied_join_request'},{event: 'favorite'},{event: 'join_request'},{event: 'login'},{event: 'login_native'},{event: 'upvote'},]

// Create Object of Class Mixpanel

create object 

method eventName = key from item in json array where time = greatest
method eventCity = key from item in json array where time = greatest

/// need to use json library for Arduino to somehow evaluate our goal which is set fucking arrayitem with biggest time stamps key values of Event Name/City to an object the lcd can print from


    // note the time that the connection was made:
    lastConnectionTime = millis();
  } else {
    // if you couldn't make a connection:
    Serial.println("connection failed");

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(" dBm");


// Set up LCD ------------------------------------------------------

LiquidCrystal lcd(2, 3, 8, 9, 10, 11); 

void setup()


lcd.begin(16, 2);


void loop()


lcd.setCursor(0, 0);


lcd.setCursor(0, 1);




/// ***----- Resources -----***

// https://ictronic.wordpress.com/2016/07/02/interfacing-16x2-lcd-with-arduino-without-potentiometer/

// http://www.instructables.com/id/Connecting-an-LCD-to-the-Arduino/?ALLSTEPS

// https://github.com/bblanchon/ArduinoJson/wiki/Decoding-JSON


Supporting Material & Info

LCD Connection



Decoding a JSON Response on Arduino


WiFi Connection & HTTPS Requests From Arduino




Team Micro-Checklist

Completed List:

  • Circuit Diagram Completed: WiFi Module Added

  • Circuit Diagram Completed: Arduino UNO Board Added

  • Circuit Diagram Completed: LCD Connected

  • Initial attempt at Arduino Code completed

  • Circuit Diagram Completed: Power (9V) connected

In Progress List:

  • Must successfully connect to Mixpanel API and pull data FROM Arduino

  • Must successfully STORE the JSON response from Mixpanel API to Arduino

  • Must extract the most recent event and add it to an Object which will be used in the LCD function to continuously loop through this Object to display most recent event (and associated properties)

  • Github Documentation

  • Improving hardware

To Be Completed:

  • Debugged Script

  • Assemble Circuit

  • Film it in action

  • Add new ideas to pull from Mixpanel

Discuss Hacking The Mixpanel API with Arduino UNO

Related Projects

Hacking The Mixpanel API