VOOZH about

URL: https://www.nuget.org/packages/nanoFramework.Iot.Device.Mcp7940xx/

⇱ NuGet Gallery | nanoFramework.Iot.Device.Mcp7940xx 1.0.889




👁 Image
nanoFramework.Iot.Device.Mcp7940xx 1.0.889

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Mcp7940xx --version 1.0.889
 
 
NuGet\Install-Package nanoFramework.Iot.Device.Mcp7940xx -Version 1.0.889
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Mcp7940xx" Version="1.0.889" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Mcp7940xx" Version="1.0.889" />
 
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Mcp7940xx" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Mcp7940xx --version 1.0.889
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: nanoFramework.Iot.Device.Mcp7940xx, 1.0.889"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Mcp7940xx@1.0.889
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Mcp7940xx&version=1.0.889
 
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Mcp7940xx&version=1.0.889
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Mcp7940xx/MCP79400/MCP79401/MCP79402 - I2C Real-Time Clock/Calendar with SRAM

The MCP7940M Real-Time Clock/Calendar (RTCC) tracks time using internal counters for hours, minutes, seconds, days, months, years, and day of week. Alarms can be configured on all counters up to and including months.

Documentation

Datasheet

Original code was written for ESP32

Usage

Important: Make sure you properly setup the I2C pins for ESP32 before creating the I2cDevice. For this, make sure you install the nanoFramework.Hardware.Esp32 NuGet and use the Configuration class to configure the pins:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs used for the bus.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);

For other devices like STM32, please make sure you're using the preset pins for the I2C bus you want to use.

The following example demonstrates using the clock and alarm functions of the Mcp7940xx family.

using System;
using System.Device.I2c;
using System.Diagnostics;
using System.Threading;
using Iot.Device.Mcp7940xx;
using nanoFramework.Hardware.Esp32;

// Setup ESP32 I2C port.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);

// Setup Mcp7940m device. 
I2cConnectionSettings i2cSettings = new I2cConnectionSettings(1, Mcp7940m.DefaultI2cAddress);
I2cDevice i2cDevice = new I2cDevice(i2cSettings);

Mcp7940m clock = new Mcp7940m(i2cDevice, ClockSource.ExternalCrystal);
clock.SetTime(DateTime.UtcNow);
clock.StartClock(true);

// Set Alarm 1 to trigger on the 4th minute of every hour.
Mcp7940m.Alarm alarm1 = new Mcp7940m.Alarm(AlarmMatchMode.Minute, minute: 4);
clock.SetAlarm1(alarm1);
clock.EnableAlarm1();
Debug.WriteLine($"Alarm 1 : {clock.GetAlarm1()}");

// Set Alarm 2 to trigger every Wednesday.
Mcp7940m.Alarm alarm2 = new Mcp7940m.Alarm(AlarmMatchMode.DayOfWeek, dayOfWeek: DayOfWeek.Wednesday);
clock.SetAlarm2(alarm2);
clock.EnableAlarm2();
Debug.WriteLine($"Alarm 2 : {clock.GetAlarm2()}");

while (true)
{
 // Get current time.
 DateTime currentTime = clock.GetTime();
 Debug.WriteLine($"Time: {currentTime.ToString("yyyy/MM/dd HH:mm:ss")}");

 // Check if alarm 1 has triggered.
 if (clock.IsTriggeredAlarm1)
 {
 Debug.WriteLine("[ALARM 1]");

 // Clear alarm 1 flag.
 clock.ResetAlarm1();
 }

 // Check if alarm 2 has triggered.
 if (clock.IsTriggeredAlarm2)
 {
 Debug.WriteLine("[ALARM 2]");

 // Clear alarm 2 flag.
 clock.ResetAlarm2();

 // Turn off alarm 2.
 clock.DisableAlarm2();
 }

 // Wait for one second.
 Thread.Sleep(1000);
}

The following example demonstrates accessing the protected EEPROM and EUI of the Mcp79401.

using System;
using System.Device.I2c;
using System.Diagnostics;
using System.Threading;
using Iot.Device.Mcp7940xx;
using nanoFramework.Hardware.Esp32;

// Setup ESP32 I2C port.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);

// Setup Mcp79401 eeprom device. 
I2cConnectionSettings i2cSettings = new I2cConnectionSettings(1, Mcp79401.Eeprom.DefaultI2cAddress);
I2cDevice i2cDevice = new I2cDevice(i2cSettings);

Mcp79401.Eeprom eeprom = new Mcp79401.Eeprom(i2cDevice);

// Read and write to EEPROM.
byte byteAddress = 0;
eeprom.WriteByte(byteAddress, 0xA6);
byte value = eeprom.ReadByte(byteAddress);

// Read EUI from EEPROM.
byte[] eui = eeprom.ReadEui();
Product Versions Compatible and additional computed target framework versions.
.NET Framework net net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-preview.85 51 6/1/2026
2.0.0-preview.80 50 5/27/2026
2.0.0-preview.73 58 5/20/2026
2.0.0-preview.69 58 5/18/2026
2.0.0-preview.62 52 5/13/2026
2.0.0-preview.58 54 5/12/2026
2.0.0-preview.49 50 5/4/2026
2.0.0-preview.45 63 4/29/2026
2.0.0-preview.37 63 4/22/2026
2.0.0-preview.32 55 4/20/2026
2.0.0-preview.16 69 3/10/2026
1.0.889 519 12/10/2025
1.0.877 291 11/10/2025
1.0.853 251 10/2/2025
1.0.810 335 4/2/2025
1.0.798 309 3/11/2025
1.0.768 268 2/26/2025
1.0.721 258 2/4/2025
1.0.718 231 2/4/2025
1.0.701 258 1/31/2025
Loading failed