Monday, February 29, 2016

YellowJacket Arduino with WiShield Wifi (Part 6)

Adding an SD Card Shield for Data Storage — 
In Parts 4 and 5, the YellowJacket Wifi board was used as a web page server or to request a web page from a remote NOAA weather server. The wifi connection was to the local network which had remote internet connectivity through wired ethernet and to devices through local wireless wifi.
In this Part 6, an Adafruit SD Card is added for data storage. In later blogs, a sensor shield will be developed to collect data for storage on the SD Card and for transmission over wifi between two YellowJacket Arduinos and Macs on the local wifi network. The data will also be stored in a mySQL data base on a Mac. YellowJacket memory will also be expanded using a FRAM memory card and SPI.
Adafruit SD Card Shield

The SD Card Shield uses stackable headers so it can be used with other Arduino Shields. The SD Card Shield has a real time clock which is fairly accurate to time-stamp data that is stored on the SD Memory Card. The YellowJacket board does not have a real-time clock, so the SD Card Shield can provide that function.
One conflict among various Shields is the pin that is used as the SPI-CS pin for each particular SPI device. The Adafruit SD Card Shield has pin 10 hard-wired on the board and was modified by cutting the circuit board copper trace. The SD Card SPI-CS was then moved from pin 10 to pin 7 since the YJ had CS hard-wired to pin 10. YJ uses pin 9 for the wifi-active LED and YJ uses pin D8 as the wifi hibernate interrupt pin. The YJ runs sketches using the SD Card Shield with CS=pin 7. When SD Card CS was set to pin 8 (wifi hibernate), there was a conflict with WiServer sketches that would not init. The SD Card Shield has pin 3 jumpered to ==> green LED1; pin 4 jumpered to ==> red LED2; pin 13 ==> SD Card Shield red LED which is also the YJ pin 13 green SPI-CLK LED. Analog pins A4 and A5 are used by I2C connections to the Real Time Clock RTC.
With the SD Card Shield stacked with a YJ Shield, the various Adafruit SD Library example sketches could be compiled and run. Each sketch had to have the “const int chipSelect = 7;” modified to use pin 7 as the SD CS pin.
During sketch testing, SD Card Shield connections L1 and L2 were disconnected to use pins D3 and D4 for other purposes.
YJ Arduino and Custom Shield Pin Assignments
At this point we will take another look at hardware pin assignments on the YellowJacket Arduino with MRF24MB0MA Wifi backpack. The following list explains which pins are used for which purpose and identifies pins that are available for use in sketches.
  • Module spi_WS.h assigns INT0 (Pin D2) as WiShield interrupt.
  • Module g2100.h Driver for the ZeroG Wireless G2100 series devices also assigns ZG_INTERRUPT_PIN INT0 to Arduino D2.
  • Pin D0 ==> YJ-RX1 to Shield D0 (RX0), is also used for programming Arduino
  • Pin D1 ==> YJ-TX0 to Shield D1 (TX1), is also used for programming Arduino. YJ-TX0 is normally high, and blinks (LED/resistor to GND) low when data is sent out.
  • Pin D2 ==> Interrupt Out from MRF24 pin 33 ; (no Wifi Init conflict with SD Shield); D2 is hardware interrupt INT0 signal from MRF24, low=data transfer from MRF24, hi=MRF24 data transfer complete; D2 normally high, blinks (LED/resistor to GND) low during Wifi activity.
  • Pin D3 ==> N/C (INT1 and PWM) on YJ; SD Card Shield wires pin3 to LED1.
  • Pin D4 ==> N/C on YJ; SD Card Shield wires pin4 to LED2.
  • Pin D5 ==> N/C (PWM) on YJ
  • Pin D6 ==> N/C (PWM) on YJ
  • Pin D7 ==> N/C on YJ. SD Card Shield wires pin7 to SPI-CS
  • Pin D8 ==> Normally Low MRF24 CE ‘Hibernate’ off; High = Hibernate state. (WiServer Init conflict with SD Shield CS=pin 8)
  • Pin D9 ==> YJ (PWM) Wired to WIFI Active Green LED9. Used to indicate when Wifi is enabled=LED lit, set in uIP software.
  • Pin D10 ==> YJ (PWM) SPI CS/SS for MRF24 Wifi. MRF24 SS selected when LOW.
  • Pin D11 ==> YJ (PWM) SPI MISO/SDO. (Master In Slave Out)
  • Pin D12 ==> YJ SPI MOSI/SDI (Master Out Slave In)
  • Pin D13 ==> YJ SPI SCLK / SPI Green LED13 (SPI Clock)
  • Gnd ==> YJ GND
  • ARef ==> Test Point on 328P goes to N/C
  • SDA ==> N/C on YJ custom shield. Would connect to pin A4 for I2C.
  • SCL ==> N/C on YJ custom shield. Would connect to pin A5 for I2C.
  • Pin A0 ==> N/C on YJ
  • Pin A1 ==> N/C on YJ
  • Pin A2 ==> N/C on YJ
  • Pin A3 ==> N/C on YJ
  • Pin A4 ==> N/C on YJ. Used for I2C SDA in sketches. Used by SD RTC for I2C.
  • Pin A5 ==> N/C on YJ. Used for I2C SCL in sketches. Used by SD RTC for I2C.
  • RAW ==> YJ RAW is connected to Shield Vin >7 VDC. Onboard 5V and 3.3V converter from RAW to VCC and 3V3.
  • Gnd ==> YJ GND
  • 5V ==> VCC 5V from RAW, shield VCC, or USB programming header
  • 3.3V ==> 3V3 from RAW, onboard VCC, or shield VCC.
  •      **  WARNING the MRF24 is a 3.3V device.
  • RST ==> Reset when pin is low; normally high.
  • Arduino PWM digital pins are pins 3, 5, 6, 9, 10, and 11.
