RAK16001 WisBlock ADC Module Quick Start Guide
Prerequisite
What Do You Need?
Before going through each and every step on using the RAK16001 WisBlock module, make sure to prepare the necessary items listed below:
Hardware
- RAK16001 ADC Module
- Your choice of WisBlock Base
- Your choice of WisBlock Core
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software
- Download and install ArduinoIDE.
- To add the RAKwireless Core boards on your Arduino board, install the RAKwireless Arduino BSP. Follow the steps in the GitHub repo.
Product Configuration
Hardware Setup
The RAK16001 is an Analog-to-Digital (ADC) module, which uses an ADS7830 from Texas Instruments that can measure 8-independent voltages or 4-independent differential voltages. The ADS7830 is an 8-bit ADC module that features a serial I2C interface and an 8-channel multiplexer with one sample-and-hold amplifier circuit.
For more information about RAK16001, refer to the Datasheet.
Assembling and Disassembling of WisBlock Modules
Assembling
The RAK16001 module can be mounted on the IO slot of the WisBlock Base board, as shown in Figure 2. Also, always secure the connection of the WisBlock module by using compatible screws.
Disassembling
The procedure in disassembling any type of WisBlock modules is the same.
- Remove the screws.
- Once the screws are removed, check the silkscreen of the module to find the correct location where force can be applied.
- Apply force to the module at the position of the connector, as shown in Figure 5, to detach the module from the baseboard.
If you will connect other modules to the remaining WisBlock Base slots, check on the WisBlock Pin Mapper tool for possible conflicts. RAK16001 uses I2C communication lines, and it can cause possible conflict, especially on some IO modules.
After all this setup, you can now connect the battery (optional) and USB cable to start programming your WisBlock Core.
Software Configuration and Example
Initial Test of the RAK16001 WisBlock Module
If you already installed the RAKwireless Arduino BSP, the WisBlock Core and example code should now be available on the Arduino IDE.
- You need to select first the WisBlock Core you have, as shown in Figure 6 to Figure 8
- Copy the following sample code into your Arduino IDE.
/**
@file ADS7830.ino
@author rakwireless.com
@brief This code is designed to config ADS7830 ADC device and handle the data
@version 1.0
@date 2021-08-23
@copyright Copyright (c) 2021
*/
#include <Wire.h>
#include "ADS7830.h" //http://librarymanager/All#ADS7830 By:RAKWireless
ADS7830 ads;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
time_t timeout = millis();
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
delay(300);
while (!Serial)
{
if ((millis() - timeout) < 5000)
{
delay(100);
}
else
{
break;
}
}
// The address can be changed making the option of connecting multiple devices
ads.getAddr_ADS7830(ADS7830_DEFAULT_ADDRESS); // 0x48, 1001 000 (ADDR = GND)
// ads.getAddr_ADS7830(ADS7830_VDD_ADDRESS); // 0x49, 1001 001 (ADDR = VDD)
// ads.getAddr_ADS7830(ADS7830_SDA_ADDRESS); // 0x4A, 1001 010 (ADDR = SDA)
// ads.getAddr_ADS7830(ADS7830_SCL_ADDRESS); // 0x4B, 1001 011 (ADDR = SCL)
// The Device operating and Power-Down mode
// can be changed via the following functions
//ads.setSDMode(SDMODE_DIFF); // Differential Inputs
ads.setSDMode(SDMODE_SINGLE); // Single-Ended Inputs
ads.setPDMode(PDIROFF_ADON); // Internal Reference OFF and A/D Converter ON
// ads.setPDMode(PDADCONV); // Power Down Between A/D Converter Conversions
// ads.setPDMode(PDIRON_ADOFF); // Internal Reference ON and A/D Converter OFF
//ads.setPDMode(PDIRON_ADON); // Internal Reference ON and A/D Converter ON
ads.begin();
}
void loop() {
// put your main code here, to run repeatedly:
byte error;
int8_t ADS7830_Address;
// ADS7830 Address
ADS7830_Address = ads.ads7830_Address;
// The i2c_scanner uses the return value of
// the Write.endTransmission to see if
// a device did acknowledge to the address.
ads.AdsBeginTransmission(ADS7830_Address);
error = ads.AdsEndTransmission();
if (error == 0)
{
float result[8] = {0};
Serial.println("Getting SingleEnded Readings");
for (uint8_t channelcount = 0; channelcount < 8; channelcount++)
{
result[channelcount] = ads.Get_SingleEnded_Data(channelcount);
Serial.printf("Analog input voltage values between Channel %d: %0.2f\r\n", channelcount, result[channelcount]);
}
Serial.println(" ");
Serial.println(" *************************** ");
Serial.println(" ");
}
else
{
Serial.println("ADS7830 Disconnected!");
Serial.println(" ");
Serial.println(" ************ ");
Serial.println(" ");
}
delay(1000);
}
If you experience any error in compiling the example sketch, check the updated code for your WisBlock Core Module that can be found on the following:
And these sample codes in Github will work on all WisBlock Core.
- Once the example code is open, install the RAK ADS7830 library by clicking the yellow highlighted link, as shown in Figure 9 and Figure 10.
- After successful installation of the library, you can now select the right serial port and upload the code, as shown in Figure 11 and Figure 12.
If you're using the RAK11200 as your WisBlock Core, the RAK11200 requires the Boot0 pin to be configured properly first before uploading. If not done properly, uploading the source code to RAK11200 will fail. Check the full details on the RAK11200 Quick Start Guide.
- When you successfully uploaded the example sketch, open the Serial Monitor of the Arduino IDE to see the modules' reading logs. If you see the logs, as shown in Figure 13, then your RAK16001 is properly communicating to the WisBlock core.