ATTENTION!!! I've added Tessel 1 board as an optional board because probably it will work also on that board. Let me know if somebody tests it!Setup
If it's the first time you use Tessel the best start point is to follow the official getting started tutorial, and yes, you can find there the blink example, otherwise you don't need more than the T2 board, the ambient module and your PC. Let's start!Step 1
Open your terminal and create a directory called “ambient”, or call it how you want, change directory into that folder, and initialize a Tessel project:
mkdir ambient cd ambient t2 init
Plug the ambient module into Tessel port A with the hexagon/icon side down and the electrical components on the top, then plug Tessel into your computer via USB.
Install the modules needed for our project and write in your terminal:
npm install ambient-attx4 npm install tiny-router
The first one is the lib to manage the ambient module, here you can find the docs, and the other one is the lib we will use to manage the routing.Step 4
Delete the “
index.js” file and create a new one called "
ambient-rest.js", open it with your preferred text editor and paste the code attached to this tutorial, save and close the file.
Connect Tessel to WiFi, this should be the same WiFi your computer is connected to. (
t2 wifi -n network -p password). Note the IP address of your Tessel when it connects (you can also show it again with
Now it's time to fire our code so type in your command line:
t2 run ambient-rest.js
You need to know the IP address of your Tessel and the computer must be in the same network. Open your browser and type the URL:
The page served from your Tessel should appear!
Now if you want the light sensor value type:
Or for the sound value type:
Try to clap or shine a flashlight at it and try to reload the pages.Conclusion
As you can see the code is pretty simple, if you want to challenge yourself you can try to add more modules and/or send response in JSON format.
If someone from Tessel team is reading this and wants to make me a surprise and give a board, please feel free to do it. I really won't mind! I will have fun experimenting with the board.
If you have any questions or problems please leave a comment.