Author Topic: CurrentRanger connection to iMac through serial header  (Read 176 times)


  • Newbie
  • *
  • Posts: 5
CurrentRanger connection to iMac through serial header
« on: February 09, 2019, 08:20:57 AM »
I wish to have a current consumption chart/graph measured by CurrentRanger (CR). For this purpose, I am trying to connect my iMac to CR through FTDI module but no success yet. Here is what I have done:
1. USB port of iMac is connected to FTDI module.
2. FTDI module is connected to serial header (where a bluetooth icon) of the CR.
3. Arduino IDE's serial monitor is activated and its baud rate is set to 230400.

FTDI to CR wirings:
1. FTDI Tx <-> CR Rx
2. FTDI Rx <-> CR Tx

Note: Voltage at FTDI module is set to 3.3V

Following lines in the CR firmware have been commented and uploaded to CR again:
Code: [Select]
//  if (BT_found && millis() - btInterval > BT_REFRESH_INTERVAL) //refresh rate (ms)
//  {
//    btInterval = millis();
//    readVOUT();
//    float VOUT = ((readDiff)/4096.0)*LDO_OUTPUT*1000*(OFFSET?1:OUTPUT_CALIB_FACTOR);
//#if defined BT_OUTPUT_ADC
//    Serial.println(readDiff,0);
//#elif defined BT_OUTPUT_AMPS
//    Serial.print(VOUT); Serial.print("E"); Serial.println(RANGE_NA ? -9 : RANGE_UA ? -6 : -3);
//#elif defined BT_OUTPUT_NANOS
//    Serial.println(VOUT * (RANGE_NA ? 1 : RANGE_UA ? 1000 : 1000000));
//  }

Question: Am I doing something wrong? If yes, what exactly?
Question: Are there any other easier way/tool of making current consumption charts on PC and iMac?
« Last Edit: February 12, 2019, 09:55:06 AM by Felix »


  • Newbie
  • *
  • Posts: 2
Re: CurrentRanger connection to iMac through serial header
« Reply #1 on: February 09, 2019, 02:18:59 PM »

So two possible methods to do this depending on whether you want to receive the readings via the BT header or the microUSB connector. [Note that one point in using a BT device is to "isolate" your PC from any possible damage while testing devices but if you are prepared to put that to one side ...]

Method 1: BT Header

This bit of code expects a BT trasmitter to be connected on the BT serial port header and checks for that during  setup. The code sends "AT" to the BT device and expects to get an "OK" back within one second. The code will only send readings to the BT header if the "OK" is received. So connecting the FTDI rather than a BT device to the BT header will cause this test to fail unless you are really quick at typing OK into the terminal screen!

You could change the "false" to "true" on this line to trick the detection logic into thinking a BT device is connected and force readings to be sent to the header and onto the FTDI, i.e:
Code: [Select]
byte BT_found=true;
You would need to re-instate the code that you had previously commented out. If you want to use the Arduino IDE Serial Plotter to graphically display the readings then you should change BT_OUTPUT_AMPS to BT_OUTPUT_NANOS on this line so that the format of the readings can be understood by the IDE Plotter, i.e.:
Code: [Select]

Method 2:

Rather than using the BT header to receive the readings, you could redirect the readings to the usb connector and use that to connect to the Mac instead. To do this change the code that you identified before to use the SerialUSB (this sends data to the usb connector) rather than Serial (this sends data to the BT header). So replace these lines with the following:
Code: [Select]
  if (millis() - btInterval > BT_REFRESH_INTERVAL) //refresh rate (ms)
    btInterval = millis();
    float VOUT = ((readDiff)/4096.0)*LDO_OUTPUT*1000*(OFFSET?1:OUTPUT_CALIB_FACTOR);
    SerialUSB.println(VOUT * (RANGE_NA ? 1 : RANGE_UA ? 1000 : 1000000));

I have played around with the BT connector and have modified these parts of the code before so I think the above options should work but let me know if any issues.
« Last Edit: February 09, 2019, 02:49:29 PM by peteb »


  • Newbie
  • *
  • Posts: 5
Re: CurrentRanger connection to iMac through serial header
« Reply #2 on: February 10, 2019, 01:36:44 PM »
Dear Peteb,

Thank you very much for the solutions. I haven't tried the Method 1, as I preferred the Method 2 because in this case I don't need additional FTDI "mediator" between the PC and the CR. Method 2 worked well from the first trial. I attached a screenshot from the first chart/graph (current measured in nanoAmps).

Thanks a lot again!!!

Kind regards,