One of the really interesting things about the Electric Imp is that you are able to program both the device, and something called an "agent", which is a secure, programmable web service that you use to interface with your Electric Imp device. If you are coming from a platform like Arduino, you may be wondering why you can't talk directly to the Electric Imp itself. That question is beyond the scope of this tutorial, but I have found that the agent is a very handy service to have. Here are a few great features of agents:
- Communicate using HTTPS
- Additional memory and processing power for code
- If you device goes offline, your agent will continue to execute code and can inform you.
The device can operate without any programming in the agent, so the first thing we need to do is program the device to read data from our thermocouple amplifier via SPI.
Log into your Electric Imp account and open the Web IDE. Find the Electric Imp that you will be using by its hardware address in the list of your Devices on the left hand side. Mouse over it, and click the gear symbol to create new Device Settings. Click the down arrow beside associated model, and then type a new model name, such as "MAX31855".
Credit for this code goes to a number of members of the Electric Imp forum community as well as members of the Electric Imp team. Big thanks to beardedinventor, bodinegl, rivers, and mjkuwp94. Check out the Electric Imp GitHub page for example and reference code.
If all is well, you should see the Imp download the new code, and start logging data every 10 seconds like this:
2013-09-04 21:33:28 UTC+4: [Status] Downloading new code
2013-09-04 21:33:28 UTC+4: [Status] Device configured to be "MAX31855"
2013-09-04 21:33:28 UTC+4: [Device] 24.5°C
2013-09-04 21:33:28 UTC+4: [Device] 76.1°F
Nice! The Electric Imp is reading our thermocouple data over SPI!
If you haven't read through LadyAda's tutorial on thermocouples, amplifiers and the Seebeck effect, I highly recommend that you do. Working with thermocouples will make much more sense.