Getting Artisan to talk to Arduino - Page 2

Discuss roast levels and profiles for espresso, equipment for roasting coffee.
Rickpatbrown
Posts: 460
Joined: 5 years ago

#11: Post by Rickpatbrown »

maniel75 wrote:Hello
My configuration is:

- Arduino Uno
- Thermocouple MAX6675 K
- Artisan 2.0
- Popcorn popper

Problem: I'm getting -1 for BT

my guess is that Artisan cannot read the temperature.

Thanks for your help

image
Comment removed

rollag
Posts: 2
Joined: 4 years ago

#12: Post by rollag »

greensloth wrote:I gave up on the Python script and tried out the Modbus setup. It works. Thanks gullygossner!

I had to tweek a few things for my setup. It wasn't working at first because of the Artisan Device Assignment. I had Curves and LCDs both set to ET only. Apparently Artisan defaults to BT when there is only one input. After correcting this I could log data.

I noticed an error in the Arduino code that caused the temperature to show only integer values. An additional set of parenthesis took care of that. There was a -1 in the line that defines the data array. This caused a warning when compiling the code but didn't seem to affect function. After removing the negative sign, it compiles without errors.

I cleaned up the code a bit and added some comments. The code I'm running is shown below. I'm not running any heater control so those lines are commented out. Hopefully this version will help some other newbies get things up and running.
/*
 * This sketch programs Ardunio to communicate with Artisan using MODBUS protocol and 
 * an inexpensive thermocouple amplifier.
 * 
 * Hardware: 
 *  Arduino UNO
 *  Thermocouple amplifier (MAX6675 or MAX31855)
 *  K-type thermocouple
 *  
 * Libraries needed:
 *  https://github.com/adafruit/Adafruit-MAX31855-library or;
 *  https://github.com/adafruit/MAX6675-library and;
 *  https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
 */
 
#include <max6675.h>
// #include <Adafruit_MAX31855.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 = 6;
int thermoCS = 5;
int thermoCLK = 4;

// declare variables for Arduino pins to power MAX:
int vccPin = 3;
int gndPin = 2;

// use the line below that applies
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
// Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);

// declare variable for Arduino pin connected to solid state relay (SSR)
// int ssr = 5;  
  
void setup() {
  // configure the pins to power MAX and SSR
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  // pinMode(ssr, OUTPUT);
  
  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.readFahrenheit()*10));
   // au16data[2] = ((uint16_t) (thermocouple.readCelsius()*10));
   
   slave.poll( au16data, 16 );

   // heater control loop:
   // for(int i=1; i<=99; i++) {
    // if(i<=au16data[4])
      // digitalWrite(ssr, HIGH);
    // else
      // digitalWrite(ssr, LOW);
   // delay(5);
   // }

   // add delay if commenting out heater control loop
   delay(200);
}

have been trying to get a Arduino UNO to connect with Artisan and following this sketch not working..i had tried compailed in Arduino ide problem with modbus slave//.. kindly please giving advice. thanks

User avatar
CarefreeBuzzBuzz
Posts: 3878
Joined: 7 years ago

#13: Post by CarefreeBuzzBuzz »

If all of you here come to some consensus, then we can find a way to get this into the Artisan Quick Start Guide. Let me know if you all do. Thanks.
Artisan.Plus User-
Artisan Quick Start Guide
http://bit.ly/ArtisanQuickStart

rollag
Posts: 2
Joined: 4 years ago

#14: Post by rollag »

gullygossner wrote:I ran mine using the modbus protocol under config>device>meter
image

