NXT2WiFi, Webserver Sensor – Getting Started Guide

www.pdf24.org    Send article as PDF   
My NXT2WiFi, Webserver module for LEGO® MINDSTORMS® NXT robots arrived a couple of weeks ago from Daniele Benedettelli. I finally got around to unpacking this new sensor today. In fact the weather here today made the decision very easy.

Purchase your own NXT2WiF Sensor

You can use the NXT2WIFI adapter to control everything on your robot from your Laptop, iOS device (iPhone, iPad, iPod Touch), or Android device! It is possible to make swarm of mobile robots sharing data in a wireless network. Your robot can have social abilities, by enabling it to post on Twitter, or sharing data on ThingSpeak. NXT2WIFI lets you control your MINDSTORMS® robot from any portable device using a normal web browser, being in the same room or on the other side of the planet!

Purchase your own NXT2WiF Sensor

OVERVIEW:
NXT2WIFI Sensor provides your NXT robot with a powerful Internet engine to a browser-based interface over a LAN, Internet or GPRS network, in a small footprint, at low power and low cost. Real time data can be both displayed and/or updated from a standard web browser, on computers, netbooks, Android powered smart phones and tablets, Apple iOS devices, because the module supports dynamic web pages.

NXT2WIFI Sensor allows you to control your robot using any browser-enabled device (iOS devices as iPhone and iPad included!), without having to install anything on your device. This is possible thanks to the graphic webserver capabilities. The Sensor allows Wi-Fi secure networking functionality (WEP, WPA, WPA2), UDP TCP sockets, real time clock, with onboard NiMh battery. The NXT2WIFI Sensor can be turned on and off, using its own switch. You can reset the NXT2WIFI Sensor by shortly pressing the reset button placed beside the power switch.

You can recharge the onboard battery at any time, simply by connecting a cable from your computer to the miniUSB plug on the NXT2WIFI Sensor. A red led will light up when charging, and will turn off when the battery is fully charged. The NXT2WIFI Sensor is connected to the NXT Brick via port 4 using any NXT connector cable.

The NXT2WIFI Sensor has two serial ports: a miniUSB plug to communicate with the PC (virtual COM port), and a NXT plug to exchange data with your NXT brick, using the RS485-enabled port 4. Sending commands from NXT or from a serial terminal on computer is transparent for the NXT2WIFI.

FIRST IMPRESSIONS:
The NXT2WIFI Sensor is well made with quality components. Perhaps the option of a case or cover would be an advantage for younger users. That aside, I am very impressed with my purchase. Daniele Benedettelli has produce an excellent add-on for anyone’s  LEGO® MINDSTORMS® NXT Kit. I can defiantly recommend Daniele’s NXT2WiFi Sensor.

The NXT2WIFI Sensor is powered by openPicus, who support the Open Source Hardware Association efforts and strives for 100% compliance with the initiative core beliefs and requirements. The NXT2WiFi Sensor relies on an openPicus FlyPort module: a system on module system with embedded software framework and Internet connectivity.

The Flyport WiFi Module is a System-on-Module solution based on a PIC 16 bit processor and a Communication Transceiver. The openPicus Software Framework that empowers each Flyport is based on, FreeRTOS: an open source, ultra efficient and ultra reliable OS that also manages the communication protocol stack. The Module has Internet Connectivity: TCP and UDP, a customizable web server, E-mail and FTP clients.

You can develop Flyport applications by leveraging C++ development skills thanks to the powerful and free IDE. Access to open source schematics and technical details are available here.

SPECIFICATIONS:

Processor: PIC24FJ256,256K Flash,16K Ram,16Mips@32Mhz

Memory: 1MB Flash onboard

Transceiver: 802.11 b/g/n Wi-Fi certified MRF24WB0MB

Power Supply: 3,7V 1000mAh LiPo onboard battery

Integrated RTC: 32,768 Khz quartz onboard

Communication: 2 UART (RS485 to NXT and PC)

Dimensions: 56 x 72 x 18 mm, 50 grams

Attachments: 8 LEGO-compatible mounting holes

 

GETTING STARTED:
To begin with, you will need the items listed:

  • a USB A-B cable (the one for the NXT)
  • a miniUSB cable (the charge and communicate with the NXT2WIFI)
  • a NXT connector cable (to connect the NXT2WIFI to the NXT port 4)
  • a NXT brick
  • the NXT2WIFI Sensor itself
  • USB virtual serial port driver may be needed (Future Technology Devices International Ltd.).

Access MS Window’s Device Manager, ‘right-click’ on My Computer and select Properties. Select Device Manager, from the ‘Control Panel Home‘.