MRF24WB0MA Pin Interactions
  • MRF24 Hibernate to YJ pin D8 has no effect on YJ pin D9 LED.
  • D8 LOW=0V for Hibernate Off; D8 HIGH=3V3 for Hibernate On;
  • During sketch, if D8 is switched HIGH, MRF24 fails to re-engage activity once D8 is set LOW.
  • MRF24 will INIT with D8=0V GND or as normal D8=N/C.
  • MRF24 will not INIT with D8=3V3, and does not INIT after setting D8=LOW or 0V.
  • YJ pin D10 is 4.84V when WiServer sketch is running, which is holding the CS/SS pin HIGH. MRF24 SS is selected for SPI when LOW.
  • Connecting D10 to D3 SD Card Shield LED1, lights the LED1 but kills the Wifi connection.
  • After removing the D10=>D3, closing and re-opening Serial Monitor reboots the sketch and the Wifi connects. D10=>10K resistor=>D3 lights LED1 dim but Wifi continues to work.
(Feb 29, 2016)

Friday, February 26, 2016

YellowJacket Arduino with WiShield Wifi (Part 5)

YellowJacket WiShield SimpleClient Example — 
In Part 4 of this series, the SimpleServer sketch successfully accepted an http request over wifi from the Mac. Then the YellowJacket Arduino responded to the Mac over wifi by sending an http page to the Mac’s Safari browser. In this Part 5, “#define APP_WISERVER” will again be used in “apps-conf.h” as it was in Part 4. All other code modules must be commented out to remove them from the compiled code.
// WiShield Library module apps-conf.h must be modified to use WiServer code
//Include the header file for the application(s) we use in our project.
//define APP_WEBSERVER
//#define APP_WEBCLIENT
//#define APP_SOCKAPP
//#define APP_UDPAPP
#define APP_WISERVER
2) SimpleClient example WiServer sketch: SimpleClient is one of the WiShield Library example sketches that uses WiServer to request a web page from a remote host and return it to the client YellowJacket through Wifi. The YJ sketch sends a request over wifi to the the Network SSID (the Apple router in the local network) at the gateway_ip address. The request is then sent over TCP_IP through the internet to the remote weather server. The remote weather server sends back the http web page to the local Network SSID which then transmits the web page over wifi to the YJ. The YJ sketch then sends the response over the FTDI/USB cable to the Mac for display on the Serial Monitor. The example SimpleClient sketch (named “SimpleGetWeatherClient_V3”) was edited to use the YellowJacket local_ip and local network Wifi login info, and saved as SimpleGetWeatherClient_V3.ino. After downloading the compiled sketch to the YJ Arduino, the Arduino Serial Monitor on the Mac displays the progress of the YJ Arduino app. After the “WiServer.init(NULL);”, there will be a 30 second delay. Just be patient, the green LED (pin D9) will light on the YJ board and the app will send the request then listen for the server response over wifi.
 
