Starting again from scratch.
It turns out that after the last python guide I was doing things wrong and python must now be run in virtual environments now (I didn't know this). I messed up the OS on the card and had to start again with a new clean os.
The first step is to write the OS to a fresh clean card with Belana etcher ( you can see the official guide for this). Put the card in the CoreMP135, switch on and wait for it to finish booting.
Once finished booting you will be presented with the following ROOT login.
To Log in you use the root (lowercase) as the default user name and password.
You will then bee logged in as the root user (not a good thing!)
The first thing to do on boot is to resize the drive image to take up all off the SDCard. On the RPI you had to do it manually first but it's now done automatically. On the CoreMP135 we still need to do this manually and so we need to navigate to the folder /user/local/m5stack/ and run
./resize_mmc.sh.
Once the process is complete you will need to reset the CoreMP135 with the command:
sudo reboot
If for some reason it fails, hold the button next to the USB connector to power down the CoreMP135, wait a few seconds and then press the button to power it back up.
After this we need to update the OS using:
sudo apt update
followed by:
sudo apt upgrade
These two command make sure the latest software versions are installed. If for some reason you get "Failed to fetch..." or "Failed to download..." error messages, make sure the network cable is connected and secure.
Once complete we need to add a new user with the command:
adduser username
Where username is replaced with your user name.
then we need to give the user root access privileges with:
usermod -aG sudo username
Where username is replaced with your user name you set in the previous step.
Next we need to add access to the i2C group or permission issues will stop things. again this is done with the usermod command:
usermod -aG sudo username
Reboot the CoreMP135 to save the changes.
Configuring Python.Now that we have permissions set it time to configure Python change to the newly created user account with:
sudo su username
Where username is replaced with your user name you set in the previous step.
and then move to the /home/username folder.
Now we need to install the Python virtual environments that seam to be a requirement nowadays for Python dev. To install them run the command:
sudo apt install -y python3-venv
Once the packages have installed run the following to create the virtual environment:
python3.9 -m venv env
this will create a new folder and download even more packages into the folder.
once finished you should see the following:
Now we need to activate the virtual environment by running the following command:
source env/bin/activate
You will see the prompt has changed to show that you are now running in a virtual environment.
Now we have Python set up and running the way its needed, we need to download the code needed to run the BME688 which is available from Pimoroni.
To download the code which is located in the Github repo found at https://github.com/pimoroni/bme680-python?tab=readme-ov-file type in the following:
git clone https://github.com/pimoroni/bme680-python
Move into the newly downloaded folder with:
cd bme680-python
and run:
./install.sh
If everything worked out then you should be able to move into the examples folder and run them with:
python3 read-all
Im using the read-all example here and so this is what is returned from the example.
Due to Issues with code and researching functions, this part has taken a lot longer than the other parts. If you find this useful then there is more crossover guides coming. You can drop a Message in Hackster.io message box below of find me via the following links:
https://twitter.com/Cpt_J_Purcell
https://bsky.app/profile/jamespurcell.bsky.social
On Discord (if I ever work out how to share the profile!)https://mastodonapp.uk/@AdamBryant
And on the M5Stack Facebook group and community forum.
If you have some spare change you can now buy me a tea @ https://bmc.link/ajb2k35
Comments