Merhaba bu konuyu inceleyerek çok faydlandım teşekkür ederim, arduino ile yaptığım sıcaklık takip sistemimi artisan a bağladım daha önce yapamam diye hiç yeltenmemiştim ancak şöyle bir sorunum oluştu artisan ile arduino ya bağladığım lcd ekranı aynı anda kullanamıyorum yardımcı olabilecek varmıdır ?
yazdığım kodları buraya kopyalıyorum modbus ve lcd ekran kodlarını aynı anda yazdığımda lcd ekran çalışıyor fakar artisan modbusa bağlantı hatası veriyor
arduino max6675 ve lcd ekranda kullandığım kod budur
#include "max6675.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd1(0x27, 16, 2);// I2C address is 0x3F
// pins for first thermocouple
int so1Pin = 4;
int cs1Pin = 5;
int sck1Pin = 6;
// pins for 2nd thermocouple
int so2Pin = 8;
int cs2Pin = 9;
int sck2Pin = 10;
// pins for 3nd thermocouple
int so3Pin = 11;
int cs3Pin = 12;
int sck3Pin = 13;
MAX6675 thermocouple1(sck1Pin, cs1Pin, so1Pin);
MAX6675 thermocouple2(sck2Pin, cs2Pin, so2Pin);
MAX6675 thermocouple3(sck3Pin, cs3Pin, so3Pin);
void setup() {
lcd1.begin();// initialize the LCD1602(LCD1)
lcd1.backlight();// turn the backlight ON for the LCD(LCD1)
Serial.begin(9600);// initialize serial monitor with 9600 baud
Serial.println("");
}
void loop() {
Serial.print("C_1 = ");
Serial.print (thermocouple1.readCelsius());
Serial.print("C_2 = ");
Serial.print (thermocouple2.readCelsius());
Serial.print("C_3 = ");
Serial.print (thermocouple3.readCelsius());
lcd1.clear();// clear previous values from screen (1)
lcd1.setCursor(0,0);// set cursor at character 0, line 0
lcd1.print(thermocouple3.readCelsius()); // print temperature in Celsius
lcd1.setCursor(5,0);// set cursor at character 9, line 0
lcd1.print((char)223);
lcd1.setCursor(6,0);// set cursor at character 9, line 0
lcd1.print("C");
lcd1.setCursor(0,1);// set cursor at character 0, line 1
lcd1.print(thermocouple1.readCelsius()); // print temperature in Celsius
lcd1.setCursor(5,1);// set cursor at character 9, line 1
lcd1.print((char)223);
lcd1.setCursor(6,1);// set cursor at character 9, line 1
lcd1.print("C");
lcd1.setCursor(7,1);// set cursor at character 9, line 1
lcd1.print(" ");
lcd1.setCursor(9,1);// set cursor at character 9, line 1
lcd1.print(thermocouple2.readCelsius()); // print temperature in Celsius
lcd1.setCursor(14,1);// set cursor at character 9, line 1
lcd1.print((char)223);
lcd1.setCursor(15,1);// set cursor at character 9, line 1
lcd1.print("C");
delay(2000);
}
artisana bağlamak için kullandığım kod budur
#include <max6675.h>
#include <ModbusRtu.h>
uint16_t au16data[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
Modbus slave;
int so1Pin = 4;// SO1=Serial Out
int cs1Pin = 5;// CS1 = chip select CS pin
int sck1Pin = 6;// SCK1 = Serial Clock pin
int so2Pin = 8;// SO1=Serial Out
int cs2Pin = 9;// CS1 = chip select CS pin
int sck2Pin = 10;// SCK1 = Serial Clock pin
int so3Pin = 11;// SO1=Serial Out
int cs3Pin = 12;// CS1 = chip select CS pin
int sck3Pin = 13;// SCK1 = Serial Clock pin
MAX6675 thermocouple1(sck1Pin, cs1Pin, so1Pin);
MAX6675 thermocouple2(sck2Pin, cs2Pin, so2Pin);
MAX6675 thermocouple3(sck3Pin, cs3Pin, so3Pin);
void setup() {
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) (thermocouple1.readCelsius()*100));
au16data[3] = ((uint16_t) (thermocouple2.readCelsius()*100));
au16data[4] = ((uint16_t) (thermocouple3.readCelsius()*100));
slave.poll( au16data, 16 );
delay(200);
}
