Skip to content

Cannot get an intance of AdcChannel on M5Core2  #1037

@timothyparez

Description

@timothyparez

Library/API/IoT binding

nanoFramework.M5Stack

Visual Studio version

No response

.NET nanoFramework extension version

No response

Target name(s)

M5Core2

Firmware version

No response

Device capabilities

ESP32 (ESP32-D0WDQ6-V3 (revision 3))
Features WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Flash size 16MB unknown from ST (manufacturer 0x32 device 0x16408)
PSRAM: undetermined
Crystal 40MHz
MAC 30:C6:F7:25:DE:28

Description

Following the samples in readme.md from https://github.com/nanoframework/nanoFramework.M5Stack
I am trying to read the value of an ADC pin.

As soon as I try to get an instance of AdcChannel an exception is thrown:

System.ArgumentException: gpioNumber

How to reproduce

  1. Create a project with the following code
using System;
using System.Diagnostics;
using System.Threading;
using nanoFramework.M5Core2;
using nanoFramework.M5Stack;
using nanoFramework.M5Stack;
using nanoFramework.Presentation.Media;
using Console = nanoFramework.M5Stack.Console;
using System.Device.Adc;

namespace Example
{
    public class Program
    {
        public static void Main()
        {                        
            M5Core2.InitializeScreen();
            AdcChannel adc = M5Core2.GetAdcGpio(36);

            //The code below is never executed
            //If you remove the line above and set value explicitly it works

            while(true)
            {
                Console.CursorTop = 1;
                Console.CursorLeft = 0;                                
                var value = adc.ReadValue();
                Console.WriteLine(value.ToString());
                Console.WriteLine("-----------------");
                Thread.Sleep(500);
            }
        }
    }
}

Expected behaviour

Expected to be able to read the ADC value

Screenshots

No response

Sample project or code

https://github.com/timothyparez/nanoframeworkadcissue

Aditional information

  • Ubuntu 22.04
  • VSCode
  • .NET 6
  • Mono 6.12.0.147

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions