RAK16001 WisBlock ADC Module Quick Start Guide
Prerequisite
- Assemble the RAK16001 with a WisBlock Base and WisBlock Core by following the RAK16001 Installation Guide.
- Download and install the Arduino IDE, then add the RAKwireless Core boards by installing the RAKwireless Arduino BSP.
- USB Cable
- Li-Ion/LiPo battery (optional)
- Solar charger (optional)
Software Configuration and Example
NOTE
- This guide uses the RAK4631 WisBlock Core to demonstrate the configuration and upload process. The example is also compatible with other WisBlock Cores, including the RAK11200 and RAK11310.
- When using the RAK11200 WisBlock WiFi Module, configure the BOOT0 pin properly before uploading the firmware. Incorrect BOOT0 configuration may cause the firmware upload to fail. For more information, refer to the RAK11200 Quick Start Guide.
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.
Figure 1: Selecting RAK4631 as WisBlock Core- Copy the following sample code into your Arduino IDE.
Click to view the code
/**
@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);
}
NOTE
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.
Figure 1: Accessing the library used for RAK16001 Module
Figure 1: Installing the compatible library for RAK16001 Module- After successful installation of the library, you can now select the right serial port and upload the code.
Figure 1: Selecting the correct Serial Port
Figure 1: Uploading the RAK16001 example code- 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, then your RAK16001 is properly communicating to the WisBlock core.
Figure 1: RAK16001 ADC Module data logs