Luc Paquin
Published © CC BY

Project #30 - UNIHIKER - MEMS CH4 - Mk06

Project #30 - UNIHIKER - MEMS CH4 - Mk06

BeginnerFull instructions provided1 hour77
Project #30 - UNIHIKER - MEMS CH4 - Mk06

Things used in this project

Hardware components

DFRobot UNIHIKER
×1
DFRobot Fermion: MEMS Methane CH4 Gas Detection Sensor
×1
USB Battery Pack
×1
DFRobot USB 3.1 Cable A to C
×1

Software apps and online services

Python

Story

Read more

Schematics

Fritzing

Code

DL2409Mk07p.py

Python
"""
****** Don Luc Electronics © ******
Software Version Information
Project #30 - UNIHIKER - Fermion: MEMS CH4 - Mk06
30-06
DL2409Mk07.py
DL2409Mk07
1 x UNIHIKER
1 x Fermion: MEMS Methane CH4 Gas Detection Sensor
1 x USB Battery Pack
1 x USB 3.1 Cable A to C

-*- coding: utf-8 -*-
"""
# Import the unihiker library
from unihiker import GUI

# Import the time library
import time

# Import the Board module from the pinpong.board package 
from pinpong.board import Board

# Import all modules from the pinpong.extension.unihiker package
from pinpong.extension.unihiker import *

# Initialize the board by selecting the board type and port number;
# if not specified, the program will automatically detect it
Board().begin()

# Initialize pin 21 as analog input mode
# Fermion: MEMS Methane CH4 Gas Detection Sensor
adc0 = Pin(Pin.P21, Pin.ANALOG)

# Instantiate the GUI class and create a gui object
gui = GUI()

# Display the initial background image 'DL2409Mk07p'
img = gui.draw_image(x=0, y=0, w=240, h=320, image='DL2409Mk07p.png')

# Fermion: MEMS Methane CH4 Gas Detection Sensor
# Display the initial Fermion: MEMS Methane CH4 Gas Detection Sensor valueCH4
valueCH4 = gui.draw_text(x=30, y=151, text='0', font_size=18)

while True:

    # Fermion: MEMS Methane CH4 Gas Detection Sensor
    # Read analog value
    CH4Sensor = adc0.read_analog()
    valueCH4.config(text=CH4Sensor)
    
    # Delay for 1 second to keep the screen content displayed for a longer time
    time.sleep(1)

Credits

Luc Paquin
99 projects • 5 followers
Teacher, Instructor, E-Mentor, R&D and Consulting -Programming Language -Microcontrollers -IoT -Robotics -Machine Learning -AI -Sensors

Comments