开源的HaaS100扩展板 - HaaS征文

本文介绍了一款为阿里HaaS100设计的扩展板,包含24V转12V模块接口、OLED显示屏控制、音频接口等硬件,并提供了使用SPI0和I2C驱动OLED的详细代码示例,所有软硬件开源,遵循GPL3.0协议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:
这是为阿里HaaS100设计的一款扩展板,建议输入电压24V。

板载硬件资源:

  1. 24V转12V模块接口x1
  2. 12V非隔离开关x1
  3. 24V非隔离开关x1,
  4. 12V/24V可选的隔离继电器x1
  5. 兼容SPI和I2C的OLED接口x1
  6. 3.5mm音频接口x1
  7. 微动按键x3
  8. 5.5mmx2.1mm DC接口x1
  9. 自恢复保险丝x1
  10. 接线柱x2
  11. PH2.54插座x3

实物如图:
在这里插入图片描述

注:实物Rev1.2 丝印SCL(I2C)和CLK(SPI)位置错误,应该互换。(项目文件已修复此问题)

正确丝印如下:
在这里插入图片描述

注:使用SPI0接口,只需短接CLK和MOSI两处即可。使用I2C需要短接SCL和SDA并焊接I2C上拉电阻R12/R13。

完整PCB预览:
在这里插入图片描述

下图是使用SPI0点亮OLED的演示:
在这里插入图片描述
如题所示,项目软硬件全部开源,请遵循GPL 3.0协议。

代码

#!/usr/bin/env python
# -*- coding:utf-8 -*-
###
# Filename: /Users/simonliu/Documents/Haas/pythonprojects/solutions/haas100_oled/main.py
# Path: /Users/simonliu/Documents/Haas/pythonprojects/solutions/haas100_oled
# Created Date: Tuesday, October 26th 2021, 11:33:39 am
# Author: Simon Liu
# 
# Copyright (C) <2021>  <刘知海> <toopoo@gmail.com> GPLv3
 
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
 
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see <https://www.gnu.org/licenses/>.
###
# -*- coding: UTF-8 -*-
import time
from driver import SPI
from driver import GPIO
import sh1106

# OLED屏幕实例
oled = None

def oled_init():
    oled_spi = SPI()
    oled_spi.open("SPI0")

    oled_res = GPIO()
    oled_res.open("oled_res")

    oled_dc = GPIO()
    oled_dc.open("oled_dc")
    global oled
    oled = sh1106.SH1106_SPI(128, 64, oled_spi, oled_dc, oled_res)

def hello():
    global oled
    oled.fill(0)
    oled.text(' Hello HaaS100!', 2, 16, 1)
    oled.text('    Simon Liu', 2, 32, 1)
    oled.show()
    

def main():
    print("---=== OLED example ===---")
    oled_init()
    hello()
    

if __name__ == '__main__':
    main()

注意要配合board.json文件

{
  "name": "haas100",
  "version": "1.0.0",
  "io": {
    "ADC0": {
      "type": "ADC",
      "port": 0,
      "sampling": 12000000
    },
    "oled_i2c": {
      "type": "I2C",
      "port": 2,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 120
    },
    "pca9544": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 8,
      "freq": 100000,
      "mode": "master",
      "devAddr": 112
    },
    "mpu6050": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 100000,
      "mode": "master",
      "devAddr": 105
    },
    "ap3216c": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 100000,
      "mode": "master",
      "devAddr": 30
    },
    "si7006": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 64
    },
    "spl06": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 119
    },
    "qmc5883": {
      "type": "I2C",
      "port": 1,
      "addrWidth": 7,
      "freq": 400000,
      "mode": "master",
      "devAddr": 13
    },
    "KEY1": {
      "type": "GPIO",
      "port": 21,
      "dir": "irq",
      "pull": "opendrain",
      "intMode": "falling"
    },
    "KEY2": {
      "type": "GPIO",
      "port": 20,
      "dir": "irq",
      "pull": "opendrain",
      "intMode": "falling"
    },
    "KEY3": {
      "type": "GPIO",
      "port": 39,
      "dir": "irq",
      "pull": "opendrain",
      "intMode": "falling"
    },
    "CTRL1": {
      "type": "GPIO",
      "port": 22,
      "dir": "output",
      "pull": "pullup"
    },
    "CTRL2": {
      "type": "GPIO",
      "port": 38,
      "dir": "output",
      "pull": "pullup"
    },
    "CTRL3": {
      "type": "GPIO",
      "port": 23,
      "dir": "output",
      "pull": "pullup"
    },
    "led1": {
      "type": "GPIO",
      "port": 34,
      "dir": "output",
      "pull": "pullup"
    },
    "led2": {
      "type": "GPIO",
      "port": 35,
      "dir": "output",
      "pull": "pullup"
    },
    "led3": {
      "type": "GPIO",
      "port": 36,
      "dir": "output",
      "pull": "pullup"
    },
    "led_r": {
      "type": "GPIO",
      "port": 36,
      "dir": "output",
      "pull": "pullup"
    },
    "led_g": {
      "type": "GPIO",
      "port": 35,
      "dir": "output",
      "pull": "pullup"
    },
    "led_b": {
      "type": "GPIO",
      "port": 34,
      "dir": "output",
      "pull": "pullup"
    },
    "SPI0": {
      "type": "SPI",
      "port": 0,
      "mode": "master",
      "freq": 2000000
    },
    "oled_dc": {
      "type": "GPIO",
      "port": 33,
      "dir": "output",
      "pull": "pullup"
    },
    "oled_res": {
      "type": "GPIO",
      "port": 32,
      "dir": "output",
      "pull": "pullup"
    },
    "serial1": {
      "type": "UART",
      "port": 0,
      "dataWidth": 8,
      "baudRate": 9600,
      "stopBits": 1,
      "flowControl": "disable",
      "parity": "none"
    },
    "port485": {
      "type": "UART",
      "port": 1,
      "dataWidth": 8,
      "baudRate": 38400,
      "stopBits": 1,
      "flowControl": "disable",
      "parity": "none"
    },
    "serial2": {
      "type": "UART",
      "port": 2,
      "dataWidth": 8,
      "baudRate": 115200,
      "stopBits": 1,
      "flowControl": "disable",
      "parity": "none"
    }
  },
  "debugLevel": "ERROR",
  "repl": "disable"
}

开源地址:

点击注册立创商城登陆后可在项目页面登录克隆项目,还有元件优惠劵,每个月免费PCB打样两次还包邮!
项目硬件开源地址(含原理图和PCB文件)
项目代码开源地址(gitee)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值