Serial Communication with another board

Hello,

I am trying to get 2 emonTH communicate together and send all data gathered from one of them through Serial to a teensy board.
Baud rate are equal between teensy and emonTH
Rx/Tx to Tx/Rx are well connected (UART)
everything is fine but some weird character appears once and stop…
Is there something specific to know about hardware on emonTH, not to permit this working?
On my mind this is something really easy to do, but maybe C++ libs use Serial for something i do not know… or something else…
Maybe somebody already encounter this knid of issues…or a specific setup ?
Thanks!

Are you trying to wire two emonTH’s in parallel to one receiving port? You cannot do that, they must go to separate serial ports.

Neither can you use one emonTH to receive the data from the other and “forward” it onwards to the Teensy - because they are asleep all the time and only wake up to make and send a reading every minute.

It should be easy to do - they do transmit serially. But I am not sure - from what you have written - that you are doing it correctly.

That is usually the wrong baud rate. The default baud rate is 115200.

Hello @Robert.Wall

No they are not in parallel
emonTH1 ---------(HF)------------emonTH2-----------(Serial @115200)-----------teensy(@115200)
emonTH2 forward emonTH1 data (HF) + its own data to transmit via serial to teensy
this is not a baudrate issue, my teensy just stop after receiving data once…
I use rf12_recvDone() boolean variable to know when data arrives from emonTH1, then get measures from emonTH2, encapsulate all those data in a string and send it through serial of emonTH2, one time in each cycle of 55,2 second ( I reduce this time for testing)
So the theory tells me that it normally works correctly…

Other things, when I used a simple arduino UNO board to simulate emonTH2 data its works perfectly so this is a software issue. I even tried to use this simulation sketch and upload to emonTH2 and it works.
I definitely think that the emonTH V2 code prevent me to do basic serial communication…

You did not say that you are using emonTH2 as a radio receiver to accept the data from emonTH1.

(It is UHF radio: in the band 300 MHz - 3 GHz. HF radio is 3 MHz - 30 MHz)

Does your Teensy stop receiving the data, or does emonTH2 stop sending it? These are not the same thing.

I still think that can never work, for the reason I began with: emonTH2 is asleep the whole minute except for a few hundred milliseconds when it wakes to read the sensors and send the data. So unless the data arrives while it is awake - and there is no guarantee that both emonTH will wake up at the same instant - it will never know the data from emonTH1 has come and gone.

If you keep it awake all the time so that it can receive messages from emonTH1, the battery will last for only days or weeks.

If you want to make your system work, you must power emonTH2 from mains electricity, and you must change the sketch so that it checks the radio continuously but powers and reads the sensor every minute. It must never sleep.

That cannot be true, I can receive data from an emonTH via a programmer and USB cable into my computer. You have changed the sketch in the emonTH so I think you do not understand how the emonTH sketch works normally. You must understand that before you change it.

[Edit]
It has just occurred to me that you have probably forgotten to power the UART when you want to send serial data. Normally, the power to the UART is turned off when the radio is in use so as to extend the battery life. As I wrote earlier, if you have the radio on continuously to receive data from emonTH no.1, then you must power emonTH no.2 by mains electricity.

Thanks for your asnwer @Robert.Wall but I know exactly what I am doing
I, of course, remove all the sleepy things of the sketch that make the emonTH sending things every minute (55,2 sec exactly, as the variables are affected with integer values in the sketch), because I really understand, before you say it, that I need to have my loop always listening to incoming data to make it works. I know that already and you do not read correctly what i am saying, i use rf12_recvDone() (means when data arrives from emonTH1 to emonTH2, I can print correctly data from emonTH1 in my emonTH2 serial output, everything is fine, in the whole cycle process).
So if you tell me that you do not understand my problem, please try not to guide me on such basic dev skills that you haven’t
My only question is “is serial implies in”
#include <JeeLib.h>
#include <RF69_avr.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <SI7021.h>

that could inhibite the serial communication with another board?

Thanks !

and @Robert.Wall I already remove power_usart0_disable() line invoked in the sketch
So the UART is always powered on

I’m sorry if you know what you are doing and I hurt your feelings, but I can only have the information that you wrote in your post. And you left a lot to guesswork.

I’ll leave you to work your way though the libraries to find your problem yourself.