M4 Express AirLift Lite and MySQL

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
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

M4 Express AirLift Lite and MySQL

Post by AlexJustAlex »

Hi I have a small project to build a portable device to log various voltages and store them in an existing MySQL database.

After much hunting around I settled on an Adafruit Metro M4 Express AirLift (WiFi) - Lite with an appropriate ADC.
I'm quite familiar with python, so it seemed a good oportunity to get to grips with circuitpython.
While waiting for it to arrive I started looking around for some examples of using circuitpython with MySQL and I couldn't find any!
WIll I be able to use pymysql as I do in regular python projects or is there a circuitpython alternative or I have I made a foolish purchase?

thanks in advance for any help or pointers in the right direction

cheers

Alex

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: M4 Express AirLift Lite and MySQL

Post by dastels »

MySQL (or any "real" database) is far beyond the capabilities of a SAMD51 (i.e. the "M4" in Metro M4). Since you have the AirLift Metro, you have some options:
- you can have it send readings to a MySQL service running on another machine, likely through MQTT or a RESTful web service
- you can send the readings (again via REST or MQTT) to Adafruit IO... this is much like the above except that the service is there already.
- you can add a SDcard shield/breakout and store readings in a file, and occasionally send that somewhere.

A bigger question is "What would you do with the data once it was in the DB?" Is there value in keeping it on the Metro?

Dave

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: M4 Express AirLift Lite and MySQL

Post by AlexJustAlex »

Thank you Dave.
To clarify:

the MySQL database already exists and is running on an appropriate server.
This database is part of a Meteorological Observatory and stores data from numerous instruments. (https://weybourne.uea.ac.uk/currentData.php)
The data makes its way to the database via a wide variety of solutions.

We sometimes add sensors for a brief period that will output data as an analogue voltage which I want to capture with some kind of portable device and then store on the database.
I do not need the data to be stored on the device.
I could do this with a Pi zero W, but I fancied trying something different.
The M4 Express AirLift Lite seemd like an interesting route to pursue, although perhaps I should have sone a bit more research first!
So the general idea is:
  • read a voltage
    connect to database on same lan over wifi
    insert reading in table
    disconnect
    wait a bit
    repeat
Nothing too taxing if the Metro can handle the MySQL conneciton
My question was can it?

Thanks for the pointers to MQTTand RESTful , I know absolutely nothing about either and it looks like I should!

In this instance if I can't do a simple MySQL connection, or, if not, get my head around one of those within a day, I'll probably put the Metro to one side and chalk that one up to experience, grab a Pi zero W and leave the Metro, MQTT and RESTful for some point when I have a bit more time.

your help is much appreciated

cheers
Alex

User avatar
AlexJustAlex
 
Posts: 15
Joined: Wed Sep 08, 2021 3:41 pm

Re: M4 Express AirLift Lite and MySQL

Post by AlexJustAlex »

If I can't connect directly to the MySQL server, I think it looks like I can use adafruit-circuitpython-requests to post the data to a webpage that will handle the actual insert

Alex

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: M4 Express AirLift Lite and MySQL

Post by dastels »

Ah, you should be fine then. The M4 Airlift is perfect for taking readings and sending them off to a server. The only question is accessing MySQL, but I would be very shocked if someone hasn't made MQTT or RESTful interfaces for it.

Dave

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: M4 Express AirLift Lite and MySQL

Post by dastels »

As AlexJustAlex said, you may be able to connect directly to the MySQL service. It is, afterall, just a WiFi connection.

Dave

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

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