Banana Pi

Model: Banana Pi

  • cpu: Allwinner A20 @ 1 GHz (ARM Cortex-A7 dual core)
  • memory: 1 GB
  • storage: SD card
  • storage: SATA connector
  • video: HDMI, composite video,
  • network: Gigabit Ethernet
  • usb: 2 x usb 2.0 ports, 1 x micro-usb OTG port
  • power: 5V 2A (micro-usb next to the SATA connector)
  • buttons: uboot key (close to the LVDS connector and the ethernet jack), reset button (next to the usb OTG connector), power button

Links

banana-pi.org: BPI-M1, old bananapi.org, Bananian Linux,

OS testing: armbian, Bananian,

back to home automation, machines page.

History / work log

2021-08-12: I re-created this page on my self-hosted web server.

2020-03-16: getting serial sensor data at the rate I had was "hogging" resources from my Home Assistant, so I changed the program to send data only every minute:

tingo@kg-core1$ more soil_sensor.ino
// soil_sensor - for my house plant
// 2020-30-15 Torfinn Ingolfsen
// based on a lot of examples on the internet
//
#include "ArduinoJson.h"

unsigned long delayTime = 60000; // microseconds, 60k = 1 minute, 300000 = 5 minutes
const int AirValue = 568;
const int WaterValue = 328; // have seen: 328
int soilMoistureValue = 0;
int soilmoisturepercent = 0;
const size_t capacity = JSON_OBJECT_SIZE(2);
DynamicJsonDocument doc(capacity);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  soilMoistureValue = analogRead(A0);
  doc["value"] = soilMoistureValue;

  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  if (soilmoisturepercent > 100)
  {
    soilmoisturepercent = 100;
  }
  else if (soilmoisturepercent < 0)
  {
    soilmoisturepercent = 0;
  }
  doc["moisture"] = soilmoisturepercent;
  serializeJson(doc, Serial);
  // for debugging via Serial Monitor, enable the line below
  // also important for getting values into Home Assistant
  Serial.println();
  delay(delayTime);
}

much better now.

2020-03-16: I noticed that the "Stueplante fuktighet" sensor stopped updating after a while. Perhaps trying to access the same serial port from two different sensors isn't a good idea. So I changed the sensors setup in configuration.yaml a bit. Now it is like this:

  - platform: serial
    serial_port: /dev/ttyUSB0
    baudrate: 9600

  - platform: template
    sensors:
      stueplante_fuktighet:
        friendly_name: 'Stueplante fuktighet'
        unit_of_measurement: "%"
        value_template: '{{ state_attr("sensor.serial_sensor", "moisture") }}'
      stueplante_raw:
        friendly_name: 'Stueplante raw'
        value_template: '{{ state_attr("sensor.serial_sensor", "value") }}'

so far it looks great. I can have graphs on the sensor card now! I also added

plant:
  stueplanten:
    sensors:
      moisture: sensor.stueplante_fuktighet
    min_moisture: 20

not sure if this is useful or not. Time will tell.

2020-03-15: sensor - I tried setting up the moisture sensor like this in configuration.yaml (in the sensor: section)

  - platform: serial
    serial_port: /dev/ttyUSB0
    baudrate: 9600
    name: 'Stueplante fuktighet'
    value_template: '{{ value_json.moisture }}'
  - platform: serial
    serial_port: /dev/ttyUSB0
    baudrate: 9600
    name: 'Stueplante raw'
    value_template: '{{ value_json.value }}'

unfortunately, I don't get any values. Ok, fixing the Arduino program so it sends a newline after each json - now it works.

2020-03-15: the Arduino with the moisture sensor shows up:

tingo@kg-bpi:~$ lsusb -d 1a86:7523
Bus 004 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
tingo@kg-bpi:~$ ls -l /dev/tty[ACU]*
crw-rw---- 1 root dialout 188, 0 Mar 15 20:08 /dev/ttyUSB0

and I can get the values with

tingo@kg-bpi:~$ screen /dev/ttyUSB0 9600

not very practical, but at least it works

2020-03-15: I found an Arduino UNO clone, wired up the moisture sensor to 5V, gnd, and A0, this works fine, even if banggood says that this sensor is for 3.3V. The program I run is this:

