Welcome! Log In Create A New Profile

Advanced

Automatic fan control via i2c

Posted by jifop 
Automatic fan control via i2c
April 29, 2020 02:32PM
Hey all, I'm hoping someone can help me.

I've built a simple i2c relay to run my fans using an i2c expander and a relay, I can control this with the Gcode below:

To turn relay off:
M260 A32 	; i2c address 0x22
M260 B170 	; write 0xAA (on)
M260 S1   	; Send the current buffer

To turn relay on:
M260 A32 	; i2c address 0x22
M260 B85 	; write 0x55 (off)
M260 S1   	; Send the current buffer

I have put this in my slicers start and end gcode sections which works ok however I'd like to get them to come on automatically when the hotend gets warm, is there a way I can achieve this?

I used the below arduino sketch to test the board before connecting it to the printer so also have the arduino code should I need it.

#include 

// address of PCF8574 IC
#define PCF8574_ADDR (0x20)
 
void setup()
{
  Wire.begin();
}
 
void loop()
{
  //send the data
  Wire.beginTransmission(PCF8574_ADDR);
  Wire.write(0xAA);
  Wire.endTransmission();
  delay(5000);
  Wire.beginTransmission(PCF8574_ADDR);
  Wire.write(0x55);
  Wire.endTransmission();
  delay(5000);
}

Thanks,

Tim

Edited 1 time(s). Last edit at 04/30/2020 12:30PM by jifop.
Sorry, only registered users may post in this forum.

Click here to login