ControlPanelSystem.jpg

The NXT2WIFI Sensor will be listed in the MS Windows Device Manager as a USB Serial Port (COM port).

DeviceManager.jpg

SERIAL TERMINAL:

I suggest you connect to the NXT2WIFI Sensor using Serial Terminal, such as the freeware ‘Termite‘ by CompuPhase. The connection settings for ‘Termite‘ or other Serial Terminals are:

  • Baud rate: 115200 baud
  • Data bits: 8 data bit
  • Stop bits: 1 stop bit
  • Parity: none
  • Flow Control: none
  • Transmitted text: Append LF

 

Termite-Setup.jpg

If you want to see the debug stream from the NXT2WIFI Sensor, issue the command $DBG1. Now every command you send from the computer or from the NXT will be shown in the terminal log as well. I personally found the Debug Stream vital during configuration of the NXT2WIFI Sensor.

Termite-DebugSetup.jpg

UPDATING THE FIRMWARE:
You should keep your NXT2WIFI Sensor’s firmware up-to-date: firmware updates are needed to fix eventual bugs or to add new features. You can find the latest firmware for your device on the official NXT2WIFI Sensor’s Support Webpage.

  1. Download the NXT2WIFI Firmware Update Tool from the support webpage.

  2. No need to install it, just extract the downloaded archive.

  3. Connect the NXT2WIFI to your computer using the miniUSB cable, and turn the device on.

  4. Double click on the NXT2WIFI-updater.exe program (the device must be already on, for the program to list the COM port in the dropdown menu).
    NXT2WIFI-updater.jpg

  5. Select the COM port of your device from the Port drop down menu. To check if the device is correctly connected and communicating with the Firmware Updater program, press the reset button on the device and click the Check BL button at once (actually within 1 second since the reset). You should see the PIC type and the bootloader version in the log window.
    NXT2WIFI-updater2.jpg

  6. Browse for the firmware image clicking on the small button beside the Hex-file drop-down menu. Select the latest .hex file you downloaded from the support page. In the log window you can see the details about the firmware image. The bar on the right shows the memory occupied by the firmware.
    NXT2WIFI-updater3.jpg

  7. All is ready to flash the new firmware onto the device. Click the Download button. The process is shown by a progress bar.
    NXT2WIFI-updater4.jpg

  8. When the update is complete, the NXT2WIFI will restart. You can then proceed to activate the device (see the Activation section of this guide for help).

WARNING: updating the firmware deletes the user settings! After the update, the device must be activated again

ACTIVATION:
The NXT2WIFI Sensor needs to be activated the first time you use it, and  each and every time you upgrade the firmware, otherwise many functionalities won’t work. You can always ping the device,to set-up the network and retrieve information, such as MAC address, or firmware version.

If found the easiest way to Activate the NXT2WiFi Sensor from the ‘Termite‘ or other Serial Terminal.

  1. You can obtain your device MAC from the serial terminal issuing the command $MAC returns MAC=XXXXXXXXXXXX where XX is a byte in hex ascii format, e.g. MAC=001EC002DA44 (be sure to have debug stream active – $DBG1 command).
    GetMAC.jpg
  2. Go to the online activation webpage, http://dev.openpicus.com/Firmware/NXT2WIFI and enter your NXT2WIFI MAC Address, press the ‘Get Activation Code’ button, select and copy that 40-char-long code.

    GetActivationCode.jpg
    ActivationCode.jpg

  3. You can enter the code sending the following command using any ‘Termite‘ or other Serial Terminal.
      $REG where is the 40-char-long code obtained from the online activation code generator.

    Example:
      $REG?9EA8FFC17964FA86677598EF4EE831F1E3B5E277

    Activated.jpg

  4. If the inserted code is correct, in the Terminal Debug/Log you will see the message NXT2WIFI activated successfully!

ALTERNATE ACTIVATION:
To activate the product via the NXT2WiFi Sensor’s Webserver, do the following:

  1. In your web browser address bar, type the IP (e.g. 192.168.0.100) you got from the Set-up Program on the NXT followed by /activate.htm
    for example http://192.168.0.100/activate.htm.
    If you are using a Windows PC, you can type http://nxt2wifi/activate.htm for the address, as NXT2WIFI is the NETbios name of the device.
  2. You should now see NXT2WIFI activation page. The device MAC address is be displayed there.
    Activate.jpg
  3. Go to the online Activation Code Generator Page, and enter your NXT2WIFI MAC address into the Form, and press the ‘Get Activation Code’ button, select and copy that 40-char-long code.
    GetActivationCode.jpg

    ActivationCode.jpg

  4. Enter (paste) the Activation Code from the Activation Code Generator Page into the form on the NXT2WIFI Activation Page, and press ‘Submit’. If all went to plan, you should something similar to the page below in your browser.
    ActivatedPage.jpg