=== Initializing WiServer as Client to display WX web page ===
=== WiServer is running... ===
>>> Request response on 10 sec intervals... 
The request “GETrequest getWeather(wx_ip, 80, “w1.weather.gov”, “/data/METAR/KLAX.1.txt”);”  is sent to the wx_ip address, which then responds with an http web page which is sent by the local Network SSID over wifi to YJ56 and displayed on Serial Monitor:
Connected to w1.weather.gov
TX 87 bytes
RX 0 bytes from w1.weather.gov
RX 329 bytes from w1.weather.gov
HTTP/1.0 200 OK
Server: Apache/2.2.15 (Red Hat)
X-NIDS-ServerID: www6.mo
Last-Modified: Fri, 26 Feb 2016 14:57:04 GMT
Accept-Ranges: bytes
Content-Length: 116
Content-Type: text/plain; charset=iso-8859-1
Date: Fri, 26 Feb 2016 15:00:12 GMT Connection: close 

000 
SAUS80 KWBC 221400 RRH 
MTRLAX METAR KLAX 221453Z 00000KTRX 56 bytes from w1.weather.gov 
 10SM FEW020 15/10 A3006 RMK AO2 SLP179 
T01500100 53010 
Ended connection with w1.weather.gov
The Arduino SimpleGetWeatherClient_V3 sketch code:
/* SimpleGetWeatherClient_V3
 *
 * A simple sketch that uses WiServer to get the 10-second weather data from LAX and prints
 * it via the Serial API
 *
 * Compiled with WiShield_V3 library
 *
 * Uses apps-conf.h "#define APP_WISERVER"
 *
 * Serial Monitor Response from
 * "GETrequest getWeather(wx_ip, 80, "w1.weather.gov", "/data/METAR/KLAX.1.txt");"
 *
 */
//#include <WiShield.h>
#include <WiServer.h>

#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,0,1,56};  // IP address of WiShield
unsigned char gateway_ip[] = {10,0,1,1};  // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};  // subnet mask for the local network
const char ssid[] PROGMEM = {"Network"};   // max 32 bytes

const char* myhost = "WiServer";
char* myhost_ip = "10.0.1.56";

unsigned char security_type = 3;  // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const char security_passphrase[] PROGMEM = {"Network_Passcode"};  // max 64 characters

// WEP 128-bit keys
// sample HEX keys
const uint8_t wep_keys[] PROGMEM = {  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  // Key 3
                };

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------

// Function that prints data from the server
void printData(char* data, int len) {

 // Print the data returned by the server
 // Note that the data is not null-terminated, may be broken up into smaller packets, and
 // includes the HTTP header.
 while (len-- > 0) {
 Serial.print(*(data++));
 }
}

//uint8 wx_ip[] = {140,90,113,200}; // old IP Address for www.weather.gov
uint8_t wx_ip[] = {23, 67, 242, 42}; // IP Address for w1.weather.gov (2016-02-25)

// A request that gets the latest METAR weather data for LAX
GETrequest getWeather(wx_ip, 80, "w1.weather.gov", "/data/METAR/KLAX.1.txt");

void setup() {
 
 // Enable Serial output
 Serial.begin(115200);

 Serial.println (" ");
 Serial.println ("=== Initializing WiServer as Client to display WX web page ===");

 // Initialize WiServer (we'll pass NULL for the page serving function since we don't need to serve web pages)
 WiServer.init(NULL);

 // Ask WiServer to generate log messages (optional)
 WiServer.enableVerboseMode(true);

 // Have the processData function called when data is returned by the server
 getWeather.setReturnFunc(printData);

 Serial.println (" ");
 Serial.println ("=== WiServer is running... ===");
 Serial.println (">>> Request response on 10 sec intervals... ");
 Serial.println (" ");

}

// Time (in millis) when the data should be retrieved 
unsigned long tempTime = millis();
unsigned long updateTime = tempTime;
unsigned long waitTime = 1000UL * 10UL ; // must use unsigned long numbers

void loop(){

 tempTime = millis();
 
 // Check if it's time to get an update
 if (tempTime >= updateTime) {
 Serial.println (" "); // add blank line to Serial Monitor display
 getWeather.submit(); 
 /* DEBUG
 Serial.println (" ");
 Serial.print (" >> If 1: millis() = ");
 Serial.print ( tempTime );
 Serial.print (" updateTime = ");
 Serial.print ( updateTime );
 Serial.print (" waitTime = ");
 Serial.println ( waitTime );
 End DEBUG */
 // Get another update 10 seconds from now
 updateTime += waitTime;
 /* DEBUG
 Serial.print (" Revised updateTime = ");
 Serial.println ( updateTime );
 End DEBUG */
 }
 
 // Run WiServer
 WiServer.server_task();
 
 delay(10);
}
 (Feb 26, 2016)

Thursday, February 25, 2016

