Last weekend I got my hand on the new Tessel 2, thanks to Flaki for every answer he gave me. For people who don't know, Tessel is a microcontroller that runs JavaScript, Python and also Rust, and like most microcontroller boards you can add modules. I've tried a couple of modules like climate, RFID, BLE, GPS, etc. But after I played few hours with those, I tried to expose the data collected from the board to other services.
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 1Open 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
Step 2Plug 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 4Delete 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 t2 wifi
).
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:
http://yourtesselipaddress:8080/
The page served from your Tessel should appear!
Now if you want the light sensor value type:
http://yourtesselipaddress:8080/light
Or for the sound value type:
http://yourtesselipaddress:8080/sound
Try to clap or shine a flashlight at it and try to reload the pages.
ConclusionAs 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.
Comments
Please log in or sign up to comment.