GRAPHIC WEBSERVER:
NXT2WIFI Sensor always listens and executes the commands sent over the serial link. It sends spontaneous messages to the NXT over the serial link only when events are generated from the webpage (button pressing, slider moving). This may cause collisions, since RS485 is half duplex communication.

To toggle the spontaneous messages on and off, use the command $SRV<X> where <X> can be 1 to turn it on, 0 to turn it off.

WebServerPage.jpg

NETWORK:
When you first start-out using the NXT2WiFi Sensor, I suggest you use the default ‘ADHOC‘ to begin with. The NXT2WIFI Sensor has two Wi-Fi connection profiles: the default one is ‘ADHOC‘, and has a DHCP server, using a standard SSID name “NXT2WIFI”; you can change the custom profile from serial, and save it permanently. There are 4 sockets available, that can be used either as TCP/UDP clients/servers.

Connecting to Wi-Fi Networks
$WFC<T> Start WIFI Connection using the <T> profile:

0 for DEFAULT (adhoc network with DCHP enabled and SSID “NXT2WIFI”)
1 for CUSTOM (user customizable)
e.g. $WFC1 connects using the CUSTOM profile settings.

$WFX Disconnect WIFI

$WFQ Stop trying to connect

Getting Connection Status
$WFGS gets Connection Status. Returns WFGS=<N>

NOT_CONNECTED 0
CONNECTING 1
CONNECTED 2
CONNECTION_LOST 3
CONNECTION_FAILED 4
STOPPING 5
TURNED_OFF 6

 

For more details: Download/View a copy of the NXT2WiFi User Guide.

CUSTOMISING GRAPHIC WEBSERVER:
On the webserver page you can show data coming from the NXT (motors, sensors, variables, messages), and command the NXT to perform actions. The NXT can update the state and the content of the webpage elements such as labels (strings), sliders and bargraphs, buttons and checkboxes, that are retrieved as strings.

You can send strings, sensor and motor data to NXT2WIFI to be shown on the webserver page. Also it can update various controls status with this simple protocol:

Widget Direction Data Type Quantity
Label output string 20 (64Bytes-long)
Button input/output bool 20
Checkbox input/output bool 20
Slider input/output int 20
Bargraph input/output int 20

 

$WEBLBL<N>?<datalen>,<data>[0x1B] where <N> is the input field ID, <datalen> is the length of <data>, usually a text string containing numbers or a message. Upto 10, 64-Byte strings can be sent; the ID can be 0-9.

$WEBBTN<N>?<S> where <N> is the button ID, and <S> is the boolean status, 1 or 0. Buttons can be used to display two different images, so they can become a graphic indicator with two states.

$WEBCHK<N>?<S> where <N> is the checkbox ID, and <S> is the boolean status, 1 for checked or 0 for unchecked.

$WEBSLD<N>?<V> where <N> is the checkbox ID, and <v> is the integer value for the slider position. Maximum and minimum values are set in the web editor.

$WEBBAR<N>?<V> where <N> is the checkbox ID, and <v> is the integer value for the bar fill level. Maximum and minimum values are set in the web editor.

$WEBCLR resets all webpage fields to zero (or empty).

CONCLUSION:
I trust this article will help you set-up your LEGO® MINDSTORMS® NXT’s NXT2WiFi: Webserver Sensor, and getting it working with minimal frustration in ‘Basic Mode’. As mentioned before, I suggest when you first start-out using the NXT2WiFi Sensor, use the default ‘ADHOC‘ to begin with, as it lessons the initial learning curve.

In coming weeks, I hope to post some further articles on using the NXT2WiFi Sensor with custom Webserver Pages. I will also add a couple robot projects using the Sensor as well….

Previous Post

BrickLink Order #3740975

I never seam to have enough LEGO Mindstorms NXT Servo Motors. On a visit to Brickule I discovered they had a good stock of NXT Servo Motors. for only US$15.50 ... Read more

Next Post

Purchase LEGO® MINDSTORMS® NXT NXT2WiF Sensor

Imagine takig control of your NXT robot from every kind of Web Enabled device: PC, MAC, laptop, netbook, Android-powered smartphone or tablet, iPhone, iPad, iPod Touch.  You can read data ... Read more

Short URL: http://tinyurl.com/j2njfve

Leave a Reply

Your email address will not be published. Required fields are marked *



Do NOT follow this link or you will be banned from the site!
error: Content is protected !!