I am trying to get my own version of Luc Small's weather station decoder working on a Chinese Arduino Micro Pro (5V). I have it working fine on a Uno R3. I have adapted the code to the Micro Pro, changing the ports, and have it working sort of. It works in picking up my weather station transmissions and decoding them, the problem I have is printing to the serial monitor, where it prints the first 63 characters each transmission and then cuts off mid word.
{"petes_weather_station_status":"started"}
{"Sensor_ID":"A4E", "humidity":82, "temperature":10.9, "wind_sp
a normal transmission would look something like this:
{"Sensor_ID":"A4E", "humidity":83, "temperature":11.0, "wind_speed":0.0, "wind_speed_max":0.0, "wind_dir":0.0, "rain_sum":506.4, "validity":1, "full_message":"A4 E1 FE 53 0 0 6 98 0 C8 "}↵
It keeps receiving packages, and just keeps printing the first 63 characters of each serial transmission.
My full code is here: Dropbox - File Deleted
I have tried a whole heap of troubleshooting, and believe I have narrowed the problem down to some sort of conflict between the timer and the serial output. The code below is a simple test of this where the timer is set up and I try to print text to the serial monitor. The "Serial Started" text comes through, but then the pro micro freezes up and all the onboard leds turn on solid.
If I comment out the TIMSK1 |= (1 << OCIE1A);
line, the code works fine, and the text comes through on the serial monitor as expected.
Can anyone shed light on why this wouldn't work?
#define COUNTER_RATE 1600
void setup() {
Serial.begin(9600);
while (!Serial) ; // while the serial stream is not open, do nothing:
Serial.println("Serial started");
noInterrupts(); // disable all interrupts
TCCR1A = 0;
TCCR1B = 0;
TCCR1C = 0;
TCNT1 = 0;
OCR1A = COUNTER_RATE; // compare match register
TCCR1B |= (1 << WGM12); // CTC mode
TCCR1B |= (1 << CS10); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt0
interrupts(); // enable interrupts
}
void loop() {
Serial.print("I just want to print all this text out to the serial monitor");
delay(10000);
}