Good Morning
I am new to Arduino and PHPoC. I am using an Arduino Uno and the Arduino - RS-232 Expansion Board example to support a test of equipment that converts serial data to IP, multiplexes it and sends it through a Serial tunnel to a receiving station that reverses the process. I have putty connected to the USB to serial COM port and am monitoring the Arduino using serial com port output. Everything works fine and I seem to gave a good data connection through my tunnel.
What I am looking for now is a way to simulate my production systems which send repeated data with a two second pause. I would like to do this without having to manually type something into the putty connection.
I connected a DHT 11 and it shows the weather data on the Arduino serial monitor screen but only after I hit a key on the Putty screen. I am also not sure if that data is actually passing through the tunnel or if it is just being generated locally when the rs232 stream initiates.
Could I just connect the dht data output to one of the 232 data input pins and pipe that through the connection?
The code I used is
// Arduino Example for RS-232 Expansion Board (PES-2606)
//
// PES-2606 is an easy-to-use RS-232 expansion board for Arduino Uno and Mega,
// which allows Arduino to exchanging data with serial device via RS-232.
//
// This is an Arduino example that receive data from a serial device, send back
// the serial device via RS-232 and print the data to serial monitor.
//
// Arduino communicates with RS-232 expansion board through PHPoC [WiFi] Shield
// using pins 10, 11, 12 and 13 on the Uno, and pins 10, 50, 51 and 52 on the
// Mega. Therefore, these pins CANNOT be used for general I/O.
//
// This example code was written by Sollae Systems. It is released into the
// public domain.
//
// Tutorial for the example is available here:
// https://forum.phpoc.com/articles/tut...xpansion-board
#include <Phpoc.h>
#include <PhpocExpansion.h>
#include <DHT.h>
// size of application buffer, reduce it if memory of Arduino is not enough
#define BUFFER_SIZE 100
byte expansionId = 1;
ExpansionSerial rs232(expansionId);
// application buffer
byte rwbuf[BUFFER_SIZE];
//Constants
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT11 // DHT11
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino
//Variables
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup() {
Serial.begin(9600);
while(!Serial)
;
// initialize PHPoC [WiFi] Shield
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
// initialize expansion board
Expansion.begin();
// get name and print it to serial
Serial.println(rs232.getName());
// set baudrate, parity, data bit, stop bit and flow control to 9600, none,
// 8 bit, 1 bit and no flow control, respectively.
rs232.begin(F("9600N81N"));
Serial.println("DHT11 sensor testing");
//Initialize the DHT sensor
dht.begin();
}
void loop() {
// get the size of the received data in the receiving buffer of RS-232
// expansion board
int rxlen = rs232.available();
if(rxlen > 0) {
// read and write length
int rwlen;
// get the size of free space in the sending buffer of RS-232 expansion
// board
int txfree = rs232.availableForWrite();
// check to make sure that read data does not exceed size of application
// buffer
rwlen = min(rxlen, BUFFER_SIZE);
// check to make sure that write data does not exceed free space in the
// sending buffer of RS-232 expansion board
rwlen = min(rwlen, txfree);
// receive data from the receiving buffer of RS-232 expansion board and save
// it to the application buffer
rwlen = rs232.readBytes(rwbuf, rwlen);
// send data from the application buffer to the sending buffer of RS-232
// expansion board
rs232.write(rwbuf, rwlen);
// print data to serial monitor of Arduino IDE
Serial.write(rwbuf, rwlen);
float converted = 0.00;
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
Serial.print("Celsius = ");
Serial.print(temp);
Serial.println(" C");
//Fahrenheit
//T(°F) = T(°C) × 9/5 + 32
converted = ( temp * 1.8 ) + 32;
Serial.print("Fahrenheit = ");
Serial.print(converted);
Serial.println(" F");
//Kelvin
//T(K) = T(°C) + 273.15
converted = temp + 273.15;
Serial.print("Kelvin = ");
Serial.print(converted);
Serial.println(" K");
//Rankine
//T(°R) = (T(°C) + 273.15) × 9/5
converted = temp + 273.15;
converted = (converted * 1.8);
Serial.print("Rankin = ");
Serial.print(converted);
Serial.println(" R");
Serial.print("Humidity = ");
Serial.println(hum);
//2000mS delay between reads
delay(2000);
}
}
I am new to Arduino and PHPoC. I am using an Arduino Uno and the Arduino - RS-232 Expansion Board example to support a test of equipment that converts serial data to IP, multiplexes it and sends it through a Serial tunnel to a receiving station that reverses the process. I have putty connected to the USB to serial COM port and am monitoring the Arduino using serial com port output. Everything works fine and I seem to gave a good data connection through my tunnel.
What I am looking for now is a way to simulate my production systems which send repeated data with a two second pause. I would like to do this without having to manually type something into the putty connection.
I connected a DHT 11 and it shows the weather data on the Arduino serial monitor screen but only after I hit a key on the Putty screen. I am also not sure if that data is actually passing through the tunnel or if it is just being generated locally when the rs232 stream initiates.
Could I just connect the dht data output to one of the 232 data input pins and pipe that through the connection?
The code I used is
// Arduino Example for RS-232 Expansion Board (PES-2606)
//
// PES-2606 is an easy-to-use RS-232 expansion board for Arduino Uno and Mega,
// which allows Arduino to exchanging data with serial device via RS-232.
//
// This is an Arduino example that receive data from a serial device, send back
// the serial device via RS-232 and print the data to serial monitor.
//
// Arduino communicates with RS-232 expansion board through PHPoC [WiFi] Shield
// using pins 10, 11, 12 and 13 on the Uno, and pins 10, 50, 51 and 52 on the
// Mega. Therefore, these pins CANNOT be used for general I/O.
//
// This example code was written by Sollae Systems. It is released into the
// public domain.
//
// Tutorial for the example is available here:
// https://forum.phpoc.com/articles/tut...xpansion-board
#include <Phpoc.h>
#include <PhpocExpansion.h>
#include <DHT.h>
// size of application buffer, reduce it if memory of Arduino is not enough
#define BUFFER_SIZE 100
byte expansionId = 1;
ExpansionSerial rs232(expansionId);
// application buffer
byte rwbuf[BUFFER_SIZE];
//Constants
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT11 // DHT11
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino
//Variables
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup() {
Serial.begin(9600);
while(!Serial)
;
// initialize PHPoC [WiFi] Shield
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
// initialize expansion board
Expansion.begin();
// get name and print it to serial
Serial.println(rs232.getName());
// set baudrate, parity, data bit, stop bit and flow control to 9600, none,
// 8 bit, 1 bit and no flow control, respectively.
rs232.begin(F("9600N81N"));
Serial.println("DHT11 sensor testing");
//Initialize the DHT sensor
dht.begin();
}
void loop() {
// get the size of the received data in the receiving buffer of RS-232
// expansion board
int rxlen = rs232.available();
if(rxlen > 0) {
// read and write length
int rwlen;
// get the size of free space in the sending buffer of RS-232 expansion
// board
int txfree = rs232.availableForWrite();
// check to make sure that read data does not exceed size of application
// buffer
rwlen = min(rxlen, BUFFER_SIZE);
// check to make sure that write data does not exceed free space in the
// sending buffer of RS-232 expansion board
rwlen = min(rwlen, txfree);
// receive data from the receiving buffer of RS-232 expansion board and save
// it to the application buffer
rwlen = rs232.readBytes(rwbuf, rwlen);
// send data from the application buffer to the sending buffer of RS-232
// expansion board
rs232.write(rwbuf, rwlen);
// print data to serial monitor of Arduino IDE
Serial.write(rwbuf, rwlen);
float converted = 0.00;
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
Serial.print("Celsius = ");
Serial.print(temp);
Serial.println(" C");
//Fahrenheit
//T(°F) = T(°C) × 9/5 + 32
converted = ( temp * 1.8 ) + 32;
Serial.print("Fahrenheit = ");
Serial.print(converted);
Serial.println(" F");
//Kelvin
//T(K) = T(°C) + 273.15
converted = temp + 273.15;
Serial.print("Kelvin = ");
Serial.print(converted);
Serial.println(" K");
//Rankine
//T(°R) = (T(°C) + 273.15) × 9/5
converted = temp + 273.15;
converted = (converted * 1.8);
Serial.print("Rankin = ");
Serial.print(converted);
Serial.println(" R");
Serial.print("Humidity = ");
Serial.println(hum);
//2000mS delay between reads
delay(2000);
}
}
Comment