Simple REST calls with Arduino over WiFi

Just ported RestClient for Arduino to use WiFi instead of Ethernet. I specifically did this to make it easier for developers to use Intel Edison’s WiFi while doing REST API calls.

I haven’t yet tested an integration but I believe aJSON or equivalent will be really useful for doing anything beyond very basic REST calls here. All I wanted was a way to make some basic REST calls with Edison over WiFi.

While I am short on time, if I get more time I might consider producing a version which support both WiFi and ethernet.

Installation

  • In a terminal, browse to the directory in your OS where your Arduino IDE keeps it’s libraries (probably “/Documents/Arduino/libraries”)
  • Run “git clone https://github.com/rexstjohn/arduino-restclient.git RestClient” to download the WiFi RestClient into your libraries
  • Restart your Arduino IDE
  • Use “File -> Examples -> RestClient -> simple_GET” to test it
/* RestClient simple GET request
 *
 * by Rex St John
 */

#include 
#include 
#include "RestClient.h"

char ssid[] = "YOUR_SSID";            //  your network SSID (name)
char pass[] = "YOUR_WIFI_PW";         // your network password
char host[] = "jsonplaceholder.typicode.com";      // target for your REST queries
int status = WL_IDLE_STATUS;         // the Wifi radio's status

// Create your WiFi RestClient, pass in the ssid and password.
RestClient client = RestClient(host, ssid, pass);

String response;
void setup() {

  // Initiate Serial Connection
  Serial.begin(9600);
  Serial.println("Starting REST client over Wi-Fi");
  if(client.connect() == WL_CONNECTED){
    response = "";
    int statusCode = client.get("/posts/1", &response);
    Serial.print("Status code from server: ");
    Serial.println(statusCode);
    Serial.print("Response body from server: ");
    Serial.println(response);
    delay(1000);
  }
}

void loop(){
  // 
}

Intel Hack N’ Tell @ SoDo Makerspace

Another Intel Hack N’ Tell came to town, I supported via my Meetup group: DeviceJam! Great event with around 70 people demonstrating 7 projects. Bonus points: Meeting Anouk Wipprecht, creator of the Spider Dress.

SXSW Journalism Hackathon @ UT Austin

How to stream audio via Bluetooth with Intel Edison

I apologize in advance, these are working notes I took during a hackathon from a developer who got Edison working as an audio source via Bluetooth. Some steps may be missing. If you find anything wrong with this please tweet me: @rexstjohn.

First, install PulseAudio via opkg if not installed and unblock Bluetooth (see rfkill instruction below). Install drivers for Bluez etc. There are some steps over here.

$ rfkill unblock bluetooth

Next, put your audio device into pairing mode. Then, on your Intel Edison do this:


$ bluetoothctl (opens the bluetooth agent)...
$ agent
$ set agent KeyboardDisplay
$ default-agent
$ scan on


Locate the audio controller from the list:


$ pair xx:xx:xx:xx (with the audio controller you get from scan on, your Bluetooth speaker)
$ connect xx:xx:xx:xx


On the linux terminal, now play the file


$ pactl list | grep -A1 SUSPENDED | grep Name (show list of devices suspended)


Scroll through the list and find the “sink.” Hint: Look for thing that says “State suspended”, find the “sink” that is suspended.

It will look like this: bluez_sink.[your mac address with colons as underscores]


$ pactl set-default-sink bluez_sink.[yourmacaddress]


Now use PulseAudio / mplayer to play your audio file. Copy a wav file into Edison (probably using scp), then play it like this:


$ “./mplayer youraudio.wav"

Hanging out with Mark Cuban and hackers at HackDFW

Using Nide to turn Intel Edison into a web-based IDE

nide

I have been thinking for some time it would be fantastic to be able to edit code files directly on Intel Edison via a web browser over the local network. Fortunately, I discovered a powerful and elegant Node.js based web IDE called Nide which makes this workflow completely possible and easy to set up!

Installing and using Nide on Intel Edison

First, open a terminal to your Edison and install the Nide using NPM:

$ npm install -g nide

and then, in the directory where your code is located, call:

$ nide init
$ nide -b

Note: You must append the “-b” option. Nide’s default behavior is to open a web browser in place (which Edison doesn’t have), resulting in errors. Adding the “-b” flag indicates you want to run Nide without a browser.

Next, you will see something like this:

Nide running at http://localhost:8123

Assuming your PC is on the same network as your Intel Edison, you should be able to navigate to the IP address of your Edison (which must be online for this to work) and append the port (in the above example, 8123) to see the Nide editor.

Note: If you are unsure of your Intel Edison’s local IP address, run “$ifconfig” in your Edison’s terminal and look for the IP address associated with “eth0.”

Once you do that, you can edit your Intel Edison project code directly via your web browser, no need to deploy code, it saves automatically in place as you edit!

Intel IoT Roadshow Seattle Highlights

Is React Native Cross-Platform Snake-Oil?

265k
Cross platform native UI, you say?

I watched the video on React Native which hit the front page of Hacker News the other day and remain pretty skeptical about the promises being made.

Having built both native iOS and Android experiences (as well as cross-platform applications in Cordova / Phone Gap and Flex 4), I am not sold that the key problems preventing developers from producing a truly unified codebase are likely to ever be solved completely in a “Learn Once, Deploy Anywhere” manner…There will nearly always be some level of customization required, Developers and designers will nearly always need to have direct knowledge of each platform target.

The obsession with attempting to streamline native mobile development is well-placed…I fully understand the pain involved in trying to manage Android and iOS development simultaneously…However, it is unlikely that React Native is going to be a “magic bullet.”
[Read more…]

Introducing “Edison” – A CLI tool for doing simple tasks on Intel Edison

Just published beta v1 of my new Node.js / Commander.js-based CLI tool “edison.” I wanted to give users a way to do something as simple as “edison blink” in order to get started with the board.

In the future I hope to add much more functionality and get others involved in upgrading the tool to automate more common tasks.

Just run “npm install -g edison” on your Intel Edison to install the tool. Then try out “edison blink” or “edison status.” Something seems to be wrong with libMRAA right now so I haven’t gotten my board blinking yet. It’s in beta…