Then setup the arduino via the config>port>modbus as follows (note that comm port /dev/tty.usbmodem14101 didn't show up in the drop down, I had to use a terminal command to figure out my comm port and manually enter it)
image

I used the following sketch pulled from https://medium.com/@lukasgrasse/how-to- ... a3334fd7d5 and modified to work with my max31855. It was originally written to work with the max 6675. I just commented those lines out so it wouldn't take much for you to get it working with your max6675. There is some erroneous code as it was meant to control a SSR for heating. You could comment out or delete those lines if you wanted.
// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple

//#include <max6675.h>
#include <ModbusRtu.h>
#include <Adafruit_MAX31855.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 object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  u8serno : serial port (use 0 for Serial)
 *  u8txenpin : 0 for RS-232 and USB-FTDI 
 *               or any pin number > 1 for RS-485
 */
Modbus slave; // this is slave @1 and RS-232 or USB-FTDI




int thermoDO = 10;
int thermoCS = 12;
int thermoCLK = 13;

Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
  

int ssr = 5;  
  
void setup() {
  //pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  //pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  pinMode(ssr, OUTPUT);
  slave = Modbus(1,0,0);
  slave.begin( 19200 ); // 19200 baud, 8-bits, even, 1-bit stop
  // use Arduino pins 
 delay(500);
  
}

void loop() {
  // basic readout test, just print the current temp
  
  
   au16data[2] = ((uint16_t) thermocouple.readCelsius()*100);
   
   slave.poll( au16data, 16 );

   for(int i=1; i<=99; i++) {
    if(i<=au16data[4])
      digitalWrite(ssr, HIGH);
    else
      digitalWrite(ssr, LOW);
    
    delay(5);
   }
   
}
I tried inserting this sketch in Arduino Uno, and. temperature is read in the arduino ide plotter menu tool and the serial port utility. but can not be read in the artisan software. with the description "Modbus connection error"
Is it necessary to add the device so it can be read in the artisan software?
please enlighten and advise from the masters.

Smplif8
Posts: 11
Joined: 4 years ago

#15: Post by Smplif8 »

I have been too trying to get Artisan to talk to Arduino Mega 2560 without success, I first tried MODBUS route and experienced so many problems, I eventually sort of got it to work but it seems the communication is intermittent, every few other readings are bad, and I have no idea how to interpret the data Artisan receives, I tried outputting both Celsius and Fahrenheit from Arduino but the data Artisan receives is not close to what the temperature supposed to be. Long story short, I finally gave up on MODBUS.

I then tried the TC4-Emulator that FilePhil wrote, I stripped the code down to minimum, without the thermocouple reading, assigning fixed values to tempA and tempB just to test the serial communication between Artisan and Arduino, still no luck, I can see in serial monitor that Artisan sends out "READ" command but receives nothing. It works if I use the Arduino IDE built in serial monitor, it returns correct string when I send the "READ" command, I tried everything I could think of without any luck, tried different Baud rate, assigned different com port number, even use different computer (both Windows machines),,,,. One thing weird I could see is the the Arduino seemed to be locked up when Artisan was talking to it, I couldn't even reset it by press the reset button.

I appreciate your help and ideas!

Thanks!

Smplif8
Posts: 11
Joined: 4 years ago

#16: Post by Smplif8 »

I think I am making some progress. I found out that I have to turn on the Artisan first, then perform a reset on the Arduino mega by long pressing the reset button, after that the Artisan can start to receive the temperature data from Arduino, I am not sure if this is supposed to be the correct procedure for getting Arduino talked to Artisan.

Currently my setup is a West Bend hopper which is PID controlled by Arduino, I just want to log my roasting profile using Artisan. I only have one thermocouple measuring the BT, I may add a 2nd one for the ET.

Cheers!

flipmodemedian
Posts: 1
Joined: 4 years ago

#17: Post by flipmodemedian »

Well, I think I finally figured it out. Got a MAX31865 for BT and a DHT11 for ET talking to a Metro 328 which is talking to Artisan using MODBUS. I documented everything here: https://github.com/austinj/arduinosan. Hope this helps!

mtbizzle
Posts: 246
Joined: 4 years ago

#18: Post by mtbizzle »

flipmodemedian wrote: Well, I think I finally figured it out. Got a MAX31865 for BT and a DHT11 for ET talking to a Metro 328 which is talking to Artisan using MODBUS. I documented everything here: https://github.com/austinj/arduinosan. Hope this helps!
Does this allow for PID control?

I'm currently trying to determine a plan/shopping list for a popper/Artisan/PID setup. There seem to be so many people who have run into various errors, I figure it would probably be worth asking someone who has a working set up what they did and replicate it rather than trying to do something like reinvent the wheel.
"All people by nature desire to know" -Aristotle

robhh
Posts: 7
Joined: 4 years ago

#19: Post by robhh »

Hi,

Thanks to this great post I managed to get my ESP 8266 Wifi module talk to Artisan, so now I can send temperatures via wifi and the local network to Artisan.

Now I would like to send the burner percentage the opposite way, from Artisan to the 8266. I was not able to find any information on this. Anyone here who has suggestions?

Best regards, Rob.

User avatar
CarefreeBuzzBuzz
Posts: 3878
Joined: 7 years ago

#20: Post by CarefreeBuzzBuzz »

Phidgets now has a wifi enabled Vint Hub which may be an easier solution for some looking for wifi. Not an Arduino device of course.
Artisan.Plus User-
Artisan Quick Start Guide
http://bit.ly/ArtisanQuickStart