RAK 19003 Base board

Hi Alan,

It works for me, but one of my team members has problems with the buzzer as well.
We have to wait for our R&D team to look into it, but that will take some time because of the holidays.

Was trying it again, this time with some code that uses both the RAK18001 Buzzer and the RAK12500 GNSS module. It works fine for me.
Can you give it a try, I will ask my team to test the same code as well.
It initializes the GNSS module and the buzzer.
In the main loop it tries to find a location. If a location was found it plays a short tune, if not, it plays a longer tune with a different frequency.

#include <Arduino.h>
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> // http://librarymanager/All#SparkFun_u-blox_GNSS

#define BUZZER_CONTROL WB_IO5

// The GNSS object
SFE_UBLOX_GNSS my_gnss;

time_t time_out;
bool has_pos = false;
time_t check_limit = 30000;

void setup()
{

	pinMode(LED_GREEN, OUTPUT);
	pinMode(LED_BLUE, OUTPUT);
	pinMode(WB_IO2, OUTPUT);
	digitalWrite(LED_GREEN, LOW);
	digitalWrite(LED_BLUE, LOW);

	// Initialize Serial for debug output
	Serial.begin(115200);

	time_t serial_timeout = millis();
	// On nRF52840 the USB serial is not available immediately
	while (!Serial)
	{
		if ((millis() - serial_timeout) < 5000)
		{
			delay(100);
			digitalWrite(LED_GREEN, !digitalRead(LED_GREEN));
		}
		else
		{
			break;
		}
	}
	digitalWrite(LED_GREEN, LOW);
	digitalWrite(LED_BLUE, LOW);

	// Power on the GNSS module
	digitalWrite(WB_IO2, HIGH);

	// Start the I2C bus
	Wire.begin();
	Wire.setClock(400000);

	if (!my_gnss.begin())
	{
		digitalWrite(LED_GREEN, LOW);
		digitalWrite(LED_BLUE, HIGH);
		Serial.println("UBLOX did not answer on I2C");
		while (1)
		{
			digitalWrite(LED_GREEN, !digitalRead(LED_GREEN));
			digitalWrite(LED_BLUE, !digitalRead(LED_BLUE));
			delay(250);
		}
	}
	else
	{
		Serial.println("UBLOX found on I2C");
		my_gnss.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
	}

	my_gnss.saveConfiguration(); //Save the current settings to flash and BBR

	my_gnss.setMeasurementRate(500);

	// Initialize Buzzer
	pinMode(BUZZER_CONTROL, OUTPUT);

	// Test Tone
	Serial.println("Good Tone playing");
	{
		for (int idx = 0; idx < 3; idx++)
		{
			tone(BUZZER_CONTROL, 698); //play the note "F6" (FA5)
			delay(100);
			// tone(BUZZER_CONTROL, 880); //play the note "A5" (LA5)
			// delay(100);
			noTone(BUZZER_CONTROL);
		}
	}
	delay(2000);
	Serial.println("Bad Tone playing");
	{
		for (int idx = 0; idx < 5; idx++)
		{
			// tone(BUZZER_CONTROL, 698); //play the note "F6" (FA5)
			// delay(100);
			tone(BUZZER_CONTROL, 880); //play the note "A5" (LA5)
			delay(100);
			noTone(BUZZER_CONTROL);
		}
	}
	delay(2000);
	digitalWrite(BUZZER_CONTROL, LOW);
}

void loop()
{
	Serial.println("Try to get location");
	time_out = millis();
	has_pos = false;
	digitalWrite(LED_BLUE, HIGH);
	while ((millis() - time_out) < check_limit)
	{
		byte fix_type = my_gnss.getFixType(); // Get the fix type

		if (fix_type >= 3) /** Fix type 3D */
		{
			has_pos = true;
			break;
		}
	}
	digitalWrite(LED_BLUE, LOW);

	if (has_pos)
	{
		digitalWrite(LED_GREEN, HIGH);
		Serial.println("Got location");
		for (int idx = 0; idx < 3; idx++)
		{
			tone(BUZZER_CONTROL, 698); //play the note "F6" (FA5)
			delay(100);
			// tone(BUZZER_CONTROL, 880); //play the note "A5" (LA5)
			// delay(100);
			noTone(BUZZER_CONTROL);
		}
	}
	else
	{
		digitalWrite(LED_GREEN, LOW);
		Serial.println("No location");
		for (int idx = 0; idx < 10; idx++)
		{
			// tone(BUZZER_CONTROL, 698); //play the note "F6" (FA5)
			// delay(100);
			tone(BUZZER_CONTROL, 880); //play the note "A5" (LA5)
			delay(100);
			noTone(BUZZER_CONTROL);
		}
	}
	digitalWrite(BUZZER_CONTROL, LOW);
	digitalWrite(BUZZER_CONTROL, LOW);
	delay(30000);
}

