M328W

From Wiki for Dragino Project
Revision as of 03:03, 16 June 2015 by Edwin1123 (Talk | contribs) (Program and upload sketch)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

Wireless Internet of Things Module - M328W

M328W Arduino Internet of Things module is designed for the easy of programming and installation for IoT projects where wireless protocol (zigbee, bluetooth, 433Mhz etc) is required. It is a plug-in module for MS14 and powered by an ATMEL ATmega328P micro-controller.

The M328W has a standard XBEE Socket and RFM12B footprint to implement different wireless protocol modules. It also has a breadboard area for easy prototyping.

Wireless Internet of Things Module - M328W

M328W is Arduino Yun compatible. It can be programmed and debug by the Arduino IDE (ver 1.5.4 or later) via WiFi.

With the combination of MS14, M328W and Arduino Yun software, user can install / prototype Internet of Things projects in an easy / rapidly way.




Features

  • Bridge various wireless protocols such as zigbee, bluetooth, NFC into WiFi IP network.
  • Internet of Things Gateway module to connect sensor network to internet.
  • Log sensor data and upload to remote server.
  • Control switch/relay from Internet.
  • Arduino IDE compatible, can be programmed /debug by Arduino IDE
  • Program/update/ debug via WiFi network.



Specification

Microcontroller ATmega328P
Operating Voltage 3.3V
I/O voltage 3.3V
SRAM 2.5KB
Flash Memory 32KB(of which 4KB used by bootloader)
EEPROM 1KB
Clock Speed 16Mhz
Digital I/O pins 13
Analog input channels 6
PWM channels 3
BEE Socket 1
ESD-protection IEC 61000-4-2
Over Voltage Protect



System Structure

Top View of M328W
Bottom View of M328W



Operation Voltage

M328W gets 3.3v power from MS14. All the I/O's of M328W is 3.3v level.

Control LED

M328W uses IO8 control the HEART LED of MS14. User can set the IO8 to HIGH to turn on the HEART LED or set IO8 to Low to turn off it.

Coding Switch

M328W has a coding switch S1 can be used to disable/enable the connection between:

  • Mega328P SS pin <--> MS14 GPIO23.
  • Mega328P IO5 <--> MS14 Cold Reset. Be careful to use this pin. HIGH on cold reset will put the MS14 in reset status. this can be used for hardware watchdog for MS14.



Add Profile in IDE, program and upload sketch

User can use Arduino IDE to program the m328w and use ms14 to upload sketch to it via wifi / LAN, the upload method is Yun alike, reference link is Program and Upload Sketch Yun Alike. The m328w uses mega328p mcu so the profile in Arduino IDE should choose: Arduino UNO -- Dragino Yun



Playground

RFM69CW-------- 433/868/915 MHz Radio

Introduction

The M328W has RFM69CW footprint at the bottom side of PCB. User can solder a RFM69CW module and communicate with other RFM69 in 433/868/915Mhz wireless protocol The RFM69CW module is connected to Mega328P via hardware SPI interface. The library used for the RFM69CW is the LowPowerLab RFM69 Library.

Notice:The LowPowerLab RFM69 library examples use the hardware Serial to print debug info. The Bridge Class in Arduino Yun also will also use the hardware Serial interface. To avoid conflict, when Bridge Class is used, user should remove the Serial function in the LowPowerLab examples, or replace them with Console function.


There are two antenna options for RFM69CW module: 1) solder a wire to the ANT hole on M328W or 2) solder the I-PEX/U.FL connector to use an external Antenna.

Install a RFM69CW module on M328W

User also need to solder a 100k pull up resistor in the SS pin of MEGA328P, otherwise the Arduino IDE can't program the M328W while there is RF69.

Solder a 100k pull up resistor to SS pin


Example This example will show the send/receive demo between two M328W with RFM69CW installed. the sketch used here are a modified version from LowPowerLab Send/Receive demo.

  • Device Running Send Sketch: This device keeps sending packets to pre-configure node ID and network. it waits for the ACK and print the status info in the Console. Sketch Code
  • Device Running Receive Sketch: This device will check if any packets arrives in same network. it will send back a ACK and print the status info in the Console.Sketch Code
RFM12B Demo Send Receive





RFM12B -------- 433/868/915 MHz Radio

Introduction

The M328W has RFM12B footprint at the bottom side of PCB. User can solder a RFM12B module to support 433/868/915 Mhz protocol. The RFM12B module is connected to Mega328P via hardware SPI interface. The library used for the RFM12B is the LowPowerLab RFM12B Library.

Notice:The LowPowerLab RFM12B library examples use the hardware Serial to print debug info. The Bridge Class in Arduino Yun also will also use the hardware Serial interface. To avoid conflict, when Bridge Class is used, user should remove the Serial function in the LowPowerLab examples, or replace them with Console function.


There are two antenna options for RFM12B module: 1) solder a wire to the ANT hole on M328W or 2) solder the I-PEX/U.FL connector to use an external Antenna.

Install a RFM12B module on M328W


Example This example will show the send/receive demo between two M328W with RFM12B installed. the sketch used here are a modified version from LowPowerLab Send/Receive demo.

  • Device Running Send Sketch: This device keeps sending packets to pre-configure node ID and network. it waits for the ACK and print the status info in the Console. Sketch Code
  • Device Running Receive Sketch: This device will check if any packets arrives in same network. it will send back a ACK and print the status info in the Console.Sketch Code
RFM12B Demo Send
RFM12B Demo Receive



XBee -------- 2.4G Zigbee Radio

Introduction

M328W with a XBee Pro Bee

The M328W has a standard XBee socket. User can plug in a XBEE module to communicate with 2.4G zigbee network

Configure XBee

User can program the Xbee from computer by X-CTU or by the MS14 itself by minicom.