YellowJacket Arduino with WiShield Wifi (Part 4)

YellowJacket WiShield SimpleServer Example — 
Hardware Network: The network setup for software development was an Apple ethernet/wifi router at ip address //10.0.1.1/, a MacBook Pro (wifi ip address //10.0.1.64/), and two YellowJacket Arduino/Wifi boards (YJ56 with wifi ip address //10.0.1.56/, and YJ57 with wifi ip address //10.0.1.57). The Arduino IDE 1.6.5 was run on the MacBook, and compiled sketches were downloaded to the YJ boards through a USB/FTDI cable to the header pins on the YJ boards. The USB/FTDI cable provided the +5V to the YJ board, the means for downloading compiled code to the YJ Arduino microprocessor, and the means for the YJ Arduino to send debugging information back to the Arduino IDE Serial Monitor on the Mac. The compiled sketch code then executed on the YJ Arduino which controlled the on-board wifi backpack hardware which handled the wifi communication with the external MacBook.
WiShield Software: Initially, no example apps distributed with the AsyncLabs WiShield library would compile. One of the first websites found which gave some clues as to the problems with the library was “Ref: http://www.sundh.com/blog/2012/02/make-wishield-work-in-latest-arduino-ide/”. After much investigation, the best library as of 2016-02-25, was the “Ref: https://github.com/kaptk2/ZG2100BasedWiFiShield” library, which was saved locally as WiShield_V3 library in the Arduino user directory. This library, with code fixes included, worked with Arduino IDE 1.6.5 software release.
The WiShield library is a large and complex set of code. To allow the code to be as small as possible for use with the Arduino’s limited memory, different code modules must be included and excluded for specific purposes. The WiShield Library code module “apps-conf.h” must be edited to use the proper code to be included during software compile of a specific Arduino sketch. In the following code snippet, “#define APP_WISERVER” is not commented out, so it will be used with the sketch code being compiled. All other code modules must be commented out to remove them from the compiled code.
//Include the header file for the application(s) we use in our project.
//define APP_WEBSERVER
//#define APP_WEBCLIENT
//#define APP_SOCKAPP
//#define APP_UDPAPP
#define APP_WISERVER
A second code module, “uip-conf.h”,  also needs attention when using UDP. There is a code switch in lines 105-115 that must be set properly. For all applications not using UDP, this switch must be set to zero.
/**
 * UDP support on or off
 *
 * \hideinitializer
 *
 * If the UIP_CONF_UDP flag is set improperly the following error will result
 * uip.h:1250:3: error: unknown type name 'uip_udp_appstate_t' uip_udp_appstate_t appstate;
 *
 */
 #define UIP_CONF_UDP      0     // default = 0
 // #define UIP_CONF_UDP   1  // jung from 0 to 1 for APP_UDPAPP only
1) SimpleServer example WiServer sketch: SimpleServer is one of the WiShield Library example sketches that uses WiServer to serve a web page from a YellowJacket through Wifi. The example SimpleServer sketch was edited to use the YellowJacket local_ip and local network Wifi login info, and saved as SimpleServer_V3.ino. After downloading the compiled sketch to the YJ Arduino, the Arduino Serial Monitor on the Mac will display the progress of the YJ Arduino app. After the “WiServer init called” response, there will be a 30 second delay. Just be patient, the green LED (pin D9) will light on the YJ board and the app will listen for wifi communication.
>> SimpleServer_V3 sketch 
>> WiServer.server_task initialized on WiServer, ip: 10.0.1.56
>> Listening for connections... 
Typing “http://10.0.1.56:80/“ in the Safari browser on the Mac sent an http request over wifi to YJ56, which then responded over wifi to Safari on the Mac:
Hello from YellowJacket Wifi MRF24 SimpleServer_V3!
and the Serial Monitor displayed:
Server connected
Processing request for /
TX 83 bytes
Server connection closed 
The Arduino SimpleServer_V3 sketch code:
/* 
 * SimpleServer_V3
 * A simple sketch that uses WiServer to serve a web page
 * 
 * This code is run with WiShield_V3 library
 * ref: https://github.com/linksprite/ZG2100BasedWiFiShield
 * The library was edited as described in 
 * ref: https://github.com/kaptk2/ZG2100BasedWiFiShield/commit/dea4af4b50e3700668365df37d9533b7fd31cf0a
 * 
 * 
 * V3 Library files required updates for Arduino V1.6.5
 * apps-conf.h #define APP_WISERVER
 * config.h
 * strings.c V3 mods required for web page serving
 * WiServer.cpp
 * witypes.h
 * 
 * This sketch code required edits to prog_char and prog_uchar
 * The primary web page can be requested by http://10.0.1.56:80/
 * The web page displays properly.
 * WiServer.cpp Verbose provides Serial Monitor monitoring of http requests.
 * 
 */

