Skip navigation


Tablets have been the technology of choice for the general consumer for a number of years now, and with Christmas fast approaching there is sure to be a spike in sales of iPads and Android devices.


What if you could choose a tablet that was also Open Source? What if, in fact, you could purchase a tablet that was completely compatible with any software or hardware you created? Well that could fast become a reality following the announcement of a recent Kickstarter campaign that could throw the doors wide open to a whole new generation of tablets.


RaspiTab is a 100% hackable tablet, with 7” capacitive touch screen where students and engineers can make their own GUI, implement the small sensor PCB into the hardware and still have a nice box or product to use...and it looks pretty awesome too.


RaspiTab, as you may have guessed from the name, operates using the Raspberry Pi Compute Module meaning not only is it fully hackable, it also means owners are not limited to the accompanying Linux OS, it can run any Operating System designed for use with Raspberry Pi.


The idea of combining the popular and diverse Raspberry Pi into a Tablet is an intriguing and interesting one, not to mention something that could change the face of mobile devices if it takes off. We’ve seen projects using the Raspberry Pi, a GPS and a touch screen to create a sat nav, so taking a step further to create a tablet is probably the next step down that same path.


The Kickstarter campaign is already underway, with the first shipping date being estimated as some point in April 2015. The RaspiTab currently has a long way to go to raise the £125,000 it needs before the 24th December, but now the idea of a hackable tablet has been put forward, it could just be a matter of time before one makes it to market...or at least I hope so!

Check out the Kickstarter page and back the project here.raspitab_2.png


Main features include:

• Open and hackable! – ALL SW code is OPEN SOURCE

• Raspian OS (or what you like to install)

• Easy 4 screw opening to access internal hardware.

• 2 Internal USB ports (one taken up by removable USB WiFi module) – for Bluetooth, Memory stick, 4G data dongle etc.

• Pin Header with I/O for expansion of small HW solutions made by your self

• G-sensor, accelerometer, GPS, GSM, RFID etc. – ITS UP TO YOU!!!

• 7” TFT screen with capacitive touch

• 5.0 megapixels camera – the well-known camera for Raspberry PI

• 2 external USB ports

• 2 stereo loudspeakers 1 Watt

• Jack connector for external loudspeaker and microphone

• Micro USB for normal charging

• 3400 mAh battery LION – +8 Hours use

• Has a LED lighting which show battery level

• Power management IC (hackable)

• Low power (uses under 15W of power during use, less than 1W during standby).

• Comes with loos WiFi USB dongle



The Internet of Things (IoT) is an expected feature for any new product coming out. But, I’ve noticed that the IoT systems out there are all quite specific. Health monitoring, home control, kitchen appliance… each focusing on their little worlds. But, what if you want to monitor when a mouse trap snaps, the mailbox opens, or someone moved your lunch in the fridge at work? That is where my general purpose IoT system comes into play. Which I will call the PiioT (Pi + IoT) for the remainder of this post. (I do dislike tongue-in-cheek names though… but moving on. ) So, dust off that old Raspberry Pi Model B.


I made it simple… it looks for a logic signal trip, like a switch. When it receives the signal, it sends out an email. Maybe one day you hid a switch underneath your beverage in the fridge, the next day you are monitoring your file cabinet.


Of course, a circuit could be built to do any one function. Then it can be set to then send a logic signal to the PIoT. An example, a temperature sensor circuit is off monitoring a fish tank, let’s say, when a certain temp it reached, a logic signal is sent to the central server, the PiioT. All IoT related tasks are shuffled off to the Raspberry Pi, in other words.


I placed in one output pin as well. So, you can send an email to the system and it will set a pin high/low. This way you can daisy chain off of that with lights, a relay, a series of relays. Turning on a relay is the easiest way to turn on an AC powered device like lights, radio, sprinkler system, holiday decorations, coffee maker, etc.


Here were my requirements

- Use a Pi

- Several input pins. I used 6, but it could be set it up to use many more.

- Have an output pin

- Emails received and triggered by email.


Project by sections

Again, I made it simple. All you need is one Raspberry Pi.

- I used pins 19, 21, 22, 23, 24, 26 for inputs for switches or sensors.

I set the output on pin 7.

