Hi Rick- I deleted my own post before noticing your message below it. Turns out that my copy-pasting the example into a new program and adding the library wasn't the right way to go (been a year since I last used these devices). When I chose the option to "use this example in a project", it compiled OK (but I haven't yet tested the code)
Another Photon2 question- When I add Serial.begin(115200) and Serial.print("123") in the loop(), nothing prints out in an Arduino Serial Terminal (when I select the USB COM port that pops up in Device Manager when I plug the Photon2 in). At first, I didn't think of loading Particle Workbench/Terminal just to test the serial port, but when I later did, the USB serial output stream does show up in its Terminal. And Realterm serial terminal picks it up- regardless of baudrate set. It seems like Photon2 is not enumerating as a CDC COM port and the Workbench Terminal is finding it by VID/PID . So, it seems only Arduino Serial terminal has problems with it
.I wrote a few Circuit Cellar magazine articles on Particle back in the Electron/Photon days and am doing another series now on your new generation, so I'm just trying to keep things straight.
The baud rate is irrelevant on Particle devices in USB CDC mode, both in what you connect with and what you pass to Serial.begin(). In fact, you can just leave the number out of the begin statement for USB serial.
I haven't checked with the Arduino serial terminal, but it wouldn't surprise me if it filters based on VID/PID, in which case it wouldn't see Particle devices since they don't have the Arduino VID.
The other thing to watch out for is if you use the default values for SYSTEM_MODE and SYSTEM_THREAD, setup() and loop() don't run unless cloud connected (breathing cyan) so this can cause confusion when you're expecting serial output since you won't get any immediately at boot.
Thanks Rick. Yeh, with USB COM ports the baudrate is an artificial concept anyway, but in other cases, it doesn't work unless they match- The Arduino Serial terminal is one example of this- but it at least prints out garbage so you know something is happening.
I use the Arduino serial terminal for Teensys, ESP32s, AVRs- many different boards, and so far this is the first time it didn't work for me. Also, Visual Studio/Visual Micro that I use for all chips that have Arduino support- doesn't work either. But, it's not surprising as VS/VM is just a fancy wrapper around Arduino tool-chain.
Yes, I'm quite aware that "my code" doesn't get executed until a Particle MCU has connected to your cloud and the LED is breathing blue/cyan.
While I have you, a working Argon project of mine which scanned for BLE beacons won't compile for the Photon2. It uses the <BeaconScanner.h> library and fails to find
BLE_GAP_SEC_STATUS_SUCCESS and BLE_GAP_SEC_STATUS_CONFIRM_VALUE
This program was compiled to OS 4.0.1 on my Argon 6 months ago and works fine.
Rick: Pardon my ignorance on this, but I cannot make any progress trying to compile the Microphone_PDM using SDFat example
This is part of the Microphone_PDM-main.zip file that you give a link for in your post .
Specifically, I am looking in the more-examples folder at 1-sdfat.
What I hoped this would do is save the PDM microphone data to an SDCARD I have connected up.
Using the Web-IDE, I cut/paste the sdfat.cpp code into a new program.
Then I add the 3 libraries called for at the head of this program, using the Library "Include in Program" button.
This procedure duplicates the 3 existing #include ... statments, so I remove them. When I compile it, I get tons of errors like
/firmware/user/../wiring/inc/spark_wiring_logging.h:730:0: multiple definition of "WavHeaderBase::~WavHeaderBase()"
lib/Microphone_PDM/WavWriter.cpp:90:0: multiple definition of "WavHeaderBase::getDataOffset() const"
Given this problem, I remembered that it might be better to just look at the
examples provided for the Microphone_PDM library, and invoke the
"Use this example as a program" option. However, none of the "extra-examples" are included, so that doesn't work.
On another matter, at the end of this thread, you gave instructions on how I could get the beacon function working with the P2 by bypassing the laird beacon code. This worked OK for me- thanks.
@rickkas7 I am trying the Example 1 Audio over TCP on a Particle Argon and when compiling code, I get an error that hal_pin_map() is not defined. Thoughts?
lib/Microphone_PDM/src/Microphone_PDM_nRF52.cpp: In member function 'virtual int Microphone_PDM_nRF52::init()':
lib/Microphone_PDM/src/Microphone_PDM_nRF52.cpp:18:25: error: 'hal_pin_map' was not declared in this scope
18 | Hal_Pin_Info *pinMap = hal_pin_map();
Most likely the right version is not getting picked up. If you are using Workbench and cloud compile, make sure the version number in project.properties is correct as that is used instead of the version in lib.
Otherwise, if you target 5.x it should build correctly, as the problem is specifically in 4.x and earlier versions. However I tested 4.1.0, 3.3.0, and 2.1.0 on the Argon and example 1 did build for me.