//#include <WiShield.h>
#include <WiServer.h>

#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,0,1,56};  // IP address of WiShield
unsigned char gateway_ip[] = {10,0,1,1};  // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};  // subnet mask for the local network
const char ssid[] PROGMEM = {"Network"};   // max 32 bytes

const char* myhost = "WiServer";
char* myhost_ip = "10.0.1.56";

unsigned char security_type = 3;  // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const char security_passphrase[] PROGMEM = {"Network_Passcode"};  // max 64 characters

// WEP 128-bit keys
// sample HEX keys
const uint8_t wep_keys[] PROGMEM = {  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  // Key 3
                };

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;

unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------


// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
  
    // Check if the requested URL matches "/"
    if (strcmp(URL, "/") == 0) {
        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<html>");
        WiServer.print("Hello from YellowJacket Wifi MRF24 SimpleServer_V3!");
        WiServer.print("</html>");
        
        // URL was recognized
        return true;
    }
    // URL not found
    return false;
}


void setup() {
  // Enable Serial output
  Serial.begin(115200);
  // /*
  Serial.println("");
  Serial.println(">> SimpleServer_V3 sketch ");  
  Serial.print(">> WiServer.server_task initialized on ");  
  Serial.print(myhost);
  Serial.print(", ip: ");
  Serial.println(myhost_ip);
  // */
  
  // Initialize WiServer and have it use the sendMyPage function to serve pages
  WiServer.init(sendMyPage);
  
  // Verbose=true >> ask WiServer to generate log messages to Serial Monitor
  WiServer.enableVerboseMode(true);
  
  Serial.println("");
  Serial.println(F(">> Listening for connections..."));

}

void loop(){

  // Run WiServer
  WiServer.server_task();
 
  delay(10);
}
 (Feb 25, 2016)

Monday, February 22, 2016

YellowJacket Arduino with WiShield Wifi (Part 3)

YellowJacket Board Setup — 
The YellowJacket board is a self contained Arduino, much like the Sparkfun Arduino Pro Mini 328 – 5V/16MHz, but the YellowJacket includes the DTR Reset pin on the programming header. The user Arduino sketch which #includes the WiShield software sets the ip address for the wifi backpack.
Initial Set Up
1) Solder header pins to YellowJacket (YJ) board. A set up 6 long header pins, bent to 90 degree angles were soldered to the YJ board for connection to an Adafruit FTDI Friend programmer through USB to a Mac running the Arduino IDE. The FTDI programmer provides +5V from the USB connection to the YJ board. The YJ board converts the +5V to +3.3V for the MRF24 wifi backpack. Both +5V and +3.3V are connected to their respective pins near the header pins on the YJ board. If RAW (>+5v) is provided to the YJ board on the RAW pin, that voltage will be converted to +5V and +3.3V in addition to any power from the FTDI/USB port.
2) Wired YJ to Adafruit FTDI Friend for programming using 6 wire FTDI connections. The two GND pins on the YJ header are connected on the YJ board which shorts the FTDI Friend CTS and GND pins together.
YJ Header Pins        5V - Gnd - Gnd - Vcc - RX1 - TX0 - DTR - 3.3V
                      NC    |     |     |     |     |     |     NC
UNO pins                         GND    5V   RX0   TX1   Reset
Adafruit USB-FTDI Cable:   Gnd   CTS  VCCOUT  TX    RX   RTSDTR
3) Plug YJ FTDI cable into USB and program vanilla example “Blink” sketch. The YJ red power LED lights when USB power is applied through the FTDI programmer. The Arduino Blink sketch was compiled in the Arduino IDE and loaded over the USB-to-FTDI programmer connected to the YJ board header. The FTDI RX/TX LEDs blinked as the Blink program loaded with no compile errors and then pin 13 LED blinked on/off. This basic Blink app indicated that the YJ Arduino board was operational.
The dedicated FTDI/USB programmer, shown here connected to the YJ57 board and shield, was an additional expense but it was a great time saver during software development and testing.