- The email address has to be configured for use. I made a gmail account for this project. I am only using it for the output pin, where I send it a command to turn on. Unfortunately, a recompile will be needed to set your own email.


- The system checks the email address set up for the output trigger. If there is a new one, it will trigger the output and then delete the email.

The difficulties

- Dealing with various ISPs was the biggest issue. Dynamic IPs didn’t quite work out. I had to use a static IP with an ISP that can handle ETRN. Which means Extended Turn, and extension of the SMTP mail delivery protocol. This allows one SMTP server to request from another SMTP server.

- Using one’s own email server system might be a better idea than with gmail.


Pics and system

Piiot B.jpg

Nothing in this picture is really necessary... just one Pi is all you need. I am just showing the system igniting a LED on the lower right after receiving an email trigger.

Schematic and Design

piot circuit B.JPG

Sticking with the general purpose angle of the project, I drafted this with generic inputs and outputs. Replace as seen fit...



(Full code attached to this page)


//##### OPERATION NOTES #####




//----- PROGRAM SETTINGS -----

//    /settings.h has all of the programs settings in it.  To edit it from the command line:

//    Edit the file:

//        nano /home/pi/settings.h

//    Make the changes required then press CTRL+X to exit, pressing Y to confirm the save.

//    Build the application:

//        cd /home/pi/whatevername

//        make

//    Reboot the RPi to run the application again, or use this to run it from the command line:

//        sudo ./whatevername.a      (CTRL+C to forcibly close it again if needed after running in this way)



//----- SENDING EMAIL -----

//To change the mailbox email is received from edit this file:

//    nano /etc/ssmtp/ssmtp.conf


//Including these strings anywhere in an email (subject or body) sent to the RPi will cause the associated action

//STRINGS MUST BE LOWERCASE HERE but are not case sensitive when sending.

const char EMAIL_RX_SET_OUTPUT_HIGH_STRING[] =    {"set output high"};        //Sets the output high and enables monitoring of the input pins

const char EMAIL_RX_SET_OUTPUT_LOW_STRING[] =    {"set output low"};            //Sets the output low and enables monitoring of the input pins



//--------- Output pin ----------


#define OUR_OUTPUT_PIN(state)                    bcm2835_gpio_write(RPI_V2_GPIO_P1_07, state)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp

const int output_pin_default_state =            1;            //0 = low, inputs not being monitored.  1 = high, inputs are being monitored.





//Note - these need to be C constant strings. You cannot include a quotation mark within these strings - use an html code instead.


#define    EMAIL_TX_INPUT_1_RECIPIENT                ""

#define    EMAIL_TX_INPUT_2_RECIPIENT                ""

#define    EMAIL_TX_INPUT_3_RECIPIENT                ""

#define    EMAIL_TX_INPUT_4_RECIPIENT                ""

#define    EMAIL_TX_INPUT_5_RECIPIENT                ""

#define    EMAIL_TX_INPUT_6_RECIPIENT                ""


#define    EMAIL_TX_INPUT_1_SUBJECT                "Email Alert for input 1"

#define    EMAIL_TX_INPUT_1_BODY                    "Input 1 was triggered"


#define    EMAIL_TX_INPUT_2_SUBJECT                "Email Alert for input 2"

#define    EMAIL_TX_INPUT_2_BODY                    "Input 2 was triggered"


#define    EMAIL_TX_INPUT_3_SUBJECT                "Email Alert for input 3"

#define    EMAIL_TX_INPUT_3_BODY                    "Input 3 was triggered"


#define    EMAIL_TX_INPUT_4_SUBJECT                "Email Alert for input 4"

#define    EMAIL_TX_INPUT_4_BODY                    "Input 4 was triggered"


#define    EMAIL_TX_INPUT_5_SUBJECT                "Email Alert for input 5"

#define    EMAIL_TX_INPUT_5_BODY                    "Input 5 was triggered"


#define    EMAIL_TX_INPUT_6_SUBJECT                "Email Alert for input 6"

#define    EMAIL_TX_INPUT_6_BODY                    "Input 6 was triggered"


//Input pins

//Pull any pin low to trigger the associated email being sent

#define SWITCH_1_INPUT                            bcm2835_gpio_lev(RPI_V2_GPIO_P1_19)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp

#define SWITCH_2_INPUT                            bcm2835_gpio_lev(RPI_V2_GPIO_P1_21)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp

