• Home
  • About
    • James Thesken photo

      James Thesken

      James' World

    • Learn More
    • Email
    • LinkedIn
    • Github
    • Youtube
  • Posts
    • All Posts
    • All Tags
  • Projects

Control an Arduino with iPhone and React-Native

30 Jan 2019

Reading time ~1 minute

If you’re reading this article, it’s because you’re interested in learning about full-stack development and how to control hardware from your phone or other networked devices. What started as seeing if I could blink an LED over a serial port opened by Node.js turned into making an iPhone app to do the same.

What are the possibilities from knowing this?

  1. Anything

The Hardware Setup

I used the following:

  • iPhone
  • Arduino Uno with USB cable
  • Raspberry Pi running a standalone hotspot

Software used:

  • Expo to simulate iOS (I don’t have a Mac)
  • React-Native because I like Javascript
  • Arduino environment
  • socket.io to broadcast commands accross the network.
  • Node.js/Express to handle requests/commands sent to the serial port.

The interfacing of hardware wasn’t too hard. Getting socket.io and React-Native to cooperate took the most work however. If you’re having trouble with that, check out my Github repo. Particularly:

//importing networking window.navigator.userAgent = 'react-native'; //this NEEDS to be placed before importing socket io import io from 'socket.io-client/dist/socket.io';

The whole thing works by having the server listen to events broadcasted on port 8080, in the form of a string. The string is received by the serial port and interpreted as different commands. For our case, a blink.



internet-of-things Share Tweet +1