tingo@kg-core1$ pwd
/usr/home/tingo/sketchbook/capa_sensor/soil_sensor
tingo@kg-core1$ ls -l
total 180
-rw-r--r--  1 tingo  tingo  181239 Mar 15 19:12 ArduinoJson-v6.14.1.h
lrwxr-xr-x  1 tingo  tingo      21 Mar 15 19:21 ArduinoJson.h -> ArduinoJson-v6.14.1.h
-rw-r--r--  1 tingo  tingo     968 Mar 15 19:55 soil_sensor.ino

program

tingo@kg-core1$ more soil_sensor.ino
// soil_sensor - for my house plant
// 2020-30-15 Torfinn Ingolfsen
// based on a lot of examples on the internet
//
#include "ArduinoJson.h"

const int AirValue = 568;
const int WaterValue = 328; // have seen: 328
int soilMoistureValue = 0;
int soilmoisturepercent = 0;
const size_t capacity = JSON_OBJECT_SIZE(2);
DynamicJsonDocument doc(capacity);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  soilMoistureValue = analogRead(A0);
  doc["value"] = soilMoistureValue;

  soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
  if (soilmoisturepercent > 100)
  {
    soilmoisturepercent = 100;
  }
  else if (soilmoisturepercent < 0)
  {
    soilmoisturepercent = 0;
  }
  doc["moisture"] = soilmoisturepercent;
  serializeJson(doc, Serial);
  // for debugging via Serial Monitor, enable the line below
  // Serial.println();
  delay(250);
}

and I'm using ArduinoJson version 6.14.1. Now let me see if I can get it working when connected to the bpi.

2020-03-09: also - Wireless Module for Capacitive Soil Moisture Sensor v1.2 looks interesting, if one needs wireless sensors.

2020-03-09: capacitive soil moisture sensor - I could just use an Arduino, and feed serial output to the bpi.

2020-03-03: I now have a few capacitive soil moisture sensors (these from Banggood), I wonder if gpio and adc of the BPI M1 is available under armbian? gpio pinout (CON3)

3.3V1                       1  2 5V1 (output)
(TWI2_SDA, PB21) I2C-SDA    3  4 5V2 (output)
(TWI2_SCK, PB20) I2C-SCL    5  6 gnd
(PWM1, PI3) GCLK            7  8 UART-TX (UART3_TX, PH0)
gnd                         9 10 UART-RX (UART3_RX, PH1)
(UART2_RX, PI19) GPIO 0    11 12 GPIO 1 (PH2)
(UART2_TX, PI18) GPIO 2    13 14 gnd
(UART2_CTS, PI17) GPIO 3   15 16 GPIO 4 (CAN_TX, PH20)
                 3.3V2     17 18 GPIO 5 (CAN_RX, PH21)
(SPI0_MOSI, PI12) SPI MOSI 19 20 gnd
(SPI0_MISO, PI13) SPI MISO 21 22 GPIO 6
(SPI0_CLK, PI11)  SPI CLK  23 24 SPI CE0 (SPI_CS0, PI10)
gnd      25 26 SPI CE1 (SPI_CS1, PI14)

pins gpio

CON1 - DSI display connector
CON2 - CSI camera connector

J11 UART (console output)

pin 1 TXD UART0-TXD
pin 2 RXD UART0-RXD

J12 - also have a serial port

2015-03-11: assembled the second Banana Pi in the second case.

2015-03-10: this afternoon I bought another Banana Pi (131313) NOK 449.- and case (130993) NOK 129.- at Digital Impuls, total cost NOK 578.-. This is so that I can have one to experiment with, while the first one is "occupied" as a server.

2015-03-07: assembled the case. A Raspberry Pi case would not work: no holes for the SATA connector, power connector, and no holes for the buttons. This case is well made, and well thought out. Included standoffs make the Banana Pi board fit perfectly in the case.

2015-03-07: I bought a clear Banana Pi case (130993) at Digital Impuls today, for NOK 129.-

2015-03-02: it looks like NetBSD runs on the Banana Pi: NetBSD evbarm / allwinner,

2015-03-02: I tested Bananian Linux on the machine; it works. It is a minimal Debian 7.

2015-02-21: at Digital Impuls, I bought a Banana Pi (131313) NOK 449.- and a 5 V 2.1A, usb charger (133750) NOK 149.-