Thursday, April 30, 2015

Windows 10 + Arduino Partnership

Arduino Partnership

Arduino Certified” Windows 10 enables developers to make devices that combine the hardware-driving capability of Arduino with the software capabilities of Windows. An example might be a security camera. One could build a camera using Arduino to power the motor controls to tilt/turn the camera and using Universal Windows Platform one can create great UI, connect the camera to the cloud, process the image for motion detection and add facial/voice recognition. The work we have done on Windows 10 is the bridge between the Universal Windows Platform and Arduino hardware. The initial release includes two key capabilities:

  • Windows Virtual Shield for Arduino enables developers to tap into the incredible power of Windows 10 devices through wireless protocols. A Lumia 530 contains well over $200-worth of Arduino shield sensors and capabilities, and we’ve made it easy to access all of those sensors and capabilities from an Arduino as if they were standard hardware shields. Imagine being able to create an Arduino project that includes GPS, Web connectivity/parsing, touch display, speech technologies and more. We’re particularly fond of the picture the weather project we’ve created that lets you bring your children’s drawings to life.
  • With Windows Remote Arduino we’re enabling developers to extend their Universal Windows Application with Arduino commands that execute on a wirelessly-connected Arduino device. It combines the power of Windows 10 device features such as image processing, speech recognition, website parsing, cameras and advanced audio pipelines with the power of physical world interactivity through Arduino. Take a look at our Basic Windows Remote Arduino project to learn how to leverage this technology in your own projects. 

Source: Windows Blog - Microsoft brings Windows 10 to Makers

Wednesday, April 29, 2015

Arduino Due + ESP8266 - to Join AP

Arduino Due connect with ESP8266 work in CWMODE=1, to join AP shared by mobile phone.


Connection between Due and ESP8266, refer to last post "Connect ESP8266 (WiFi module) to Arduino Due".


Due8266.ino
/*
Arduino Due - ESP 8266 WiFi Module
Serial (Tx/Rx) communicate to PC via USB
Serial3 (Tx3/Rx3) connect to ESP8266
Tx3 - ESP8266 Rx
Rx3 - ESP8266 Tx
pin 53 - ESP8266 CH_PD (Always High)
*/
#define ESP8266 Serial3
String SSID = "TestAP";
String PASSWORD = "12345678";

int LED = 13;

//always high
int CH_PD_8266 = 53;

boolean FAIL_8266 = false;

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(CH_PD_8266, OUTPUT);
  digitalWrite(CH_PD_8266, LOW);
  
  digitalWrite(LED, LOW);
  delay(500);
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);

  digitalWrite(CH_PD_8266, HIGH);
  delay(1000);

  do{
    Serial.begin(9600);
    ESP8266.begin(9600);
  
    //Wait Serial Monitor to start
    while(!Serial);
    Serial.println("--- Start ---");

    ESP8266.println("AT+RST");
    delay(1000);
    if(ESP8266.find("ready"))
    {
      Serial.println("Module is ready");
      ESP8266.println("AT+CWMODE=1");
      delay(2000);
      
      //Quit existing AP, for demo
      Serial.println("Quit AP");
      ESP8266.println("AT+CWQAP");
      delay(1000);
      
      clearESP8266SerialBuffer();
      if(cwJoinAP())
      {
        Serial.println("CWJAP Success");
        FAIL_8266 = false;
        
        delay(3000);
        cwGetIP();
      }else{
        Serial.println("CWJAP Fail");
        delay(500);
        FAIL_8266 = true;
      }
    }else{
      Serial.println("Module have no response.");
      delay(500);
      FAIL_8266 = true;
    }
  }while(FAIL_8266);
  
  digitalWrite(LED, HIGH);
}

void loop() {

}

boolean waitOKfromESP8266(int timeout)
{
  do{
    Serial.println("wait OK...");
    delay(1000);
    if(ESP8266.find("OK"))
    {
      return true;
    }

  }while((timeout--)>0);
  return false;
}

boolean cwJoinAP()
{
  String cmd="AT+CWJAP=\"" + SSID + "\",\"" + PASSWORD + "\"";
  ESP8266.println(cmd);
  return waitOKfromESP8266(10);
}

//show IP address on Serial Monitor
void cwGetIP()
{
  clearESP8266SerialBuffer();
  ESP8266.println("AT+CIFSR");
  delay(1000);
  
  while (ESP8266.available() > 0) {
    char a = ESP8266.read();
    Serial.write(a);
  }
}

void clearESP8266SerialBuffer()
{
  Serial.println("= clearESP8266SerialBuffer() =");
  while (ESP8266.available() > 0) {
    char a = ESP8266.read();
    Serial.write(a);
  }
  Serial.println("==============================");
}



Tuesday, April 28, 2015

Connect ESP8266 (WiFi module) to Arduino Due

Just to prove the connection between Arduino Due (TX3/RX3) and ESP8266 WiFi module, electrically and logically. Because both Arduino Due and ESP8266 work on 3.3V, so no voltage converter is needed.

ESP8266 GND - Due GND
ESP8266 VCC - Due 3.3V
ESP8266 TX - Due RX3
ESP8266 RX - Due TX3
ESP8266 CH_PD - Due pin 53 (always HIGH)

The test program on Arduino Due simple redirect the received data from RX to TX3, and from RX3 to TX. Such that we can use Serial Monitor of Arduino IDE (TX/RX) to send command to ESP8266 (TX3/RX3). It act as a USB-Serial cable functionally. Pin 53 always High, such that the ESP8266 always NOT Power Down.



int LED = 13;
boolean LEDst = false;

//always high
int CH_PD_8266 = 53;

void setup() {
  Serial.begin(9600);
  Serial3.begin(9600);
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LEDst);
  pinMode(CH_PD_8266, OUTPUT);
  digitalWrite(CH_PD_8266, HIGH);
}

void loop() {
  while (Serial.available() > 0) {
    char a = Serial.read();
    Serial3.write(a);
  }
  
}

void serialEvent3() {
  while (Serial3.available() > 0) {
    char a = Serial3.read();
    Serial.write(a);
    ToggleLED();
  }
}

void ToggleLED(){
  digitalWrite(LED, LEDst = !LEDst);
}




Next:
- Arduino Due + ESP8266 - to Join AP