RAK 4630 and RAK5811 combination

Hey all,

I’m trying out the RAK4360 with the RAK5811 interface mounted on a WisBlock.

I have been plugging it into my laptop, a 2013 macbook pro. Today I had some very strange behaviour from the setup. I wonder if anyone could suggest what is going on?

  • It runs very warm. It is quite warm to touch.
  • My computer shut down, as if the device was using too much current or caused an overvoltage at the USB port.
  • The 5811 will turn off and I don’t see why (with nothing in the code to pull the pin low). I can see that it is turned off in the sense that 0.08V is present where it should be outputting 3.3V.
    -The 5811 will sometimes emit a wandering low voltage of about 163mV where it should emit 3.3V. Unplugging the unit and plugging it in again seems to reset this. It is sometimes, but not always, triggered by flashing the device.

I’ve had a few errors that the 4630 is unavailable to flash as well. Unplugging it and plugging it in seems to reset it.

I used the example code to sense a voltage from the 5811 (RAK58110-5V.ino in the Arduino IDE) and modified the code. I’ll put it below.

Also, I saw that the internal MCU, the nRF52840 has a 12 bit ADC and we can add a line to start using 12 bit instead of the default 10 bit, so I tried that. It’s stable when I apply 3.3V from the 5811 into A1. But when I try to measure temperature with a 10K thermistor I know works well, in a voltage divider, I get a lot of wander and drift. Here in the chart you can see when I pinch the (ntc) thermistor with my finger. The signal does drop in a logarithmic shape each time (4 times). But there are some strange things happening too - there is a drop, and a lot of drift up and down. Is this just noise from a low quality ADC, or is something deeper going on?

Sorry that’s a lot of stuff all at once! But I wonder is there is some single source like a problem with the power supply? I don’t want to give up on LoRaWan or Wisboard but I can’t use the system like this.

/**
 * This was:
 * @file RAK5811_0-5V.ino
 * @author rakwireless.com
 * @brief 0 to 5V analog input example.
 * @version 0.1
 * @date 2020-07-28
 * @copyright Copyright (c) 2020
 * 
 * It was edited by James Douglas, 2022-03-25. Then used for temperature sensing.
 */
 
#include <Arduino.h>
#include <Adafruit_TinyUSB.h>

#define NUMSAMPLES 32

//thermistor stuff
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 5
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 3950
// the value of the 'other' resistor
#define SERIESRESISTOR 10000

void setup()
{

  Serial.begin(115200);

  /* WisBLOCK 5811 Power On*/
  pinMode(WB_IO1, OUTPUT);
  digitalWrite(WB_IO1, HIGH);

  pinMode(WB_A1, INPUT_PULLDOWN);
  analogReference(AR_INTERNAL_3_0);
  analogOversampling(128);

  analogReadResolution(12); //default is a 10 bit adc. But actually the nRF52840 has a 12 bit adc. 
}

void loop()
{

  getADC();

  Serial.println(calcTemp(getADC()));

  delay(2000);
}

float calcTemp(int adc){
    // convert the value to resistance
    float resistance;
    resistance = SERIESRESISTOR * (4095.0 / adc - 1.0);//4095 is the number of levels on the adc

    float steinhart;
    steinhart = resistance / THERMISTORNOMINAL; // (R/Ro)
    steinhart = log(steinhart); // ln(R/Ro)
    steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
    steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
    steinhart = 1.0 / steinhart; // Invert
    steinhart -= 273.15; // convert to C
    
//    Particle.publish("Temperature: ", String(steinhart)); //This is just for troubleshooting.
    return steinhart;
}