#define SWITCH_3_INPUT                            bcm2835_gpio_lev(RPI_V2_GPIO_P1_22)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp

#define SWITCH_4_INPUT                            bcm2835_gpio_lev(RPI_V2_GPIO_P1_23)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp

#define SWITCH_5_INPUT                            bcm2835_gpio_lev(RPI_V2_GPIO_P1_24)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp

#define SWITCH_6_INPUT                            bcm2835_gpio_lev(RPI_V2_GPIO_P1_26)        //If changing this ensure the initialise() port setup is also changed in ap-main.cpp



Just one Raspberry Pi B. Just $35 for a IoT controller is a decent price. This will work with every Pi version, even the A+.

What is connected to the inputs/output is up to the user.



Other uses of the system

- Imagination is the limit


Oddities and observations

- A Dynamic IP internet connection did not work. A static IP was the only way I could connect to the gmail server.

- The model B+ & A+ seem to have a different networking parameters.. so stick with the old model B or A for the time being.


Every lab (home, office, school) needs temperature measurement capabilities. Measuring temperature for science experiments is hard – all sorts of materials, liquids, and chemicals may be involved or a large temperature range may need to be covered. The sensor used for this (a thermocouple) is not easy to interface, and the sensor amplifier is non-trivial since it has to be able to measure an extremely small voltage.


For flexibility in the science experiments that it can be used for, high accuracy is needed along with a fast response and good update rate. It goes without saying that data should be logged in a convenient form, and it should be easy to use.


For convenience there are ready-built temperature measurement and logging products out there, sometimes they are not easy to use due to soft-button overload and a limited display. In addition for large lab or classroom use information should be logged and retrievable by people easily – and perhaps view the current status on a large screen. It also goes without saying that some experiments may take a long time, so the ability to check up on your experiment using a mobile phone during lunch is useful too. One last requirement was that this should be easy to build even for people new to electronics and software.


This project shows how to connect up a thermocouple board to a Raspberry Pi (RPI), and use it for temperature measurement and logging with great performance and ultra-low cost. This project is easy – no soldering required unless you want to. This is also a great project to start using the 'DIL (dual-in-line) header'  connector on the RPI if you have not already done so.



Here is a video showing the entire project in action; the brown cable is the temperature probe.


Design Overview

A lot of thermocouple-based hobbyist projects use the MAX31855 integrated circuit and ready-built ‘thermocouple amplifier’ boards are available for connecting to the RPI from several suppliers. This project however uses the far higher-resolution ADS1118 from Texas Instruments. It comes in a surface-mount package but fortunately a ready-built ADS1118 development boardready-built ADS1118 development board is available which contains all circuitry including a LCD display and thermocouple - it is extremely good value for money. If you don’t fancy soldering then it is possible to connect up this board to the Raspberry Pi (or any other computer board – it uses a standards based communicaton method called Serial Peripheral Interface or SPI) using eight jumper wires (male-to-female cables are needed). Alternatively, if you don’t mind a soldering exercise then a small adapter board can be constructed. This was the approach taken here. In summary you can see in the photo below all the bits that are used for this project, including the assembled adapter board.



The entire project can be controlled via a web browser or from the command line.



To build the adapter board, the simplest way is to use a circuit board; using EAGLE software I drew up a design for which the files are attached to this post ready to send off to a PCB manufacturer (it costs about $30 for ten boards).



Alternatively, prototyping board can be used; I obtained some perf-boardperf-board (the type with isolated pads, not stripboard) and cut it to size. A 3mm hole was drilled for attaching a support pillar (threaded hex spacer)support pillar (threaded hex spacer). The boards are next to each other, not on top of each other, to minimise temperature change and noise issues, both of which would have an effect on the thermocouple reading.


The next step was to solder a  40-way DIL header socket  40-way DIL header socket.



I wanted the ability to plug in the ADS1118 board onto the pad side of the perf-board, so there is a slight complication here. The solution was to use bent SIL headers. 10-way SIL headers10-way SIL headers are needed (the photo shows 8-way which is what I had at hand) - or use surface mount ones which are similar but with the bent ends alternating on either side. If you are using a circuit board and not perf-board, then straight SIL headersstraight SIL headers are needed.


