Fundakit software is written in the Python programming language. Open a terminal and follow these steps to get the host computer ready – required once. Instructions are written for a Unix/Linux based system like the Raspian OS (Raspberry Pi) or Ubuntu. If you are using something else adapt accordingly.

1. Check that you have Python 3 installed by running the following command:
  $ python3 --version  
The version number may vary, but the output should look something like this:
  Python 3.6.8  
If you don’t have Python 3, you can install 3.6 with the following command:
  $ sudo apt install python3.6  

2. Install pip3 for Python 3. Pip is a package management system which simplifies installation and management of software packages written in Python.
Update the package index by running the following command:
  $ sudo apt update  
Use the following command to install pip for Python 3:
  $ sudo apt install python3-pip  
When installation is complete, verify the installation by checking the pip version:
  $ pip3 --version  
The version number may vary, but the output should look something like this:
  pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)  

3. Install the Python XBee package from Python Package Index (PyPI) using pip3:
  $ pip3 install XBee  
Pip will also install pyserial if you don’t have it. You can find out more about the XBee package here. The fundakit uses XBee modules to build up the wireless sensor network.

4. Copy the funda application to the computer (no installation process required). Be sure to copy the funda directory and its contents.

5. Install Scratch 1.4 if you don’t have it. You can get a copy here. If you’re new to Scratch, grab a copy of the 1.4 Getting Started guide. The next section assumes you have a basic understanding of Scratch.

Creating your First Project
Follow these steps to create your first funda project:

1. Plug the XBee-to-USB receiver into a USB port on the host computer.

2. Open Scratch and select the Sensing palette.

3. Right-click on either of the bottom two Sensing blocks – () sensor value or () sensor (circled below).

funda example pic1

4. Select enable remote sensor connections from the pop-up window.
Note: Scratch will automatically ask you if you want to do this when you open an existing Scratch-funda project.
Scratch - enable remote sensors

5. In the terminal, navigate to the funda directory and run the funda application:
  $ python3  
At startup the software attempts to establish a Serial connection with the funda receiver and a Socket connection with Scratch. If the receiver is not plugged in or Scratch does not have remote sensor connections enabled, the software will throw an error and offer advice for fixing.

6. Fit some freshly charged batteries in the reader and flip the ON/OFF switch to the ON position. The LED located next to the switch should light up red. After +/- 15 seconds two LEDs located at the front of the receiver should light up green: RSSI (Received Signal Strength Indicator) – constant to indicate a network connection; RX (Receive) – pulsing to indicate the receipt of data packets (sensor and power) from the reader.

7. In the funda GUI File menu, select Add Tag to add a tag to the project. This action will bring up a dialogue box which tells you to read the tag you wish to add to your project. Bring this tag within 15mm of the RFID module on the reader so that it can be read.

8. After the reader has read the tag, a new dialogue box will appear. In the Name field, enter a name for the tag. Use a name which will help you identify the tag later in Scratch. Something to do with its role in the project normally works well. In the Number field, enter the external number as it appears on the tag. This number is found on a sticker attached to the tag.

9. Click the OK button to close the dialogue. The tag will appear as read (highlighted in green) in the GUI. The unique ID of the tag will be displayed next to the Code heading. The number of the reader which read the tag will be displayed next to the Reader heading. You can edit or remove tags from the funda project by right-clicking on their name. To add more tags, repeat steps 7-9.

10. When you are ready to save your project, select Save from the File menu. This will bring up a standard save dialogue box in which you can enter a name for your project. When entering your name be sure to keep the .pkl file extension part of the default name untitled.pkl

11. In Scratch, drag a when I receive () block into the scripting area. Read the tag (in this example named ‘cricket’) to add its broadcast message to the list of messages available in the block. Select the message from the drop-down menu to set it in the block. (Your reader will have a different number.) Finally, import the cricket sound from the Scratch sound library, and connect a play sound () block with the cricket sound selected to the when I receive () block.

12. You should now hear the cricket sound when you read the ‘cricket’ tag. If you do, everything is set up correctly and you are ready to start creating with the fundakit. If you don’t, go back and check that you have followed all the steps in the correct order.

13. Save your Scratch project. It helps to give it the same name as the partner funda project so that they are clearly associated. You can differentiate between the two by looking at their file extensions – e.g. (Scratch); insects.pkl (funda).

Sensor Data

Incoming data packets from readers include samples from the three sensor ports and a battery voltage measurement. It’s a good idea to create your own data representation tools in Scratch to have ongoing and ready access to sensor data for thinking and debugging purposes.

Follow these steps to build a data representation tool for a single reader:

1. Create three new variables, and name them using the reader number (or object in which the reader is embedded) and sensor port numbers.

2. Drag three () sensor value blocks into the scripting area and select the reader and sensor ports from the block’s dropdown menu – they are listed in the bottom group (battery@readerN, sensorN@readerN).

3. Place the () sensor value reporter blocks with the reader and sensors selected in set () to () variable blocks with the corresponding variables selected.

4. Snap the assembled set () to () variable construct in a forever loop and run the script. Variables will now be automatically updated with the latest sensor data from the reader – normally every 500 milliseconds in 3 node project PANs.

5. Set the variables to visible to display the sensor values in variable watchers on the Scratch stage. Sensor and battery data can also be visualised graphically with personalised versions of methods used on mobile phones (e.g. slices of pizza, apples on a tree, a setting sun).

6. Sensor data can then be used in programmes. For example, they can be used in conditional constructs to determine outcomes and flow in a programme:

or block until a certain sensor condition is met:

You can download the Technical Manual here.

Comments are closed.