Hi,
I want to send my Data Logged by an Arduino Mega 2560 using the USB to UART Cable to a RaspberryPi3 with an emoncms installation (latest Version) an log it ehre remotely. I figured this should be pretty easy using the serialprint() function.
I allready found this documentation on how to do this. Sadly it is refering to the deprecated gatewayconfig of Jerome.
Then I found within the examples of emonHUB (sadly documentation links on git are dead ends) this examples for a directserial connection:
Emonhub can read from a serial device directly e.g. /dev/ttyUSB0
Data Format
Data should be printed to serial (integer only) with space sperators in the format:
NODEID VAR1 VAR2 VAR3
…and so on
Here is an example of printing data from an Arduino sketch:
Serial.print(nodeID); Serial.print(' ');
Serial.print((int)(realPower1)); Serial.print(' '); // These for compatibility, but whatever you need if emonHub is configured to suit.
Serial.print((int)(realPower2)); Serial.print(' ');
Serial.print((int)(realPower3)); Serial.print(' ');
Serial.print((int)(realPower4)); Serial.print(' ');
Serial.print((int)(Vrms*100));
Example emonhub Config
In the [interfacers]
section:
[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyUSB0
com_baud = 9600
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
Debugging
- Ensure the data received on the serial port is 100% numerical characters with no rogue spaces. Non-numerical characters could result in
Thread is dead
error.
My RaspberryPi3 didn’t recognice the Mega on the dev/ttyUSB*. After some research I found that they sometimes appear on dev/ttyACM0. On this threat franknfurther seemed to have a similar experience. But this thread is also reffering to the deprecated gatewayconfig.
The emonhublog told me that the connection was succesfull with this path. Another good indicator seems to be the error message “Thread is dead” when I unplug the Arduino. Here is the testsketch running on the Arduino, based on the code I found in the example above (I also tried the version with the (int) within the serialfunction; same results):
const int nodeID = 6;
void setup() {
Serial.begin(9600);
}
void loop() {
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 107;
Serial.print(nodeID); Serial.print(’ ');
Serial.print(a); Serial.print(" “); // These for compatibilit$
Serial.print(b); Serial.print(” “);
Serial.print(c); Serial.print(” “);
Serial.print(d); Serial.print(” ");
Serial.print(e);
delay(1000);
}
This triggers nothing at all within emoncms. No emonHUB log, no inputs created. I also checked via ssh directly on the pi with the command tail -f /dev/ttyACM0 , which should print whats actually received on this path. Nothing.
The LED on the Mega shows that its actually sending. Connected to the IDE I also get the expected result when I check the Serial Monitor.
Whats wrong here? What am I missing?
Assuming emoncms would receive Data, would i need to make further changes for logging remotely?
Thanks for your help.
Regards,
kaulquappe