Alternative Programming Method Using an Arduino UNO as FTDI to program YJ:
Ref: http://www.instructables.com/id/Arduino-Examples-2-Use-an-Arduino-as-a-FTDI-Progr/
Using the steps outlined in the referenced instructable, an Arduino UNO with a socketed microprocessor chip (not soldered surface mount) can be used as an FTDI programmer if a dedicated FTDI programmer cable is not available. First, wire Uno to YJ header:
  • Arduino UNO pin: Gnd  Gnd  5V  RX(D0) TX(D1)  Reset
  • YJ Header pin:   Gnd  Gnd  5V  RXI    TXO     DTR
AVRDude Problem uploading sketch to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
Solution was “You must remove the atmega328 from the Arduino UNO or the programming will not save on either device.” Use care to lift the atmega328 processor chip from its socket on the Uno without severely bending the pins and store it in a safe place.
YJ Programmed with “Blink” sketch: The solution to the above errors was to remove UNO CPU chip and then the YJ programmed “Blink” without errors. The Pin 13 Green LED began blinking on/off. Changing Pin 13 to Pin 9 in the sketch will blink the YJ Pin 9 Green LED.
  • Pin 13 Green LED blinks several times while the YJ is programmed.
  • YJ Header GND pins are connected on board.
  • YJ Red power-on LED is lighted when 5V power is provided through the USB cable.
  • YJ Pin 13 blinks the Green LED next to the RESET push button.
  • YJ Pin 9 blinks the Green LED second from the RESET push button and closest to pins 12 and 13.
Wiring the YJ Arduino Pins and Shields
Pins – Four types of pins are used for shield construction, and the terminology can get a bit messy. There are Male-Male pins and Female-Male pins. Male-Male pins are straight wires on both ends with a piece of plastic which will hold the pins at a fixed spacing of 0.1″ which neatly fit into the 0.1″ hole spacing used in most shields. Female-Male pins have a Female socket on one end to receive a Male pin or jumper wire that has the insulation removed. Kits of jumper wires of various lengths and colors that push into the female header or slip over the male pins are handy for prototyping circuits. Left to right in the photo: female header, stacking header, male header, and extra-long male header.
YJ56 – In addition to the 6 programming header pins and the +5V and +3.3V pins, the YJ board has holes for 12 pins down both sides of the board. On the board named YJ56, stacking headers with long pins were soldered on the YJ MRF24 side of the board so that the long headers could be pushed into breadboard sockets that would receive the pins. The breadboard can be used to easily wire additional components  for prototyping circuit designs. The breadboard was taped onto a blank Arduino shield that had long headers with female sockets that backpack onto other Arduino shields.
 The YJ56 board uses female stacking sockets with long male pins along the sides of the board. The sockets with long pins were soldered on the bottom (MRF24 side) so
they could push into a breadboard for prototyping circuits. The FTDI header pins (photo bottom edge) are bent at 90 degrees to attach to the FTDI programmer 6-pin socket. These pins can not extend into the breadboard since the breadboard shorts these sockets together across the breadboard. Wires are used to make connections from the YJ56 sockets to the red shield sockets that stacks onto other shields.

Side view of YJ board with stacking pins soldered through YJ and pushed into breadboard. The breadboard was taped to a shield for prototyping circuits. The breadboard is just wide enough to accept the pins from the YJ board. Wires provide the connections between the YJ board and the shield.

YJ57 – The YJ57 used a different, more permanent design by using short header pins on the YJ board that push into a shield made with short female stacking sockets that receive the YJ57 pins. The YJ57 shield used stacking long header pins to backpack onto other Arduino shields, such as, SD memory shield, Sensor shield, and LED display shield.
On the YJ57, short header pins were soldered on the YJ Arduino side of the board with long side down from the Wifi backpack side of the board. These pins plug into the center sockets on the shield. The FTDI header pins are long pins bent at a 90 degree angle on the top of the board for the FTDI connection. The straight header pins on the bottom side of the board make the wiring connection for FTDI and +5V and +3.3V to the YJ57 shield.

The YJ57 shield was created with female socket/long male header pins so it could stack with other Arduino Uno shields. Inner short female sockets were installed to plug in the YJ57. Wires were solder on the top and bottom of the shield to make the pin-to-pin connections between the YJ Arduino pins and the shield pins. The 5-pin female socket on the top edge of the board are shorted together to provide a tie point when multiple wires need to share a signal.

This image shows the YJ57 board backpacked onto the shield which can be stacked with other Arduino shields.




(Feb 22, 2016)

Saturday, February 20, 2016

YellowJacket Arduino with WiShield Wifi (Part 2)

