mirror of
https://codeberg.org/scip/attinycore-makefile-tests.git
synced 2025-12-16 19:00:57 +01:00
add rf transmitter
This commit is contained in:
53
841-tinycore-micronucleus-bme280-spi-radio-test/Makefile
Normal file
53
841-tinycore-micronucleus-bme280-spi-radio-test/Makefile
Normal file
@@ -0,0 +1,53 @@
|
||||
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
|
||||
|
||||
# attiny841:
|
||||
# BOARD_TAG = attinyx41
|
||||
# BOARD_SUB = 841
|
||||
# attiny861:
|
||||
# BOARD_TAG = attinyx61
|
||||
# BOARD_SUB = 861
|
||||
# attiny85:
|
||||
# BOARD_TAG = attinyx5
|
||||
# BOARD_SUB = 85
|
||||
# attiny84:
|
||||
# BOARD_TAG = attinyx4
|
||||
# BOARD_SUB = 84
|
||||
|
||||
ARDUINO_VERSION = 10810
|
||||
|
||||
PROJECT_DIR = $(shell pwd)
|
||||
BOARD_TAG = attinyx41
|
||||
BOARD_SUB = 841
|
||||
ARDUINO_DIR = /usr/local/arduino
|
||||
ARDMK_DIR = /usr/local/arduino/Arduino-Makefile
|
||||
MONITOR_PORT = /dev/ttyACM0
|
||||
ISP_PORT = /dev/ttyACM0
|
||||
AVRDUDE = /usr/local/bin/avrdude
|
||||
ARDUINO_LIBS = SPI TinyBME280 RFTransmitter
|
||||
ARDUINO_SKETCHBOOK = .
|
||||
|
||||
# mk stuff
|
||||
ALTERNATE_CORE = ATTinyCore
|
||||
F_CPU = 8000000L
|
||||
MONITOR_BAUDRATE = 115200
|
||||
AVRDUDE_ARD_PROGRAMMER = stk500v2
|
||||
AVRDUDE_ARD_BAUDRATE = 9600
|
||||
AVR_TOOLS_DIR = /usr/local/avr
|
||||
AVRDUDE_CONF = /usr/local/etc/avrdude.conf
|
||||
|
||||
# Micronucleus
|
||||
MNINST = sudo micronucleus
|
||||
|
||||
# compiler stuff
|
||||
CFLAGS_STD = -std=gnu11
|
||||
CXXFLAGS_STD = -std=gnu++11
|
||||
CXXFLAGS + = -pedantic -Wall -Wextra
|
||||
CURRENT_DIR = $(shell pwd)
|
||||
|
||||
# keep this!
|
||||
include $(ARDMK_DIR)/Arduino.mk
|
||||
|
||||
# install using micronucleus
|
||||
install: $(TARGET_HEX) verify_size
|
||||
@echo "########### Press RESET on the Nanite! ##############"
|
||||
$(MNINST) $(TARGET_HEX)
|
||||
17
841-tinycore-micronucleus-bme280-spi-radio-test/README.md
Normal file
17
841-tinycore-micronucleus-bme280-spi-radio-test/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Usable Pins
|
||||
|
||||
```
|
||||
PIN_A0 (10)
|
||||
PIN_A1 ( 9)
|
||||
PIN_A2 ( 8)
|
||||
PIN_A3 ( 7)
|
||||
PIN_A4 ( 6)
|
||||
PIN_A5 ( 5)
|
||||
PIN_A6 ( 4)
|
||||
PIN_A7 ( 3)
|
||||
PIN_B0 ( 0)
|
||||
PIN_B1 ( 1)
|
||||
PIN_B2 ( 2)
|
||||
PIN_B3 (11) /* RESET */
|
||||
LED_BUILTIN (2)
|
||||
```
|
||||
113
841-tinycore-micronucleus-bme280-spi-radio-test/SensorSerial.ino
Normal file
113
841-tinycore-micronucleus-bme280-spi-radio-test/SensorSerial.ino
Normal file
@@ -0,0 +1,113 @@
|
||||
/* -*-c++-*-
|
||||
Blink
|
||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
./hardware/ATTinyCore/avr/cores/tinymodern/core_pins.h
|
||||
Caution: reverse Pinout: PA3 => Pin 3
|
||||
|
||||
Nanite841 Pinout from above:
|
||||
|
||||
button
|
||||
SDO/MISO PA5 PA6 SDI/MOSI
|
||||
SCK PA4 PA7
|
||||
CS PA3 PB2
|
||||
RX0 PA2 PB2
|
||||
TX0 PA1 PB1
|
||||
PA0 PB0
|
||||
GND VCC
|
||||
usb
|
||||
|
||||
Bosch BME280 Breakout from above pin header left:
|
||||
|
||||
VCC
|
||||
GND
|
||||
SCL => SCK
|
||||
SDI => MOSI
|
||||
CSB => PA3/3
|
||||
SDO => MISO
|
||||
|
||||
*/
|
||||
|
||||
#define TINY_BME280_SPI
|
||||
#include <TinyBME280.h>
|
||||
|
||||
// https://andreasrohner.at/posts/Electronics/New-Arduino-library-for-433-Mhz-AM-Radio-Modules/
|
||||
#include <RFTransmitter.h>
|
||||
|
||||
#define NODE_ID 1
|
||||
#define OUTPUT_PIN 7
|
||||
#define LED 2 //LED_BUILTIN // PORTB2
|
||||
#define CS 3
|
||||
#define DELAY 5000
|
||||
|
||||
static tiny::BME280 sensor;
|
||||
RFTransmitter transmitter(OUTPUT_PIN, NODE_ID);
|
||||
|
||||
#define SET_OUTPUT(pin) DDRB |= (1 << pin)
|
||||
#define SET_HIGH(pin) PORTB |= (1 << pin)
|
||||
#define SET_LOW(pin) PORTB &= ~(1 << pin)
|
||||
|
||||
void print_asufloat(uint32_t val, uint16_t factor) {
|
||||
Serial.print(val / factor);
|
||||
Serial.print(".");
|
||||
Serial.print(val % factor);
|
||||
}
|
||||
|
||||
void print_asifloat(int32_t val, uint16_t factor) {
|
||||
Serial.print(val / factor);
|
||||
Serial.print(".");
|
||||
Serial.print(val % factor);
|
||||
}
|
||||
|
||||
void print_measurements() {
|
||||
uint32_t pres, humidity;
|
||||
int32_t temp;
|
||||
|
||||
temp = sensor.readFixedTempC();
|
||||
humidity = sensor.readFixedHumidity();
|
||||
pres = sensor.readFixedPressure();
|
||||
|
||||
SET_LOW(LED);
|
||||
|
||||
Serial.print(" Temperature: ");
|
||||
print_asifloat(temp, 100);
|
||||
Serial.println(" Grad C");
|
||||
|
||||
Serial.print(" Pressure: ");
|
||||
print_asufloat(pres, 100);
|
||||
Serial.println(" hPa");
|
||||
|
||||
Serial.print(" Humidity: ");
|
||||
print_asufloat(humidity, 1000);
|
||||
Serial.println(" %");
|
||||
|
||||
Serial.println();
|
||||
|
||||
transmitter.send((byte *)temp, sizeof(temp));
|
||||
SET_HIGH(LED);
|
||||
}
|
||||
|
||||
void halt() {
|
||||
while(1);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
SET_OUTPUT(LED);
|
||||
Serial.begin(115200);
|
||||
Serial.println("init");
|
||||
|
||||
if(sensor.beginSPI(CS) == false) {
|
||||
Serial.println("Sensor BME280 connect failed, check wiring!");
|
||||
halt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
print_measurements();
|
||||
delay(DELAY);
|
||||
}
|
||||
|
||||
1
841-tinycore-micronucleus-bme280-spi-radio-test/hardware
Symbolic link
1
841-tinycore-micronucleus-bme280-spi-radio-test/hardware
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/local/arduino/hardware
|
||||
@@ -0,0 +1 @@
|
||||
/usr/local/arduino/hardware/ATTinyCore/avr/libraries/RFTransmitter
|
||||
1
841-tinycore-micronucleus-bme280-spi-radio-test/libraries/SPI
Symbolic link
1
841-tinycore-micronucleus-bme280-spi-radio-test/libraries/SPI
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/local/arduino/hardware/ATTinyCore/avr/libraries/SPI
|
||||
@@ -0,0 +1 @@
|
||||
/usr/local/arduino/hardware/ATTinyCore/avr/libraries/TinyBME280
|
||||
Reference in New Issue
Block a user