When FireBlock Meets Fireduino

来自Firefly wiki
跳转至: 导航搜索

Introduction

We now introduce how to connect FireBlock to Fireduino board.


FireBlock communcates with Fireduino board using Firmata protocal. You need to flash the Firmata firmware to the board.


You have to make the Arduino IDE ready to develop with Fireduino. If in doubt, please check the quickstart articles in the Wiki Main Page.


Flash Firmata

Fireduino is required to flash specific version of Firmata. Take the steps below:


① Open Arduino IDE, and in menu "Tools->Board", select "Fireduino":

Fireblock connect ide 1 en.png


② In menu, select "File -> Examples -> Firmata -> FireduinoFirmata":

Fireblock connect ide 2 en.png


and get:

Fireblock connect ide 3 en.png


③ Modify the network configuration. You need to specify you WiFi's SSID and password here.

If a static IP address is prefered, uncomment STATIC_IP_ADDRESS, and modify it to a valid IP address unoccupied by other devices:

Fireblock connect ide 4 en.png


Generally you are suggested to use static IP address. Otherwise, you need to find out the actual board IP address via methods such as looking at the serial output of the board, or the DHCP log of your wireless route, and the IP address may be dynamicly changed, which cause a lot of trouble.


For example, if you need to use staitc IP address "192.168.1.113", delete the comment string "//" before STATIC_IP_ADDRESS, and modify the content.

Fireblock connect ide 5.png


Pay attention here, the "." needs to be replaced with ",", which is required by the Firmata code.


④ Connect Fireduino to PC with USB cable, and put the board into upgrade state (which is a matter of keeping the "UP" button pressed, short pressing the "RES" button before finally releasing "UP" button.)


⑤ Press "upload" button in the toolbar. The IDE will compile the program, and flash the firmware into Fireduino:

Fireblock connect ide 6 en.png


Once success, it will prompt:

Upgrade firmware ok.


The flash of Firmata is completed.

Insert TF card

By default, it it required to insert the TF card for the firmware to work. If it is not inserted, the LED will blink quickly forever and the board cease to work.


If you do not need to play music file in the TF card, you can remove this restriction, by commenting out the following code:

Fireblock connect ide 7.png


After modification:

Fireblock connect ide 8.png


And finally press "Upload" button to flash the modified firmware.


Connect in FireBlock

First, please make sure the PC or tablet running FireBlock shares the same wireless route or ethernet with Fireduino board. This keep things simple.


Click the link FireBlock, switch to "Fireduino" category, and drag the "connect" block into the scripting area:

Fireblock connect fb 1 en.png


Click the editbox inside, input the IP address of the Fireduino board, which has been flashed with FireduinoFirmata.

Fireblock connect fb 2 en.png


Then click the "connect" block (not the editbox inside). The block is displayed with glow around, which indicates that it is running the connect action. In the meantime, a message dialog is popuped:

Fireblock connect fb 3 en.png


Once connected successfully, Fireduino board will blink the LED regularly to show the major and minor firmware version number, and FireBlock will display a dialog showing the result:

Fireblock connect fb 4 en.png


If connection is failed, FireBlock will popup the error dialog:

Fireblock connect fb 5 en.png


In this situation, you need to check the message in the serial console. The most common reason are:

  • TF card is not inserted (and the check code is also not commented).
  • WiFi failed to connect with bad SSID or password.
  • IP address is not matched.


Control Fireduino

You have now succefully connect FireBlock to Fireduino board. Please click here to write your first FireBlock script to control the Fireduino board.