WiFi Enabled Arduino Over USB

1,846

28

Published

Introduction: WiFi Enabled Arduino Over USB

About: I go by millerman4487, and I am here to share what I make. Hopefully, you can learn from watching what I have done and even improve upon it. So here you go! If you have any ideas for future projects, send...

This project uses Blynk, which is a service you can use to connect WiFi enabled things to a server. You can control devices like the Raspberry Pi or a specialized SparkFun Blynk Board from an app on your phone. The boards mentioned already have built in wireless capabilities, but the Arduino is not meant to do that - at least not without some help.

If you have never used Blynk before, this will be helpful: http://www.blynk.cc/getting-started/

Step 1: Install Necessary Software

Step 2: Set Up the App

  1. Open the Blynk app
  2. Create a new project
  3. Give it a cool name
  4. Select the board "Arduino UNO"
  5. Set the connection type to USB
  6. Tap "Create" - It should send you an email with your Auth token (you'll need this later)
  7. Click run

At the top it will probably say that your board is offline, we'll fix that in the next step.

Step 3: Upload and Run the Code

  1. Connect the Arduino board to your computer
  2. Navigate through the newly installed Blynk Library to find the Arduino code: Arduino > libraries > Blynk > examples > Boards_USB_Serial > Arduino_Serial_USB
  3. Change the "YourAuthToken" to the Auth token provided in the app:

char auth[] = "YourAuthToken"; 

- Once you change it, it might look like

char auth[] = "c3e7d746a05b4cah18723cbcb3631a97"; 

(I just made up some random stuff there - don't try using it for real)

Step 4: Run the Blynk Script

  • With the Arduino code still going, run the .bat file located in: Arduino > libraries > Blynk > scripts. Type your serial port when it prompts you and press enter (Mine is COM3).

Open the app again and wait a little while. If it still doesn't come online, close the running .bat file and continue with the step below.

  1. Close the .bat file
  2. Edit blynk-ser.sh with wordpad (or something similar) located in: Arduino > libraries > Blynk > scripts - (you might need to change baud rate):
# === Edit default options to match your need === 
FROM_TYPE="SER" # SER, TCP 
TO_TYPE="SSL"   # TCP, SSL 
COMM_BAUD=9600
SERV_ADDR=blynk-cloud.com 
...
  1. Save the document and close it
  2. Run the .bat file again

If the app says everything is online, you can move on.

Step 5: Add a Button

We will use a virtual button on your phone to control what we just made:

  1. Press the (+) button at the top and select a button widget
  2. Set the output to V0
  3. Press Run

Now we have to tell the Arduino to do something when you press the button:

  1. Close the .bat file
  2. In the void setup() section, add:
 pinMode(13, OUTPUT); 

Now scroll down to the bottom of the code and add this below the void loop() section:

BLYNK_WRITE(V0) {
 int pinData = param.asInt(); 
 digitalWrite(13,pinData); 
} 

Upload the code again and run the .bat file. Now when you press the button it should turn on the onboard led.

Step 6: Going Further

If you want to do more than turn on an led, you can add these sections to your code to both send and receive data to your board:

How to send data (this is what you did before):

BLYNK_WRITE(V0) {
 int pinData = param.asInt(); 
 } 

How to recieve data:

  • Make a value display in the app and set the input to V5.
  • You can attach a button to the Arduino for example, and have the display tell you when the button is pressed by typing:

 pinMode(2, INPUT);

in void setup(). Use the code below in void loop():

BLYNK_READ(V5) { 
 int val = digitalRead(2); 
 Blynk.virtualWrite(5, val); 
} 

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Clocks Contest

      Clocks Contest
    • Make it Move Contest

      Make it Move Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Comments