int getADC(){
  int ADCReadingsAcc = 0;       //Use this to add all the ADC readings together.
  int averageADCReadings;       //Use this to average of all the adc readings
  float ADCVoltage;             //Use this to store the voltage reaching MCU.
  float originalVoltage;        //Use this to store the voltage reaching the 5811. 
  //The 5811 is just an op amp. It takes in up to 5V and outputs only up to 3.0V. It's just meant to take in 5V and make that readable with the ADC on the RAK.
  //Plus it gives you a little spring terminal block to attach stuff to.

  for (int i = 0; i < NUMSAMPLES; i++)
  {
    ADCReadingsAcc += analogRead(WB_A1); //take a reading from the adc and accumulate them all.
  }
  
  averageADCReadings = ADCReadingsAcc / NUMSAMPLES;

  ADCVoltage = averageADCReadings * 3.0 / 1024;   //max 3V, 10bit ADC

  originalVoltage = ADCVoltage / 0.6; //The 5811 just cuts the 5V max signal down to max 3.0V so the ADC can handle it. Here we calculate backwards to get the original voltage.

  //Serial.println(averageADCReadings);

  return averageADCReadings;

}
/*
float measuretemp()
{
    float average;

    // take N samples in a row, with a slight delay
    for (i=0; i< NUMSAMPLES; i++)
    {
        samples[i] = analogRead(THERMISTORPIN);
        delay(10);
    }

    // average all the samples out
    average = 0;
    for (i=0; i< NUMSAMPLES; i++)
    {
        average += samples[i];
    }

    average /= NUMSAMPLES;

    // convert the value to resistance
    float resistance;
    resistance = SERIESRESISTOR * (4095.0 / average - 1.0);//4095 is the number of levels on the adc

    float steinhart;
    steinhart = resistance / THERMISTORNOMINAL; // (R/Ro)
    steinhart = log(steinhart); // ln(R/Ro)
    steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
    steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
    steinhart = 1.0 / steinhart; // Invert
    steinhart -= 273.15; // convert to C
    
//    Particle.publish("Temperature: ", String(steinhart)); //This is just for troubleshooting.
    return steinhart;
}
*/

Welcome to the forum @thePhytochemist

Congratulations, you found a bug in our libraries.

RAK5811 uses 3V3_S as supply. 3V3_S is switched on/off with WB_IO2.
WB_IO1 is used to switch on/off the 12V output on the connector.

Change

  /* WisBLOCK 5811 Power On*/
  pinMode(WB_IO1, OUTPUT);
  digitalWrite(WB_IO1, HIGH);

to

  /* WisBLOCK 5811 Power On*/
  pinMode(WB_IO2, OUTPUT);
  digitalWrite(WB_IO2, HIGH);

or, if you need the 12V on the connector

  /* WisBLOCK 5811 12V output On*/
  pinMode(WB_IO1, OUTPUT);
  digitalWrite(WB_IO1, HIGH);
  /* WisBLOCK 5811 Power On*/
  pinMode(WB_IO2, OUTPUT);
  digitalWrite(WB_IO2, HIGH);

Wow, thank you. Ok I will try it!

Hm, no luck. Changing the IO pin doesn’t help the situation. When I use the example code, sometime it is unable to flash, sometimes it flashes and I can take readings. Sometimes it flashes and reports an ADC reading of only 1 or 2. So there is a lot of erratic behaviour and the system isn’t really useable.

Not sure what the issue is with your RAK5811, I have it and it works fine with the example code.

For the problems with the flashing, make sure you have the latest bootloader installed. Updating the Bootloader

Just an update:

I uploaded the newest bootloader, 0.4.2 over 0.4.1 using adafruit-nruftil. I entered
dfu mode by double-pressing the reset button so the device appears as a drive on a mac. That did indeed help. Last week I was able to gather some very low-noise 12 bit ADC readings over serial.

The 12V supply does not turn on, but I don’t need it. Maybe my macbook pro cannot supply enough power over the usb port to turn it on?

Whether WB_IO2 or WB_IO1 are set high or not, the RAK4630 becomes quite warm, almost too hot to touch. This is only recording data from the ADC and sending it over serial.

Can you show me your connections to the RAK5811?
The RAK4631 should not get warm at all, it has nothing to do with the power supply, that is located on the Base Board.
Do you have anything connected to VBAT, 3V3 or 12V on the RAK5811? These are outputs only.