Thursday, 2 April 2015

The Cactus Micro - $11 Arduino-compatible with ESP2866 wi-fi integrated

I recently purchased the Cactus Micro (made by aprbrother.com) - it is available on Tindie as well as through this eBay seller.


I have been quite impressed with this item, especially for $11.  It is an Arduino Micro (same driver as Arduino Leonardo or Lilypad USB) and integrates an ESP8266 wi-fi module on pins 11 and 12 for software serial.

Update 2015-07-10: The Cactus Micro now has a version 2 with a few minor but useful improvements.  Mainly, the wifi module has better options to use hardware serial, and the wifi module is now an SMD connected unit instead of plugged in with a connector.







Here is how to get started quick and easy on Windows:

  1. Make sure you have a working Arduino IDE set up.
  2. Plug the Cactus Micro in via micro-B USB cable.  Red power LED should light.
  3. Let your computer think about what you have plugged in.  
    1. Open Device Manager
    2. You should see something under "Ports"
    3. If it worked, you see Lilypad with a COM Port number.
    4. Otherwise you see it as an unknown device.
      1. If it's unknown, manually select a driver location and choose the Arduino Drivers folder from the location where you installed the Arduino IDE.  That should do it.
      2. If this all fails, follow the instructions for getting running and troubleshooting from Arduino.cc for the Lilypad USB or Arduino Leonardo.
  4. Open the Arduino IDE and select "Lilypad USB" as the board.
  5. Select the same COM port shown in the Device Manager.
  6. Modify the test sketch below with the SSID and password of your local wireless network.
  7. Upload the test sketch.
  8. Open the serial terminal from the IDE (9600 baud) to watch the unit wake up and connect to the wi-fi network.  You're done!
Test code:
#include <SoftwareSerial.h>
 
// Important!! We use pin 13 for enable esp8266
#define WIFI_ENABLE_PIN 13
 
#define DEBUG 1
 
#define SSID "YOUR SSID HERE"
#define PASS "YOUR WI-FI PASSWORD HERE"
 
char serialbuffer[100];//serial buffer for request command
int wifiConnected = 0;
 
SoftwareSerial mySerial(11, 12); // rx, tx
 
void setup()
{
mySerial.begin(9600);//connection to ESP8266
Serial.begin(9600); //serial debug
 
if(DEBUG) {
while(!Serial);
}
 
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(1000);//delay
 
//set mode needed for new boards
mySerial.println("AT+RST");
delay(3000);//delay after mode change
mySerial.println("AT+CWMODE=1");
delay(300);
mySerial.println("AT+RST");
delay(500);
}
 
boolean connectWifi() {
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";
Serial.println(cmd);
mySerial.println(cmd);
for(int i = 0; i < 20; i++) {
Serial.print(".");
if(mySerial.find("OK"))
{
wifiConnected = 1;
break;
}
delay(50);
}
Serial.println(
wifiConnected ?
"OK, Connected to WiFi." :
"Can not connect to the WiFi."
);
return wifiConnected;
}
 
void loop()
{
 
if(!wifiConnected) {
mySerial.println("AT");
delay(1000);
if(mySerial.find("OK")){
Serial.println("Module Test: OK");
connectWifi();
}
}
 
if(!wifiConnected) {
delay(500);
return;
}
 
//output everything from ESP8266 to the Arduino Micro Serial output
while (mySerial.available() > 0) {
Serial.write(mySerial.read());
}
 
} 

Going Further

1 comment: