SoftwareSerial conflict?


#1

Greetings,

After a frustrating amount of debugging it seems my gc0011 library for the PFC1 BOM will not work. I’m unable to see for certain but it seems that SoftwareSerial is causing a conflict with the rest of the Rosserial implementations.

Has anyone used SoftwareSerial in an Openag_Brain sensor or actuator?

Can somebody who is a rocket scientist take a look at my code and tell me what I’m missing?

https://github.com/novemberalpha/openag_gc0011

This code has been refactored about a zillion times but is now a basic copy of the GC0012 repo with the change that it uses SoftwareSerial to connect to the originally specified pins 12 and 11 on the Mega.

The problem starts at gc0011_1.begin();
The program locks up if I uncomment
_serial_port->print("K 2\r\n"); // enable polling mode

There is demo code in the gc0011-demo-arduino-code folder. It works.

Thanks for your help!

J


#2

Ideas for narrowing down the trouble or perhaps sidestepping it:

  1. Does the problem only happen when you have your code running with other OpenAg firmware modules? Does it work okay if your module is the only one enabled by the fixture? This could indicate that another firmware module is messing with interrupts needed by SoftwareSerial–disabling them, reconfiguring them, or whatever.

  2. Are you doing this on an a Mega 2560? If so, what happens if you try using one of its additional hardware serial ports? See 4th paragraph of https://www.arduino.cc/en/reference/serial.

  3. What happens if you put a
    delay(10);
    right after
    _serial_port->print(...)
    If you are having trouble with interrupts, this might be a quick and dirty workaround. The delay is based on about 1.04 ms per byte at 9600 baud times 5 characters, plus some padding. If that does fix it, I’d suggest a comment calling out the potential for troubles with interrupt conflicts. Better yet, use hardware serial if you can.


#3

Interestingly, My students pointed out there are two sets of pins 11 and 12. They actually soldered to PWM pins 11 and 12 (hardware pins 24 and 25) instead of hardware pins 11 and 12.

I may have used the wrong ones when I soldered the daughterboard. Do you know if the PFC1 BoM Hardware should be soldered to actual pins or the digital pins? I was able to get SoftwareSerial to work using the hardware pins 11 and 12 and to read the GC0011 correctly so I’m mostly certain that I did it correctly and they didn’t. We are going to test the software on their build next week to see if the demo app can run with their configuration.

I’m going to try your tips above and will report back in the next few days. I would prefer not to change the hardware configuration of the PFC1 for it to adopt the Openag_brain software but I already had to move the DHT22 to a different grove connector so a change may be required.

Back soon!


Need help setting up the development environment?
#4

Nope. But, the way I’d go about trying to figure it out would be:

  1. Find the pins that the firmware code is trying to use

  2. Consult the Arduino docs to understand how the logical pin numbers in the code correspond to hardware pins

  3. Physically trace the connection from those pins to wherever they lead and compare that to any available PFC1 documentation

Good luck