YellowJacket Hardware Details — 
The YellowJacket (YJ) Wifi board is composed of two primary components: 1) an Arduino Uno-equivalent microprocessor board; and, 2) a Microchip MRF24WB0MA wifi backpack. A considerable amount of time was spent tracing connections between the two boards to understand the hardware design. Following is a fairly in-depth report on the hardware.















  • YJ board contains the Atmel Mega328P-AU AVR which serves as Arduino UNO.
  • YJ board uses KA7805R to convert RAW (7-24V) to 5v.
  • YJ board uses ST-L1117-33 to convert ~5v to 3.33v @ 800ma.
  • YJ Vin = RAW > 5v, VCC = 5v.
  • YJ 16 mhz resonator.
  • YJ Red LED 5V Power on indicator.
  • MRF24 pin 23 ==> YJ pin 10; SPI CS for MRF24.
  • YJ Pin 13 Green LED indicator next to Reset push button.
  • YJ Pin 9 Green LED indicator next to pins 12-13, set on/off in WiServer software
  • FTDI programming ports on end of board to USB/FTDI pins (Gnd, Gnd, 5V, TX, RX, DTR/Reset)
    • or, can be connected to external Shield pins (Gnd, Gnd, 5V, RX(D0), TX(D1), Reset)
  • Microchip MRF24WB0MA Wifi
  • 802.11b Wireless (WLAN) Wifi 11 Mbps, 2.4 Ghz band.
YJ Arduino UNO-equivalent Features
  • ATMega328 microprocessor running at 16MHz with external resonator
  • Uses FTDI cable for Arduino programming
  • Supports auto-reset
  • Raw DC input 7V up to 16V
  • 5V regulator to VCC and VOUT
  • 3.3V regulator (max 800ma)
  • Over current protected
  • On board red Power and 2 green Status LEDs
  • Analog Pins: 6
  • Digital I/Os: 14, 0=RX, 1=TX
  • No on-board USB port.
  • No on-board memory card connections.
  • WiShield original code does not support DNS; must use IP addresses.
  • No UART level shifting due to on board direct connections to Arduino.
ATMega328 Microprocessor Features
  • Atmel 8-bit AVR
  • Absolute maximum VCC: 6V
  • Maximum current for chip: 200mA
  • Maximum current per pin: 40mA
  • Recommended current per pin: 20mA
  • Flash Program Memory: 32kB
  • EEPROM: 1kB
  • Internal SRAM 2kB
  • ADC: 10-bit
  • PWM: 8bit
YellowJacket Microchip MRF24WBOMA Wifi Module
The Microchip MRF24WB0MA Wifi (aka MRF24) module is installed as a backpack on the YellowJacket breakout board to provide wifi capability on an Arduino UNO platform (aka YJ Arduino). A YellowJacket circuit diagram was requested and received from Rugged Circuits (non-disclosure agreement). JTAG (N/C) pins are for testing circuit boards and are not used in Arduino applications.
Note:
  • YJ Arduino pin D1 is High when MRF24 is active. Blinks low on signal activity.
  • YJ Arduino pin D2 <=> MRF24 INT0 pin blinks low on wifi activity. Do not use pin D2 in apps.
  • YJ Arduino pin D8 is MRF24 hibernate. Do not use pin D8 in apps.
  • YJ Arduino pin D9 is used by WiServer software to indicate MRF24 is active.
  • YJ Arduino pin D10 is MRF24 SPI CS pin. Do not use pin D10 in apps.
  • YJ Arduino pins D11, D12, and D13 are SPI pins. Use in apps for SPI control.
  • YJ Arduino pin Vin == pin RAW (+7-12VDC). Pin RAW provides power to => KA7805R which outputs 5V to => L1117 which outputs 3V3.
MRF24WB0MA Circuit Design and Pinouts




 The MRF24WB0MA backpack module is a 3.3V surface mount 36 pin device with integrated wifi antenna. The YJ Arduino is a 5V device which provides 3.3V for the wifi module.

