Skip to content

Instantly share code, notes, and snippets.

@pawl
Last active February 12, 2024 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawl/5ed1f61e0b0b27aa839fc2b4499a92c2 to your computer and use it in GitHub Desktop.
Save pawl/5ed1f61e0b0b27aa839fc2b4499a92c2 to your computer and use it in GitHub Desktop.
arduino modbus coffee roaster with 2 thermocouples for artisan software
/*
* This sketch programs Ardunio to communicate with Artisan using MODBUS protocol and
* an inexpensive thermocouple amplifier.
*
* Hardware:
* Arduino UNO
* Thermocouple amplifier (MAX6675)
* K-type thermocouple
*
* Libraries needed:
* https://github.com/adafruit/MAX6675-library and;
* https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
*
* Based on:
* serialthermocouple arduino example
* https://github.com/hallgeirl/coffee-roaster/blob/4d4fa73c9831b0ff3f28752c454011ab70410de8/src/roaster/roaster.ino#L112-L136
*/
#include <max6675.h>
#include <ModbusRtu.h>
// data array for modbus network sharing:
uint16_t au16data[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
Modbus slave;
// declare variables for Arduino pins connected to the MAX data pins:
int thermoDO_bt = 6; // SO
int thermoCS_bt = 5;
int thermoCLK_bt = 4; // SCK
int thermoVCC_bt = 3;
int thermoGND_bt = 2;
MAX6675 thermocouple_bt(thermoCLK_bt, thermoCS_bt, thermoDO_bt);
int thermoDO_amb = 12;
int thermoCS_amb = 11;
int thermoCLK_amb = 10; // SCK
int thermoVCC_amb = 9;
int thermoGND_amb = 8;
MAX6675 thermocouple_amb(thermoCLK_amb, thermoCS_amb, thermoDO_amb);
void setup() {
// configure the pins to power MAX6675
pinMode(thermoVCC_bt, OUTPUT); digitalWrite(thermoVCC_bt, HIGH);
pinMode(thermoGND_bt, OUTPUT); digitalWrite(thermoGND_bt, LOW);
pinMode(thermoVCC_amb, OUTPUT); digitalWrite(thermoVCC_amb, HIGH);
pinMode(thermoGND_amb, OUTPUT); digitalWrite(thermoGND_amb, LOW);
slave = Modbus(1, 0, 0); // MODBUS object declaration: (1 = slave #1, 0 = RS232, 0 = RS232)
slave.begin(19200); // 19200 baud, 8-bits, none, 1-bit stop
delay(500);
}
void loop() {
au16data[2] = ((uint16_t) thermocouple_bt.readCelsius() * 100);
au16data[3] = ((uint16_t) thermocouple_amb.readCelsius() * 100);
slave.poll(au16data, 16);
// For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
delay(200);
}
@shl95
Copy link

shl95 commented Mar 9, 2023

hi i wonder how to setting artisan

@Terror212
Copy link

How to setting on artisan sir?

@AleksandrKras
Copy link

How to setting on artisan sir?

shot2
shot3

@TheProgen
Copy link

Can this be compiled in Arduino IDE and uploaded to an Uno because I kept getting a stream of error messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment