Go Down

Topic: H-gate controlling peltiers (multiple units) (Read 145 times) previous topic - next topic


Hi, I am totally new here and am struggling a bit with some coding expansion. I am building a temperature gradient board using 10 ceramic tiles heated by peltiers with ds18b20 sensors using 5 dual gated H-gates so that i am able to cool as well as heat the tiles. All this is thru a Mega 2560
the sketch i am using is as below and i am not sure how the coding goes to expand it out to include the 10 sensors (one wire and i have the addresses) and the individual control of the outputs to the digital pins.
this sketch works fine for what i am doing but only works the one H-gate

if anyone can help, it would be appreciated

#include <Wire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define RELAY1 50  // Relay heating
#define RELAY2  51  // Relay coolingv

int red = 53; // red LED heating
int blue = 52;
#define BACKLIGHT_PIN 13
#define ONE_WIRE_BUS 7
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {

  lcd.begin(20, 4);

  pinMode(red, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);


void loop() {
  lcd.setCursor(0, 0);
  lcd.print(" TEMP today");

  float temperature = sensors.getTempCByIndex(0);
  lcd.setCursor(3, 1);
  lcd.print("      ");

  if (temperature < 24.00)
    digitalWrite(red, HIGH);
    digitalWrite(blue, LOW);

    lcd.setCursor(0, 1);

    digitalWrite(RELAY1, 0);
    digitalWrite(RELAY2, 1);
  else if (temperature > 24.00)
    digitalWrite(RELAY1, 1);
    digitalWrite(RELAY2, 0);
    digitalWrite(red, LOW);
    digitalWrite(blue, HIGH);

    lcd.setCursor(0, 1);
    lcd.print("Cooling ");
    lcd.setCursor(0, 3);


i would also like the individual tile temps displayed on the lcd.
thanks for your time


have i posted this in the wrong forum section?
i thought i was multiplexing
let me know as new to this forum


Unfortunately I cannot help with your technical issues. However, the forum ask that certain conditions be followed--which can be found at the top of the first page of every topic page "How to use the forum - Please read".

One that helps is to use the </> to post code so that one doesn't need to scroll through a lot of code to read what is being said and asked. Goes along the overarching theme on here of 'help yourself before we help you'


May 20, 2019, 08:14 pm Last Edit: May 20, 2019, 08:16 pm by Grumpy_Mike
A program without a schematic of the hardware is useless, so please post a schematic.

Using 10 peltier devices is going to take one hell of a lot of current. Have you calculated how much?

If the temperature gradient across a device exceeds a certain value then what was a cooling action flips round to be a heating action causing runaway heating. Think of these things as heat pumps you need to get rid of the heat on the other side with heat sinks, probably with forced air cooling.

i thought i was multiplexing
Yes it is the multiplexing section. However I can't see any multiplexing going on in your project. Click on the report to moderator link on your post and ask them to move it.

Go Up