Hex over TTL
i'm going try , repost new topic, hope i'm not treading on toes here, started post measuring 230v through arduino uno analog pins have discovered have power meters can provide me information need through ttl serial port. tried opening new topic thought different original post 2 combined , after 24 hours nobody has responded try again new post (once again, sorry if annoying moderators.)...
i know if following (it first ever code) send 7 byte hex request meter pin 3 read reply pin 2 , print serial monitor. (thanks nick gammon great tutorials, absolutely not have gotten far without them.)
i getting no reply meter , obvious mistake might have made sketch. if know have sketch can concentrate on trouble shooting wiring etc.
any advice, comments, criticism of sketch below appreciated.
thanks
i know if following (it first ever code) send 7 byte hex request meter pin 3 read reply pin 2 , print serial monitor. (thanks nick gammon great tutorials, absolutely not have gotten far without them.)
i getting no reply meter , obvious mistake might have made sketch. if know have sketch can concentrate on trouble shooting wiring etc.
any advice, comments, criticism of sketch below appreciated.
thanks
code: [select]
#include <softwareserial.h>
softwareserial sserial(2, 3); // rx, tx pins
const unsigned int baudrate = 9600;
byte voltagerequest[] = {0xb0, 0xc0, 0xa8, 0x01, 0x01, 0x00, 0x1a}; // hex request send meter
const unsigned int max_input = 7; // how serial data expect before newline
unsigned long oldmillis = millis();
int try = 1;
void setup() {
// initialize serial:
serial.begin(9600);
sserial.begin(baudrate);
}
// print incoming sserial data serial monitor
void process_data (const char * data)
{
serial.println (data);
}
void processincomingbyte (const byte inbyte)
{
static char input_line [max_input];
static unsigned int input_pos = 0;
if (input_pos < (max_input - 1))
input_line [input_pos++] = inbyte;
else process_data (input_line);
} // end of processincomingbyte
void loop() {
// send voltage request every 2 seconds
if (millis() >= oldmillis)
{
(int = 0; <= sizeof(voltagerequest) - 1; i++)
{
sserial.write(voltagerequest[i]);
}
oldmillis = oldmillis + 2000;
}
// when software serial available
while (sserial.available() > 0)
{
processincomingbyte (sserial.read ());
}
}
perhaps no replies because don't supply information using. meter , documentation on , ttl serial port connections , data format , protocol communicating? tells meter receiving data transmission? there led in meter blinking received data?
how have arduino connected meter? meter powered , working?
paul
how have arduino connected meter? meter powered , working?
paul
Arduino Forum > Using Arduino > Project Guidance > Hex over TTL
arduino
Comments
Post a Comment