To get them aligned, plug them into the ADS1118 board, and position it over the perf-board and then tack a few pins with solder. Then the ADS board can be very gently unplugged and the SIL headers can then be soldered properly. Note that at this stage it is quite difficult to unplug without tearing the pads off the board. Hold the bent part of the SIL headers against the board while unplugging the ADS1118 board.


Next, to make the SIL headers very secure, solder each pin to as many pads as possible (each one can be soldered to three pads).



The next step is to wire it up. I used Kynar wireKynar wire which is very thin but any wire will do.



To identify the connections, refer to the pin numbering photo below and the following table:

* Connections:
* TI board       RPI B+
* ------------   ------------------
* P1_1  VCC      1     3.3V
* P1_7  CLK      23    CLK
* P1_8  ADS_CS   26    SPI_CE1
* P2_8  LCD_CS   24    SPI_CE0
* P2_9  LCD_RS   11    GPIO_17_GEN0
* P2_1  GND      9     GND
* P2_6  SIMO     19    MOSI
* P2_7  SOMI     21    MISO




After testing the software and board functionality, it is possible to use some epoxy resin glue (e.g. Araldite) to make the SIL headers even more secure. A minimal amount was used so that it was possible to still just-about solder onto the pins if needed to in future.


With the PCB approach mentioned earlier, when the PCB arrives, the header pins and receptacle can be soldered, and it is an easy task (takes five minutes) so the PCB is the preferred method especially if you need to make many of them (I intend to make several). I used DIL header pins instead of SIL, but either will work with the PCB layout attached to this post.


Here it is attached to the RPI:


Underside view:





The diagram here shows the entire solution overview. The majority of the code is in three files. The code that interfaces to the ADS1118 board is discussed first, because it is possible to run this code standalone if desired. It is shown in purple in the diagram.



To create the software, the first thing one of the things to do is to create a logo:

* therm.c
 RPI  430BOOST-ADS1118 Thermocouple/LCD Board 
*         __                                __     ____   _____
*   ____ |  |   ____   _____   ____   _____/  |_  /_   | /  |  |
* _/ __ \|  | _/ __ \ /     \_/ __ \ /    \   __\  |   |/   |  |_
* \  ___/|  |_\  ___/|  Y Y  \  ___/|   |  \  |    |   /    ^   /
*  \___  >____/\___  >__|_|  /\___  >___|  /__|    |___\____   |
*      \/          \/      \/     \/     \/                 |__|


The next step is to make use of the wealth of code that TI usually offers. In this case, TI already had high quality ADS1118 code intended for the MSP430 Launchpad that could be reused. It was adapted slightly to be usable on the RPI, using some input/output (I/O) code from Gert van Loo and Dom.


Temperature measurement may seem to be an easy task (read an ADC value and convert to temperature) but thermocouples require ‘cold junction compensation’ which in the case of the ADS1118 means reading an internal temperature sensor too. The code interleaves reading the internal sensor and the external thermocouple. Another key point is that a thermocouple output is not linear compared to temperature; thermocouple manufacturers publish data that can be used to get a more accurate conversion from ADC value to actual temperature. The TI code already includes these capabilities for the supplied thermocouple.


The code was adapted to add logging capability. Since the board is to be powered by the noisy 3.3V supply from the RPI, and it is in close proximity to the RPI, some steps need to be taken to ensure that the measurement is cleaned up. The implemented algorithm every second reads the internal temperature sensor once, and the external thermocouple ten times in a short burst (a few hundred milliseconds total) so that the measurements can be averaged and finally output to 0.1 degrees C resolution. The end result was very good; see some example output here.


The LCD has two lines of 16 characters, so it was decided to use the bottom line to display the time and current thermocouple temperature. The top line is user-dependent; it can be set to something so that people immediately know what the experiment is about. For example, it can say “Test #1” or “Don’t touch’.



Using the code is easy.


First off, confirm that some features are enabled on the RPI. If the RPI is being used fresh, then after operating system installation, ensure that the ‘Advanced’ menu option is selected and then enable three things: SSH, SPI and I2C - we don't use all these for this project, but they are standards based interfaces that should always be enabled unless you never want to unplug the RPI from a monitor or not make use of the 40-way DIL connector on the RPI. If this was not done after OS install, then type raspi-config in a text window (also known as a command shell) on the RPI and then select ‘Advanced’ in the menu that appears.