Hi Bernt,
Thanks for this.
I built a new project to include just this.
It failed in a similar way to my test case.
I got one line output and then it crashed:

Good Tone playing
Exception in thread rx:

I am using Windows 11 - I don’t know if that might be a factor?

Alan

You are using PlatformIO, not Arduino IDE, correct?

Hi, Yes, I am using Platform IO. I had thought about trying the Arduino IDE, but decided against it.

Alan

OK, I am using always PlatformIO.

I am wondering about this error:

Exception in thread rx:

That is weird error message and I didn’t see something like this before.

You have flashed my unchanged code?

We are trying to get the error on our side, but my colleague who has the same hardware has no problems. The other one, which said he has a problem with the buzzer, didn’t answer yet. And with the 24th being tomorrow, I don’t think I have any news for you before next week.

This is my platformio.ini:

[env:wiscore_rak4631]
platform = nordicnrf52
board = wiscore_rak4631
framework = arduino
build_flags = 
	-DMY_DEBUG=1
lib_deps = 
		sparkfun/SparkFun u-blox GNSS Arduino Library 

Sorry. I should have been more explicit. The ‘Exception’ line is the first line of the error report from the serial monitor in PIO after the connection was dropped.

My platform.ini file is:

[env:wiscore_rak4631]
platform = nordicnrf52
board = wiscore_rak4631
framework = arduino
lib_deps = sparkfun/SparkFun u-blox GNSS Arduino Library@^2.1.4

Alan

We have right now the following situation:

Your RAK19003 + RAK18001 => Does not work
A colleagues RAK19003 + RAK18001 => Does not work
Another colleagues RAK19003 + RAK18001 => Does work
My RAK19003 + RAK18001 => Does work

I am asking our R&D guys to look into it, but I do not expect an answer before January because of Christmas/New Year.

Hi Bernd,
Thanks for this.
I am under no time pressure to get this working so the New Year is fine.
Have a good holiday.

Thanks
Alan

Hi Alan,

Already got an answer from the R&D team in China. They tested and found a problem.

USB 2.0 has limited current (0.5A). Difference between RAK5005-O and RAK19003 is in the power regulation. We made some changes, that shows now problems on USB 2.0

What I do not understand yet is, if you use tone() we see the problem. But when we use HW PWM directly it works.

Here is how they use the HW PWM directly:

#define PWM_FOSC  16000000    //PWM的时钟频率为16MHz

pinMode(WB_IO5,OUTPUT);
HwPWM0.addPin(WB_IO5);

unsigned long freq = 4000; // 4000Hz

unsigned long pwm_period = PWM_FOSC/freq-1;
unsigned long duty = PWM_FOSC/freq/2;

HwPWM0.setMaxValue(pwm_period);   // set max value = 16000000/pwm_frequency - 1
  
HwPWM0.writePin(WB_IO5,duty,false);

I still need to try that code by myself. I got these from the R&D guys.

Hi Bernd,
That was quick.
I haven’t tried this code yet, but I did try plugging directly into a USB 3 port with the cable provided with the board (I was using an old USB 2 hub).
Unfortunately it made no difference.

Alan

Hmmmm,

Can you try to plug in a rechargeable LiPo battery as well.

OK. The battery is the critical link.
If I reflash with the battery connected it works fine.
If I disconnect the battery while the USB is still connected, it soon crashes and repeatedly resets.
If I reconnect the battery it recovers again.

Alan.

Thanks for trying. I will give this feedback to our R&D. I am afraid we have to do some redesign.

I believe there is also some correlation with the state of the GPS.
I updated another device without a battery (by mistake) and it continued working for several iterations until it got a GPS fix.

Alan

Hi,
Is there a straightforward way I can discriminate between the 5005 and the 19003 in my code - so I can select the correct pin number for the buzzer?
Thanks
Alan

No, sorry, that is not possible.