To configure XBee module from MS14, we should do below things. Below first three settings can be done by select the Sensor --> Operation Mode to BEE Console and reboot the ms14.

  • Disable UART console
  • Disconnect UART to mega328p by setting GPIO24 to Low
  • Connect UART to XBee by setting GPIO27 to HIGH
  • make sure mega328p's IO7 , IO6 are not in output mode. This can be done by put mega32u4 into reset state (GPIO20 to HIGH).


Then we can use minicom to configure the XBee. in SSH access, run minicom and configure minicom as:

  • Serial Device: /dev/ttyATH0
  • Bps/Par/Bits  : 9600 8N1
  • Hardware Flow Control : No
  • Software Flow Control : No
  • Add linefeed : ON
  • local Echo on/off : ON

In minicom, type +++ to enter XBee configure mode( don't press ENTER after type +++ ). Then the xbee module return OK and you can type the commands as decribed in XBee Commands. Below is a screen shot to show how to set the XBee ID. NOTE: XBee will exit configure mode if there is no input for several seconds.

Use minicom to configure XBee module


Reset XBee

Several methods to reset XBee, this will discard the current change after a ATWR command.

  • Push the BEE_RESET button
  • Set GPIO26 to HIGH
  • Reboot Device.



Test XBee: Echo Test Example Get Source

To use XBee with mega32U4, we first have to set up the UART mode to Sensor --> Operation Mode to Arduino-Bridge. Then can programm the XBee with below code and instructions to finish a simple echo test:

//This sketch is an echo test for the ms14+m32w+XBee
//This test use two XBee module, XBee-A is connected to PC and control by X-CTU tool. XBee-B is loaded in the m32w. 
//Both XBee are pre-configure to work at the same network. 
//User can put chareters in X-CTU so the chars will be sent from XBee-A to XBee-B then to m32w, m32w will return the same to XBee-A so to finished
//a simple echo test. 
//2014-03-13 Dragino Technology Co., Limited 
 
#include <SoftwareSerial.h>
#define rxPin 7  // RX Pin on the Xbee socket
#define txPin 6   // TX Pin on the Xbee socket
SoftwareSerial xbee =  SoftwareSerial(rxPin, txPin);
 
void setup(){
  xbee.begin(9600);
}
 
 
void loop(){
  if (xbee.available() > 0){
   xbee.write(xbee.read());
}
Echo Test Result shown in X-CTU




Bluetooth Bee -------- 2.4G Bluetooth V2.0

Introduction

M328W and a Bluetooth Bee

The M328W has a standard XBee socket. User can plug in the Bluetooth Bee HC-05/HC-06 to communicate with other bluetooth device

Configure Bluetooth Bee

User can program the Bluetooth Bee from computer or by the MS14 itself by minicom.

To configure Bluetooth Bee module from MS14, we should do below things: Below first three settings can be done by select the Sensor --> Operation Mode to Bee Console and reboot the ms14.

  • Disable UART console
  • Disconnect UART to mega328p by setting GPIO24 to Low
  • Connect UART to XBee by setting GPIO27 to HIGH
  • make sure mega328p's IO7 , IO6 are not in output mode. This can be done by put mega328p into reset state (GPIO20 to HIGH).


Then we can use minicom to configure the XBee. in SSH access, run minicom and configure minicom as:

  • Serial Device: /dev/ttyATH0
  • Bps/Par/Bits  : 9600 8N1
  • Hardware Flow Control : No
  • Software Flow Control : No
  • local Echo on/off : ON

The AT Command Set of Bluetooth Bee HC-05 and HC-06 can be found from this link AT Command set

Below are the configure example from minicom. It sets the bluetooth name to Dragino and Password to 8888.

NOTICE: The bluetooth module require short interval (1s) between characters. So better use copy/paste method to send commands instead of typing manually.

Use Minicom to Configure Bluetooth Bee




Test Bluetooth Bee: Echo Test Example Get Source

To use Bluetooth Bee with mega328p, we first have to set up the UART mode to Sensor --> Operation Mode to Arduino-Bridge. Then can programm the m328w with below code and instructions to finish a simple echo test:

//This sketch is an echo test for the ms14+m328w+ Bluetooth Bee HC-06
//This test also requires: 
// 1) ms14+m328w+ Bluetooth Bee HC-06
// 2) Android Phone with BlueTerm App installed (https://play.google.com/store/apps/details?id=es.pymasde.blueterm)
// 
//How to test?
//1/ Open BlueTerm in your Android phone and pair it with HC-06. 
//2/ Upload this sketch to MS14 and open Serial Monitor
//3/ In the BlueTerm console type a character and you will see the character is shown in the Arduino Serial Monitor. 
//The Android phone will get a "OK" string from HC-06 and shown in the console. 
//
//2014-04-16 Dragino Technology Co., Limited 
 
#include <Console.h>
 
#include <SoftwareSerial.h>
#define rxPin 7  // RX Pin on the Xbee socket
#define txPin 6   // TX Pin on the Xbee socket
SoftwareSerial bluetoothbee =  SoftwareSerial(rxPin, txPin);
 
void setup(){
  //Initialize Console and wait for port to open:
  Bridge.begin();
  Console.begin(); 
  bluetoothbee.begin(9600);
 
  while (!Console) {
    ; // wait for Console port to connect.
  } 
 
  // prints title with ending line break 
  Console.println("Waiting for bluetooth data");   
}
 
 
void loop(){
  if (bluetoothbee.available() > 0){
   char c = bluetoothbee.read();  // Get the Android data
   bluetoothbee.println("OK"); //Send back an OK to Android
   Console.println(c);  // Print this char to the Serial Monitor
  }
  delay(100);
}
Echo Test Example



Reference