Assuming the three features mentioned above are enabled, then create a folder for your work off your home directory (e.g. create a folder called development and then a sub-folder called therm) and copy the source code (stored at into that sub-folder.

Here is how to do all this:



To compile the code (also shown in the screenshot above) type:

gcc -o therm therm.c -lrt


The code is now ready to run. There are a few ways to use this project. One way is to just type commands into the command shell. Another way is to use a web browser. These two methods are discussed next.


Command Interface

The code can be run either using ‘sudo’ or as superuser (root) user.

For the latter, to become root user, first type sudo passwd root one time, and create a superuser (i.e. root user) password. Now, whenever you want to become superuser, you can just type 'su' and enter that password. To exit out of superuser privileges at any time, type 'exit'. Some people prefer sudo, others feel it is an unnecessary handcuff.


sudo ./therm


or (using the root user method)

sudo passwd root


The temperature will be displayed.

There are other variations, of which some are listed here. For example to dump the temperature every second to the command shell, type:

./therm 1


The command above will indefinitely dump temperature to the screen. To stop it at any time, press Ctrl-C.


To log the data, type:

./therm 1 mylogfile.csv


Press Ctrl-C to stop logging, and the generated file can be viewed and graphed using spreadsheet software (e.g. Excel).


To print some text to the LCD display, type:

./therm msg “Experiment #1”


or combine it with a filename to start logging too:

./therm 1 mylogfile.csv msg “Logging…”


Using a Web Browser

To use web browser capability, a platform called Node.js is run on the RPI. There are plenty of projects on Element 14 using Node.js with the RPI or BeagleBone Black. To avoid repeating, just follow the Node.js and Socket.IO install steps at this location (scroll to the section "Raspberry Pi web server and application software") and follow all the steps listed in that section up to and including the command ‘npm install’.

The code that will be used to enable web control is shown in blue and orange in the diagram below:



To run the web server/application software, type

node index.js


Now you can navigate using a web browser to http://xx.xx.xx.xx:8081/index.html to see the web page. Click ‘Live’ to see the live view of temperature.



Select a file name and click ‘Log’ to start logging data.



Thanks to TI’s skilful engineering with the ADS1118 board, a very high quality science lab temperature-logging instrument can be quickly assembled, ready to run interesting experiments. See the coffee cup blog post for an example.


The software is fresh and really just proof-of-concept level and will have a few bugs but it appears to work reasonably well in the limited testing I have done so far (I used it to log data for a few hours). It would be wise to do a practise run before trying to use the software in a classroom.


Although I have no means to measure accuracy, TI have published a PDF document about precision thermocouple measurement with the ADS1118 which shows the techniques they used to ensure an accurate result. It is reassuring to see the output using the board and algorithm appears clean and as expected.


For quick results, use the PCB design attached to this post, but the proto-board method works well too.



Additional Ideas

If desired (e.g. outdoor use), the solution can be powered from a Lithium Polymer (LiPo) cell. To do this, a BatteryBoosterPackBatteryBoosterPack is inserted in-between the adapter board that was created, and the thermocouple board. Here is what it looks like:


The Battery BoosterPack comes with the LiPo cell. Note that some slight modifications need to be done to the Battery BoosterPack before it is used for this project, in order to prevent any pins from clashing. See this blog post (scroll to the section titled "Battery Power" and perform the steps in that section).


Source Code

Code is available on GitHub, click here. The initial version has functionality to display temperature on the LCD display and on the browser dynamically, and also initiate logging (and displaying temperature). It is experimental code, and will need enhancements; currently it is not possible to stop the logging if started, except by going to the command line.


It has some bugs, such as if multiple users connect to the browser, expect occasional erroneous values of 0 degrees C on the display briefly if multiple users connect and the system is not logging (if the system is logging, this issue does not occur). Also it may display 'error' briefly when connecting. It continues to function.


There are no known issues with the actual measurements and the logging functionality, however if you are planning to run a very long (multiple hours) experiment, it would be good to have a dry run first, to confirm the system functions for an extended time - I only ran the system for an hour or two at a time. Also, you may wish to log less frequently in that case (currently it logs every second).

Filter Blog

By date: By tag: