Arduino Two Channel Thermometer with Display (Full Code)

Pictured below is a two-channel thermometer we recently built for a customer. This device takes inputs from two ds18b20 temperature sensors and displays their measured temperatures on a 1602 LCD display module. The thermometer is built around an Arduino Pro Mini.

Arduino double thermometer with lcd display - full code provided

Below is the full Arduino sketch (code) for our device.

See this guide to Connecting an I2C Display to Arduino for the LCD connections. We have added the necessary 3k3 pull up resistors between pin A4 and 5V, and pin A5 and 5V – click here to read about I2C Pull Up Resistors. We have also used an external 5V regulator rather than relying on the 5V regulator built into the Arduino Pro Mini, and added reverse polarity protection on the input with a 1N4001 diode.

// © reuk.co.uk - 2018
// Double Thermometer with Display.

// For the DS18B20 temperature sensors.
#include <OneWire.h> // (https://github.com/PaulStoffregen/OneWire)
#include <DallasTemperature.h> // (https://github.com/milesburton/Arduino-Temperature-Control-Library)

// Data wires are plugged into pins 2 and 3 on the arduino.
#define ONE_WIRE_BUS 2
#define SECOND_BUS 3

// For the 1602 LCD module.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Note that some modules have address 0x3F

#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

// Setup a oneWire instances to communicate with OneWire devices.
OneWire oneWire(ONE_WIRE_BUS);
OneWire secondWire(SECOND_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensor1(&oneWire);
DallasTemperature sensor2(&secondWire);

float sensorOneTemperature = 0.0;
float sensorTwoTemperature = 0.0;

void setup(void)
{
 // Start up the temperature sensor library.
 sensor1.begin();
 sensor2.begin();
 
 // Set the temperature sensor resolutions to 11 bit
 // ADC (12 bit is much slower but higher resolution).
 sensor1.setResolution(11);
 sensor2.setResolution(11);
 
 // Initialise the LCD.
 lcd.begin (16,2); // For a 16x2 character LCD
 // Switch on the LCD backlight.
 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
 lcd.setBacklight(HIGH);
 // Clear the LCD screen.
 lcd.clear();
}

void loop(void)
{ 
 // Read in the temperatures of the two sensors.
 sensor1.requestTemperatures(); // Read temperature of sensor1
 sensorOneTemperature = sensor1.getTempCByIndex(0);
 sensor2.requestTemperatures(); // Read temperature of sensor2
 sensorTwoTemperature = sensor2.getTempCByIndex(0);

 // Display the temperatures of the sensors on the LCD.
 displayTemperatures();
}

void displayTemperatures(){
 // Display sensor1's temperature.
 lcd.setCursor(0,0);
 lcd.print(" T1: ");
 lcd.print(sensorOneTemperature,2);
 lcd.print((char)223);
 lcd.print("C ");
 
 // Display sensor2's temperature.
 lcd.setCursor(0,1);
 lcd.print(" T2: ");
 lcd.print(sensorTwoTemperature,2);
 lcd.print((char)223);
 lcd.print("C ");
}

If you need any kind of bespoke thermometer or thermostat, please email neil@reuk.co.uk with details of your specific requirements.

Formula 1 Race Starting Lighting Timer

formula 1 racing timerPictured above is a timer we recently built for a customer which will be used in a Formula 1 style race start lighting gantry. This gantry will be fitted at the top of a slope with toy cars held by a small gate latched up by a small solenoid with a spring loaded core. When the race is to start, the solenoid is energised which drops the gate allowing the cars to roll down the slope in their race.

In the photograph, five red LEDs are temporarily attached to the timer board for testing, but these will be mounted into the gantry across the track when it is finished.

When the user presses the button, the LEDs follow the standard F1 race start sequence – each red LED turns on in sequence with a one second interval. As each LED turns on, an on board piezo buzzer briefly pips. Then, when all five LEDs are illuminated, there is a random time interval of between 1 and 3 seconds before all the LEDs are turned off.

formula 1 race starting gantryThe lights turning off indicates that the race is to start. The buzzer sounds for 1 second, while the on board relay energises for 1 second to energise the solenoid and start the race.

If you need any kind of bespoke timer or controller, please email neil@reuk.co.uk with details of your requirements.

2x12V 24V Battery Bank Low Voltage Disconnect

24V battery bank low voltage disconnect LVD with dual battery measurementPictured above is a low voltage disconnect (LVD) we recently made for use with a 24V battery bank comprising two 12V batteries. These two batteries do not equalise well (i.e. they do not hold the exact same charge or show the same voltage), and so this low voltage disconnect has to look at both batteries independently and take actions based upon the measurements of the weakest battery.

This device is based around our OLED display 12V LVD with some major modifications. The batteries are connected in series to make a 24V bank. The device measures the voltage of the whole battery bank and also measures the voltage of the first 12V battery. The second 12V battery voltage is then calculated by subtracting the first 12V battery voltage from the 24V battery bank voltage.

OLED display on 24V battery bank LVDThe OLED display on the low voltage disconnect shows the two battery voltages which make up the bank, the status of the LVD, and the voltage threshold (user programmable) at which the status of the LVD will next change (turn off the output if it is on, turn it on if it is off) depending on the charge level of the two batteries in the bank.

If the voltage of either battery in the battery bank falls below the low voltage threshold set by the user, the output will be turned off cutting the power to any devices being powered by the battery bank. When both of the batteries in the bank then reach a voltage in excess of the high voltage threshold set by the user, the output is restored reconnecting power to the devices powered by the battery bank.

If you need any kind of low voltage disconnect, please take a look at our range of LVD products, and email neil@reuk.co.uk if you have any special requirements.

Dual Pulse Spot Welder Timer Controller

Pictured below is our popular 12VDC dual pulse spot welder timer controller which we designed, build, and sell.dual pulse spot welder controller

Spot welding (resistance spot welding – RSW) is used to join metal surfaces by passing a large electric current through them. Because of the heat generated by the resistance to the electric current, the contacting metals melt together forming a weld at the spot through which the current is passing.

In order to get good clean reliable welds and not to burn holes through the metal, it is essential that the pulse of electric current is of a suitable duration which depends on the types and thicknesses of the metals to be welded as well as many other factors. Therefore an accurate timer controller is required for consistent welds.

For the best spot welds, a dual pulse controller is used in which the electric current flows for a time (pre-weld), then there is a brief pause, and then electric current flows again (welding). The first pulse clears away any plating or surface oxidation, and then the second pulse welds the now clean base materials together. Using a dual pulse welder also reduces spitting.

REUK Dual Pulse Spot Welder Controller

Our controller offers two modes of operation: single pulse mode and dual/double pulse mode. Pictured below is a view of the built in OLED display when in dual pulse mode.

dual pulse spot welder display

The user can set the durations of Pulse 1, the pause time, and Pulse 2 in 0.01 second steps between 0.01 and 1.99 seconds.

single pulse operation of spot welder

In single pulse mode, the duration of just one pulse has to be set by the user. (A future update of this device will probably include up to 10 user-programmable presets for increased convenience.)

setting spot welder pulse duration

On board buttons are provided for toggling between the single and double pulse modes, entering programming mode to set the timings, and making a spot weld with the displayed settings. Screw in terminals are provided so that external buttons can be connected – for example a foot pedal to make a weld with your hands free.

This version of the welder controller is fitted with a 10A relay which can be used to power a < 5A rated solenoid which in turn switches the welder.

Buy a Welder Timer Controller for Your Relay

For any type of welder timer controller, please email neil@reuk.co.uk with details of any special requirements. Our controller as described above is available at £21.95 plus postage.

If you require a timer which will be switching more than 10 Amps of current for your welding setup, then we also make the alternative devices pictured below which have a 1 Amp 12V output for connection to your own solid state relay (SSR) or mechanical relay. These are available for £19.95 plus postage – no relay included. Click here for a source of solid state relays.

reuk dual pulse welder timer controller for solid state relay

dual pulse welder timer with solid state relay (ssr)

If you require a bespoke device which pulses the welder with very brief times and higher time resolution – e.g. 0.001s – 1.999s instead of 0.01-1.99s – we can modify the above photographed timer controller…but only for use with a solid state relay (since SSRs can switch in 1ms (0.001s) rather than the 10’s of milliseconds it can potentially take a mechanical relay to switch). Contact us with details of your specific requirements for a quotation.

Dual Pulse Spot Welder Timer Instructions

There are two buttons on the controller. If you press the ‘down’ button, you can toggle between single pulse and dual/double pulse operation. The display will change to show which mode you are in: SINGLE or DBL (double) as well as showing the durations currently programmed into the device.

If you press and hold the down button for more than one second, the display will show SET TIMERS. If you are in single pulse mode, you can now set the single pulse duration. If you are in double pulse mode you can now set the durations of pulse 1, the pause time, and pulse 2. The top line of the display will show what is currently being programmed (Time 1, Pause Time, or Time 2), and the bottom line will show the current value. Use the up and down buttons to increase or decrease the displayed value (within the range 0.01s to 0.99s). Five seconds after you last touched a button, the top line of the display will show -SAVED- and the value will be saved in long term memory (still available the next time you power on the controller). If you are in double pulse mode, you will now be asked to set the pause time and the duration of the second pulse in exactly the same way that Time 1 was set. (When using the up and down buttons to increase or decrease a time value, you can press and hold the button to move faster through the numbers.)

If you press the up button, the controller will run. The relay will close for the duration of Time 1 and then open again. If you are in double pulse mode, it will then remain open for the duration of Pause Time and then close for the duration of Time 2.

In addition to the buttons on the controller board itself, screw in terminals are provided to which you can connect external buttons of your choosing – e.g. a foot pedal operated button, or a larger hand operated button etc for your own convenience.

Poultry Egg Incubator with On Board Display and Humidity Maintenance

We have made many poultry egg incubators and timers over the last few years – devices which monitor and maintain temperature and humidity and also turn the eggs at regular intervals. Below is an image of one such incubator controller which we were recently commissioned to build which is a bit different from those.

poultry egg incubator controller

The motor is set to turn for three seconds five times per day to rotate the eggs. This is standard.

The heating element used for this incubator is a bit oversized, so we have to be careful not to overheat the eggs when it is used. When the temperature is measured to be 0.5C or more below a user set target temperature, the heater is turned on. Then, when the target temperature is reached, the heater is turned off. Because the element remains hot after being turned off, the incubator will continue to heat up to a little above target temperature while the element cools down. Therefore, there is also a fan which turns on just in case the temperature exceeds the target by 1.5C or more to cool things down long before the eggs overheat.

display for poultry egg incubation controller

Humidity management is also achieved rather differently than usual. In all previous incubators we have made which have included humidity sensing, a commercial humidifier has been switched on/off to maintain appropriate humidity levels. For this controller, when humidity is measured to be below a user set target minimum level, a pump is turned on for five second which adds water to a container in the incubator. The rapid evaporation of this water in the warmth of the incubator increases the humidity level back above the minimum rapidly. In order to prevent flooding or raising the humidity level excessively, the controller will run the pump at most once every ten minutes.

This entire system is powered by a solar charged 12V battery bank.

If you need any type of incubator (or humidor), please email neil@reuk.co.uk with details of your requirements.

Testing 128×32 OLED IIC Display with Arduino

Many of the products we sell make use of 16×2 character LCD displays. These displays coupled with an Hitachi HD44780 LCD control module enable an Arduino or Raspberry Pi to operate the display very simply with just two data connections and two power connections required.

16x2 LCD display with module for use with Arduino and Raspberry Pi

However, these displays are physically quite large being 80 x 36mm, and while they are well suited to panel mounting, they cannot really be attached to the circuit board that is driving it without creating a device with large dimensions.

We have recently being looking at alternatives to these displays looking for something physically smaller, easily circuit board mountable, lower power consumption, and improved contrast. After much testing, we have chosen the OLED display pictured below.128x32 i2c arduino displayThese displays are far smaller having an active screen area of just 22.38 x 5.58mm. They require no backlight as each of the 128×32 pixels self-illuminates thanks to OLED technology. The maximum power consumption of one of these displays is 0.08W with every pixel illuminated – therefore less when showing text or when nothing is being displayed. In all ways these displays are an improvement on the 16×2 character LCDs.

OLED display used with arduinoThese OLED displays have much better contrast than LCDs, there is more space available to display information since more characters can be displayed, and there are much better graphics capabilities with the OLED displays. The image above shows the new OLED version of the LCD display from our REUK Low Voltage Disconnect with Display pictured below.

LCD display on REUK low voltage disconnect (LVD)

The biggest advantage however is the ease with which these OLED displays can be mounted to the circuit boards of our controllers so that we can produce more convenient small form factor integrated units with no increase in our pricing for customers.

arduino pro mini controlled 128 x 32 oled display

If you are interested in trying out one of these displays for your own projects, click here: buy 128×32 OLED Display for under £3 including delivery. If you intend to use one with an Arduino project, you will need to add the following libraries to your Arduino IDE: SSD1306 Library and Adafruit GFX Library, so that you can communicate with the display.

Controller for Heater used to Prevent Condensation on Telescope Mirror

A common problem for amateur astronomers is condensation forming on the mirror in their telescopes. During the night the mirror cools down, and then in the morning as the air warms up, condensation forms on the mirror which is colder than the surrounding air. The same thing happens to the surface of a bottle when you take it out of a fridge, but for a telescope it is problematic as condensation deteriorates the reflective coating on the mirror, and of course a foggy coating reduces the quality of the star images obtained by the telescope.

One solution to this problem is to warm up the mirror so that it remains 2 to 5 degrees Celcius above the ambient air temperature – something which can be achieved using a heating element and a thermostatic controller. If the mirror gets too cold, it will be covered in condensation. If the mirror gets too hot, it could warp. Therefore accurate control of the heating element is essential.

telescope condensation prevention controller with heater

Pictured above is one such thermostatic controller we recently prepared for a customer loosely based around our 2013 Solar Water Heating Pump Controller.

This device has two ds18b20 digital temperature sensors – one which attaches behind the mirror of the telescope and the other which measures the ambient air temperature. When the temperature at the mirror falls to within 2°C (or any other user programmable value) warmer than ambient, the heating element is switched on (via the onboard relay). The heating element stays on until the mirror has heated up to be at least 5°C (or any other user programmable value) warmer than ambient.

We used a non-waterproof sensor at the back of the mirror as this area remains dry and that sensor needs to respond to quick temperature changes. (The protection on waterproof temperature sensors slows down their response to temperature change.) We did however use a waterproof sensor to measure ambient air temperatures because that sensor is exposed and ambient air temperatures change relatively slowly.

The heating cycle continues automatically ensuring condensation does not form on the mirror, and the mirror is not over heated. This is a 12VDC powered controller managing a 12VDC heating element so that it can be battery powered when used at remote locations.

If you need a user programmable thermostatic controller for your telescope heating element, please email neil@reuk.co.uk with details of your requirements.

Triple Independent Repeating Timer for Lighting Control

Pictured below is a bespoke timer we recently made for a customer which includes three user programmable independent repeating on/off timers for controlling LED lighting.

three independent timers with a single master controller

This device built around an Arduino Pro Mini has three 12V outputs each of which can be set to turn on for from 0.5 to 15 seconds (in 0.5 second steps) and then turn off for from 0.5 to 15 seconds (in 0.5 second steps). This is a repeating timer, so each of the independent on/off cycles continues for as long as the timer is powered.

The user’s programmed settings are stored in non-volatile memory, so whenever the device is disconnected and then reconnected to the 12V power source, the timers continue as previously set.

If you need any kind of timer, please email neil@reuk.co.uk with details of your requirements.

28 Day Timer

Pictured below is a device we recently made to turn any typical 24 hour 7 day timer into a 24 Hour 28 Day Timer.

28 Day Timer

This particular unit was designed to run a pump for 20 minutes once every 28 days to supply an unattended irrigation system header tank with water. The user simply has to programme their existing programmable 7 day timer to turn on for the desired duration once per week. Our add-on board detects when that timer’s internal relay closes, and every fourth time (i.e. fourth week), it closes its own relay which turns on the pump.

Red LEDs on the board are used to show which week it currently is out of the four weeks that make up 28 days, and those LEDs also flash whenever the timer is on to give visual confirmation of the status of the system.

Programmable digital timers have a back up battery which ensures that time is kept accurately during a power cut. Our board stores the current week in memory, so that in the event of a power cut, it will remember which week it was in when power is restored.

If you need any kind of special timer, please email neil@reuk.co.uk with details of your requirements.

μduino Smallest Arduino Compatible Board – ATMEGA32U4

Pictured below are photographs of the top and bottom of prototypes of the new μduino, an Arduino-compatible board with dimensions of just 12x12mm making it probably the smallest Arduino every built – just a little bigger than a microSD card.

uduino smallest arduino compatible board

The μduino is smaller in size than the Digispark (with its ATTiny85 chip and 6 I/O pins), but uses the same ATMEGA32U4 microcontroller found on the much more powerful Arduino Leonardo offering 20 I/O pins including 6 analog and 14 digital I/O ports, 7 PWM channels, and a lot more memory.

μduino is now (early August 2017) fully funded on Crowd Supply (a crowd funding website similar to Kickstarter and Indiegogo), easily reaching and exceeding its funding goal with 11 days to spare.

μduino can be set up to operate at either 3.3V or 5V depending on the requirements of your project and any connected sensors.

The tiny size of µduino was achieved using a smaller hole separation (1.27mm vs 2.54mm) relative to standard boards, and packing the components tightly together on both sides of the board.

For full details and/or to place an order for a µduino @ US$18 (shipping on or after September 20th 2017), click here for µduino on the CrowdSupply.com website.

μduino Specs

ATMEGA32U4 microcontroller
6x Analog I/O ports
14x Digital I/O ports (including Rx/Tx)
Status LED
Dual-power modes for 3.3V and 5V operation (accepts up to 16V)
1x Power output (3.3V or 5V depending on what mode is selected)
3x Ground ports
1x Analog reference voltage port
Reset button
16 MHz precision crystal oscillator
MicroUSB port for easy programming and prototyping