The RAKwireless RAK11200 WisBlock WiFi Core Module and RAK2305 WiFi Espressif ESP32 Wireless Module are based on an Expressif ESP32 processor which is supported by the .NET nanoFramework.
The RAKWisBlock system has a broad selection sensors and I wanted to see how hard it was to get a representative sample of them working.
Be careful with the RAK11200 and RAK2305 40 pin connectors they will be damaged if not handled carefully (The WisBlock modules should also be screwed to the mainboard).
The SHT3C Temperature and Humidity SensorThe SHT3C sensor module is one of the cheapest (USD4.60 Feb 2023) modules and has.NET nanoFramework IoT.Device support so it looked like a good place to start.
The example code works with both RAK11200 Core and RAK2305 Wireless modules.
public class Program
{
public static void Main()
{
Debug.WriteLine("devMobile.IoT.RAK.Wisblock.RAK11200RAK1901 starting");
try
{
// RAK11200 & RAK2305
Configuration.SetPinFunction(Gpio.IO04, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO05, DeviceFunction.I2C1_CLOCK);
I2cConnectionSettings settings = new(1, Shtc3.DefaultI2cAddress);
using (I2cDevice device = I2cDevice.Create(settings))
using (Shtc3 shtc3 = new(device))
{
while (true)
{
if (shtc3.TryGetTemperatureAndHumidity(out var temperature, out var relativeHumidity))
{
Debug.WriteLine($"Temperature {temperature.DegreesCelsius:F1}°C Humidity {relativeHumidity.Value:F0}%");
}
Thread.Sleep(10000);
}
}
}
catch (Exception ex)
{
Debug.WriteLine($"SHTC3 initialisation or read failed {ex.Message}");
Thread.Sleep(Timeout.Infinite);
}
}
}
There can be versioning issues with the NuGet packages (esp. Units.Net ones) so some "tinkering" might be required.
I used TinyGPSPlusNF library to process the NMEA0183 messages produced by the u-blox7 GNSS module on the RAK1910 GNSS GPS Location Module.
The RAK WisBlock Pin Mapper tool output for RAK1910,RAK5005-O WisBlock Base Board and RAK11200.
To save power GPIO27 was used to turn the RAK1910 module on/off.
After reviewing the RAK2305 and RAK5005 schematics and some experimentation and I found that serial port TX/RX lines also had to be reversed because both devices would normally be connected to a WisBlock core module.
The demo application is based on the TinyGPSPlusNF library by MBoude which parses the NMEA 0183 sentences produced by the RAK1910.
public class Program
{
private static TinyGPSPlus _gps;
public static void Main()
{
Debug.WriteLine($"devMobile.IoT.RAK.Wisblock.RAK1910 starting TinyGPS {TinyGPSPlus.LibraryVersion}");
try
{
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.COM2_TX);
Configuration.SetPinFunction(Gpio.IO19, DeviceFunction.COM2_RX);
_gps = new TinyGPSPlus();
// UART1 with default Max7Q baudrate
SerialPort serialPort = new SerialPort("COM2", 9600);
serialPort.DataReceived += SerialDevice_DataReceived;
serialPort.Open();
serialPort.WatchChar = '\n';
// Enable the GPS module GPS 3V3_S/RESET_GPS - IO2 - GPIO27
GpioController gpioController = new GpioController();
GpioPin Gps3V3 = gpioController.OpenPin(Gpio.IO27, PinMode.Output);
Gps3V3.Write(PinValue.High);
Debug.WriteLine("Waiting...");
Thread.Sleep(Timeout.Infinite);
}
catch (Exception ex)
{
Debug.WriteLine($"UBlox MAX7Q initialisation failed {ex.Message}");
Thread.Sleep(Timeout.Infinite);
}
}
private static void SerialDevice_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// we only care if got EoL character
if (e.EventType != SerialData.WatchChar)
{
return;
}
SerialPort serialDevice = (SerialPort)sender;
string sentence = serialDevice.ReadExisting();
if (_gps.Encode(sentence))
{
if (_gps.Date.IsValid)
{
Debug.Write($"{_gps.Date.Year}-{_gps.Date.Month:D2}-{_gps.Date.Day:D2} ");
}
if (_gps.Time.IsValid)
{
Debug.Write($"{_gps.Time.Hour:D2}:{_gps.Time.Minute:D2}:{_gps.Time.Second:D2}.{_gps.Time.Centisecond:D2} ");
}
if (_gps.Location.IsValid)
{
Debug.Write($"Lat:{_gps.Location.Latitude.Degrees:F5}° Lon:{_gps.Location.Longitude.Degrees:F5}° ");
}
if (_gps.Altitude.IsValid)
{
Debug.Write($"Alt:{_gps.Altitude.Meters:F1}M ");
}
if (_gps.Location.IsValid)
{
Debug.Write($"Hdop:{_gps.Hdop.Value:F2}");
}
if (_gps.Date.IsValid || _gps.Time.IsValid || _gps.Location.IsValid || _gps.Altitude.IsValid)
{
Debug.WriteLine("");
}
}
}
}
There can be versioning issues with the NuGet packages (esp. Units.Net ones) so some "tinkering" might be required.
123456
Playing nice with othersThe RAK11200 WisBlock WiFi Module has two I2C ports and on the RAK5005 WisBlock Base Board the Wisblock Sensor, and RAK1920 WisBlock Sensor Adapter Module Grove Socket are connected to I2C1.
123456
123456
public class Program
{
public static void Main()
{
Debug.WriteLine("devMobile.IoT.RAK.Wisblock.RAK1920SHT31 starting");
try
{
Configuration.SetPinFunction(Gpio.IO04, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO05, DeviceFunction.I2C1_CLOCK);
I2cConnectionSettings settings = new(1, (byte)I2cAddress.AddrLow);
using (I2cDevice device = I2cDevice.Create(settings))
using (Sht3x sht31 = new(device))
{
while (true)
{
var temperature = sht31.Temperature;
var relativeHumidity = sht31.Humidity;
Debug.WriteLine($"Temperature {temperature.DegreesCelsius:F1}°C Humidity {relativeHumidity.Value:F0}%");
Thread.Sleep(10000);
}
}
}
catch (Exception ex)
{
Debug.WriteLine($"SHT31 initialisation or read failed {ex.Message}");
Thread.Sleep(Timeout.Infinite);
}
}
}
There can be versioning issues with the NuGet packages (esp. Units.Net ones) so some "tinkering" might be required.
The .NET nanoFramework libraries worked well as expected. I ended up taking a bit longer to get the GPS working because I had to refer to the schematics to figure out how it was connected.
Comments