Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Reply To: Reposting: Library extension "Mod"

Home Forums Mayfly Data Logger Reposting: Library extension "Mod" Reply To: Reposting: Library extension "Mod"

Sara Damiano

If you’ve downloaded the libraries from https://github.com/EnviroDIY/Libraries, then you should be able to fix it by replacing (in your sketch, not in the library) every instance of “SoftwareSerialMod” with “SoftwareSerial_PCINT12” and “Sodaq_PcInt_Mod” with “Sodaq_PcInt_PCINT0”.

Essentially, what happened is that these libraries all conflict with each other because each tries to monopolize all of the interrupt control registers within the processor chip. The processor in the Mayfly has 4 grouped interrupt registers (vectors 0-3 or A-D) which control interrupts on 8 pins each. Several years ago, Shannon made modified versions of the Software Serial and PcInt (and SDI12) libraries to force each to only work with a specific interrupt vector (instead of each trying to use all 4). At that point, she added the “mod” to each library name to note that it had been modified. As you noticed, sometime after she wrote the examples, I renamed those libraries from “mod” to “PCINT#” to specify which of the interrupt vectors each library had been modified to control.

Because the modified versions do only have control of specific interrupt vectors (instead of all of them) you have to be careful which pins you try to use with each library:
– Sodaq_PcInt_PCINT0 only works on vector A/0, so you can only assign interrupts to pins D24-D31 (aka A0-A7) using that library. If you’re only using this to assign a wake-up interrupt from the clock, which is attached at A7, that’s fine.
– SoftwareSerial_PCINT12 only works on vector B/1 & C/2, so you can only fake a serial input/output on pins D8-D23. The way the pins on the Mayfly are routed, the only pins exposed in a grove jack for SoftwareSerial_PCINT12 are D10&D11. The Mayfly does have two hardware serial ports (which are always superior to a software serial port imitation) but these are taken up by the communication with the FTDI chip (ie, the communication with the USB) and the communication with the “Bee” socket.
– SDI12_PCINT3 only works on vector D/3, so you can only use it on pins D0-D7.