Hi,
I have an issue where I am trying to connect a display to my PLC and send some data to the screen from a temperature sensor. The issue I am having is that it seems my screen is not picking up the data for some reason. Now my PLC has two RX and TX ports but how will I define them in my code? For example, do I define them using the Arduino Pins and using software serial, although I prefer hardware serial, or is their another way to use them.
Also, when I use the RS232 library, I get a message notifying me that no such library exists. I am new to this device and I appreciate any help you can offer. The code is below and your thank you.
#include <Arduino.h>
#include <stdio.h>
//#include <RS232.h>
#include <genieArduino.h>
Genie genie;
// RX and Tx pin
//#define RXpin RX
//#define TXpin TX
//#define resetpin Reset
// gpio 34 as analog to digital pins + input only pins
#define temp_in_pin I0_2 // analog input : PLC Pinout IO.2 : Arduino Pin 54 : this is from the User Guide
// int temp_in_pin = I1_8;
float temp_read;
//mV assuming 250 Ohms resistors in series // values should technically be int, but compiler takes 'smaller' data types and converts into 'larger' data types
float input_min = 1000; // minimum voltage input
float rate_DegV = 0.075; // degrees Farenheit per millivolt
float offset_temp = 2.4; // offset voltage needs to be tested
// Temperature outputs using variables above
float temperatureC;
float temperatureF;
// Temperature strings
String Farh = " Farenheit";
String Celc = " Celcius";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //
Serial1.begin(115200); // serial Rx1 and Tx1 pins on
genie.Begin(Serial1);
pinMode(temp_in_pin, INPUT);
delay(4000); // to help in uploading code and preventing serial overload
}
void loop() {
temp_read = analogRead(temp_in_pin); //reading pin I0_2 in zone C
Serial.println(temp_read);
temperatureF = ((temp_read - input_min) * rate_DegV) + offset_temp;
Serial.println(temperatureF + Farh);
temperatureC = (temperatureF - 32.0) * (5.0/9.0) ; // 500mV offset with 10 mV per degree
Serial.println(temperatureC + Celc); //celcius
if(temperatureF > -100){
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, temperatureF);
}
//delay(1000); // reloop after 1 second
}