Reference: http://ww1.microchip.com/downloads/en/DeviceDoc/70632C.pdf
Typical circuits with the MRF24WB0MA use a few pull-up and pull-down resistors and filtering capacitors for power conditioning and to interface to an external microprocessor board.
The MRF24WB0MA module uses SPI pins CS, SDO, SDI, and SCK, plus INT to communicate with an external microprocessor.
MRF24 Pin Connections
MRF24 Pin ==> Visible Connection on YellowJacket Board
01 ==> Gnd
04 ==> TCK to MRF24 pin 16 both pulled high to +3V3
07 ==> Reset normally high, asynchronous hardware reset when pin=low for the MRF24 module
10 ==> Gnd
16 ==> Write protect (this pin is used to enable FLASH update) to MRF24 pin 04 Write-protect for the internal module SPI Flash.
17 ==> VDD3V3
18 ==> Gnd
19 ==> Gnd
20 ==> ‘Hibernate’  CE connected to YJ Arduino pin D8; Hibernate mode enable (high input will disable the module)
23 ==> SPI CS connected to YJ Arduino pin D10 CS
25 ==> Gnd
26 ==> Serial debug port input (Connected on board?)
27 ==> Serial debug port output  (Connected on board?)
28 ==> Gnd
29 ==> +VDD 3.3V
30 ==> Gnd
32 ==> SPI SDO Data Out to YJ Arduino pin D12 MISO
33 ==> Interrupt Out connected to YJ Arduino hardware interrupt pin D2; (active low interrupt indicator pin (~INT), which is asserted low by the MRF24 when data is available for the host device. The ~INT line is de-asserted high after the data transfer is complete.)
34 ==> SPI SCK Clock Input to YJ Arduino pin D13 CLK
35 ==> SPI SDI Data In to YJ Arduino pin D11 MOSI
36 ==> Gnd
(Feb 20, 2016)

Thursday, February 18, 2016

YellowJacket Arduino with WiShield Wifi (Part 1)

Short History — 
Several years ago (probably 2010) I purchased two hard to get YellowJacket Wifi boards from Rugged Circuits. The YellowJacket board incorporates a wifi backpack module on an Arduino Uno-equivalent microprocessor. At that time, wifi on a microprocessor was a dazzling concept, but BlueTooth Low Energy (BLE-4) technology soon emerged as a versatile means of communication between a microprocessor chip and an iPhone. The YellowJacket Wifi boards sat unused since that time. Recently I had the inclination to use Wifi technology for a project and dusted off these boards. In the intervening 5 years, technology had moved a bit, there was almost no information on the Rugged Circuits YellowJacket board on the web, and the WiShield software that was required for the board was no longer supported by the author. This series of blogs will examine how I moved forward with using YellowJacket Wifi boards.
As a backdrop for this series of blogs, my local development network is comprised of several Mac computers (with Windows running on  Bootcamp partitions), connected through ethernet and/or wifi to an Apple ethernet/wifi router. The router uses the default ip address //10.0.1.1/  and ethernet and wifi ip addresses are assigned either automatically or manually by the router. The YellowJacket boards were manually assigned ip addresses //10.0.1.56/ (board identified as YJ56) and //10.0.1.57/ (board identified as YJ57). The Mac computers are currently running OS X 10.10 Yosemite or 10.11 El Capitan. Arduino IDE 1.6.5 is used for Arduino code development.
YellowJacket Hardware and Wifi Software

The YellowJacket (YJ short name) WiShield board briefly manufactured by Rugged Circuits comprises an Arduino Uno-equivalent microprocessor with a Microchip MRF24WB0MA Wifi backpack.
The original AsyncLabs WiShield precursor to the YellowJacket used the ZeroG ZG2100 Wifi board, which was bought out by Microchip in January 2010 and then presumably marketed (probably with some design changes) as the MRF24B0MA. The AsyncLabs WiShield code library on GitHub can be used to program the YellowJacket Arduino/Wifi board. My current version of the Arduino development software (IDE) is version 1.6.5, which compiles the original 2010 WiShield software with errors. For Arduino 1.6.5, the WiShield library (as of 2016-02-25) modified by “kaptk2” (Ref: “https://github.com/kaptk2/ZG2100BasedWiFiShield”) fixed most all of the compile errors. This version of the WiShield library was the third I had tried to use with the YellowJacket boards and is referred to in this blog as “WiShield_V3” as the Arduino Library name.
One early problem getting the hardware and software to work was that spi.h code in the WiShield library conflicted with spi.h code used by other devices. For clarity, the WiShield Library spi.h was renamed spi_WS.h and that reference was changed to “#include spi_WS.h” in all files in WiShield_V3 library. Renaming the WiShield library spi_WS.h file, fixed the conflicts with SPI.h used by other Arduino devices. The WiShield spi_WS.h is specific to the spi interface between the YJ Arduino and the MRF24 Wifi backpack.
As I became more proficient with the YellowJacket boards and WiShield software, I located other versions of the WiShield software on GitHub that had been updated and incorporated additional features. My most recent WiShield_V14 Library is that contributed by “hamityanik” (Ref: https://github.com/hamityanik/WiShield_user_contrib) which compiles without errors on Arduino IDE 1.6.5.
Future blogs will provide details on using the YellowJacket Wifi boards for various wifi applications.
(Feb 18, 2016)