Python interface for Metro Mini V2 USB

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pm_circuit
 
Posts: 2
Joined: Wed Mar 15, 2023 8:13 am

Python interface for Metro Mini V2 USB

Post by pm_circuit »

I am new to the product and I would like to access ADC measurements upon request via the USB interface on the Metro Mini V2 board. I was imagining that the way to do this would be to find a DLL (windows) that would have some C functions to do this. I was then going to call the c functions using C-types in python.

Is this a reasonable solution, or are there better ideas for doing this? If so, where could I find such a DLL?

Thanks

Order: 3028801-3112350439

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Python interface for Metro Mini V2 USB

Post by mikeysklar »

Your approach to access the ADCs via Windows would be quite unorthodox.

Normally you would open up a serial connection via the USB interface and access the ADC values by printing them to the serial console from the Arduino code running on the chip.

User avatar
pm_circuit
 
Posts: 2
Joined: Wed Mar 15, 2023 8:13 am

Re: Python interface for Metro Mini V2 USB

Post by pm_circuit »

Thank you very much for your reply!

I figured that my first stab at the solution would be a little off the wall, but threw it out there anyway. Are there any examples on opening a serial connection via the USB interface for Metro Mini V2? Could examples for an Arduino UNI be equally applicable?

Thanks

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Python interface for Metro Mini V2 USB

Post by mikeysklar »

Pretty much all example code sends data and status information over serial. This one will probably interest you the most from the Arduino IDE.

File --> Examples --> Basics --> Read Analog Voltage

Code: Select all

/*
  ReadAnalogVoltage

  Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/ReadAnalogVoltage
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”