Overview:
- Built around an Arduino NANO – a compact Arduino that has a USB port for simple programming.
- A high power MOSFET to control the current to the ZVS module
- On board resistors allow for LEDs to be attached without the need for any extra components – includes terminals to attach an RGB LED as well as 2 extra LED terminals (resistor values are specified for red, green or yellow LEDS)
- A low power transistor controls a 12v circuit for attaching 12v LEDs (such as those in illuminated buttons)
- A voltage sensor for monitoring battery charge.
- A TMP36 temperature sensor protects the electronics from overheating if something goes wrong
- A 1µf capacitor attached to the trigger button circuit prevents debouncing
- Breakout solder terminals are included for I2C and Serial connections
- 3 and 5V solder terminals for powering external sensors or modules
Pin Out:
Arduino Pin | Input / output | Connected to |
D11 | OUTPUT (pwm) | red pin of RGB LED |
D10 | OUTPUT (pwm) | green pin of RGB LED |
D9 | OUTPUT (pwm) | blue pin of RGB LED |
D8 | DIGITAL INPUT | trigger button |
D5 | OUTPUT (pwm) | LED 2 |
D4 | OUTPUT | LED 1 |
D3 | OUTPUT (pwm) | MOSFET |
D2 | OUTPUT | 12v out |
A1 | ANALOG INPUT | TMP36 temperature sensor |
A4 | I2C | SDA |
A5 | I2C | SCL |
A6 | ANALOG INPUT | voltage sensor |
A7 | ANALOG INPUT | potentiometer |
Code:
/*
- Starter code for VapOven Arduino Shield.
* - This code will turn on the IH module and light up LED1 when the trigger button is pressed.
- It uses the RGB LED as a battery indicator – green when battery is good, red when battery is low.
- It monitors the temperature and will not activate the IH if the temperature is over 60 deg Centigrade
* - Code is included to read the potentiometer output but the value is not used.
* - This code is free to use and modify
*
*/
//pins
int triggerPin = 3;
//LEDs
int LED12v = 2;
int LED1 = 4;
int LED2 = 5;
int blueRGB = 9;
int greenRGB = 10;
int redRGB = 11;
//inputs
int buttonPin = 8;
int potPin = A7;
//sensors
int tempPin = A1;
int voltSensorPin = A6;
bool buttonState; //variable for the button press
bool ovenOn = LOW; //the main oven on / off variable
int tempC; //temperature from TMP36 sensor
int tempCutOff = 60; //temperature in Centigrade to stop IH activating
float voltage; //battery voltage
double lowBatteryThreshold = 10; //the voltage value to turn the battery indicator from green to red
int potValue; // value returned from potentiometer
void setup() {
//set up all the pins
pinMode(buttonPin, INPUT);
pinMode(triggerPin, OUTPUT);
pinMode(LED12v, OUTPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(blueRGB, OUTPUT);
pinMode(greenRGB, OUTPUT);
pinMode(redRGB, OUTPUT);
}
void loop() {
//check the temperature
tempC = getTemp();
//check the battery voltage (if the button isn’t pressed)
if(ovenOn == LOW) voltage = getVoltage();
//set the RGB LED colour to indicate battery level
if(voltage >= lowBatteryThreshold){
digitalWrite(redRGB, LOW);
digitalWrite(greenRGB, HIGH);
digitalWrite(blueRGB, LOW);
}
else{
digitalWrite(redRGB, HIGH);
digitalWrite(greenRGB, LOW);
digitalWrite(blueRGB, LOW);
}
//read the potentiometer value
potValue = analogRead(potPin);
//check if the button is pressed
buttonState = digitalRead(buttonPin);
//if the button is pressed set oven to on, else set it to off
if(buttonState == HIGH) ovenOn = HIGH;
else ovenOn = LOW;
//if the temperature is above the cutoff, set the oven to off
if(tempC >= tempCutOff){
ovenOn = LOW;
}
// on off switch for oven
if(ovenOn == HIGH){
digitalWrite(LED1, HIGH);
digitalWrite(triggerPin, HIGH);
}
else{
digitalWrite(LED1, LOW);
digitalWrite(triggerPin, LOW);
}
}
//returns temperature in celcius from TMP36 sensor
int getTemp(){
int tempReading = analogRead(tempPin);
// converting to voltage
double voltage = tempReading * 5.0;
voltage /= 1024.0;
// output the temperature
double tempCdoub = (voltage – 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage – 500mV) times 100)
//parse from double to int
int tempCint = tempCdoub;
return tempCint;
}
//returns the battery voltage
float getVoltage(){
int data = 0;
float V = 0.0;
float R1 = 47000.0;
float R2 = 22000.0;
data = analogRead(voltSensorPin);
V = (data * 5.0) / 1024.0;
return(V / (R2 / (R1 + R2)));
}