The Alpha Geek – Geeking Out

Battery

Project #26 – Radio Frequency – Video Game – Mk10

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFunJoystickShield #SparkFunThingPlusESP32WROOM #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Video Game

——

Video Game

——

Video Game

——

LaunchBox

LaunchBox was originally built as an attractive frontend for DOSBox, but has long since expanded to support both modern PC games and emulated console platforms. LaunchBox aims to be the one-stop shop for gaming on your computer, for both modern and historical games.

LaunchBox includes automated import processes for everything from modern Steam games to GOG classics, ROM files, MS-DOS games, and so much more. Box art and metadata is automatically downloaded from the LaunchBox Games Database, with excellent coverage for your games.

Doom (Video Game MS-DOS)

Doom is a video game series and media franchise created by John Carmack, John Romero, Adrian Carmack, Kevin Cloud, and Tom Hall. The focuses on the exploits of an unnamed space marine operating under the auspices of the Union Aerospace Corporation, who fights hordes of demons and the undead in order to save Earth from an apocalyptic invasion.

The original Doom is considered one of the first pioneering first-person shooter games, introducing to IBM-compatible computers features such as 3D graphics, third-dimension spatiality, networked multiplayer gameplay, and support for player-created modifications with the Doom WAD format.

DL2303Mk01

1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

DLE_UP – Digital 16
DLE_DOWN – Digital 19
DLE_LEFT – Digital 18
DLE_RIGHT – Digital 17
DLE_FIRE – Digital 21
DLE_SPACE – Digital 5
LED – LED_BUILTIN
VIN – +3.3V
GND – GND

——

DL2303Mk01p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Video Game - Mk10
26-10
DL2301Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Lithium Ion Battery - 1 Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// ESP32 BLE Keyboard - NIMBLE
#define USE_NIMBLE
#include <BleKeyboard.h>

// ESP32 BLE Keyboard
BleKeyboard bleKeyboard;

// Game Controller Buttons
#define DLE_UP 16
#define DLE_DOWN 19
#define DLE_LEFT 18
#define DLE_RIGHT 17
#define DLE_FIRE 21
#define DLE_SPACE 5

// Button
bool keyStates[6] = {false, false, false, false, false, false};
int keyPins[6] = {DLE_UP, DLE_DOWN, DLE_LEFT, DLE_RIGHT, DLE_FIRE, DLE_SPACE};
uint8_t keyCodes[6] = {KEY_UP_ARROW, KEY_DOWN_ARROW, KEY_LEFT_ARROW, KEY_RIGHT_ARROW, KEY_LEFT_CTRL, ' '};

// Connect Notification Sent
bool connectNotificationSent = false;

// Software Version Information
String sver = "26-10";

void loop() {
  
  // Bluetooth Serial (ESP32SPP)
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// isBluetooth
void isBluetooth() {

  // Counter
  int counter;
  
  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Connect Notification Sent
    if (!connectNotificationSent) {
      
      connectNotificationSent = true;
      
    }

    // Button
    for(counter = 0; counter < 6; counter ++){
      
      handleButton(counter);
      
    }

  }

}

getGames.ino

// Games
// Set Inputs
void setInputs() {
  
  // Make the button line an input
  pinMode(DLE_UP, INPUT_PULLUP);
  pinMode(DLE_DOWN, INPUT_PULLUP);
  pinMode(DLE_LEFT, INPUT_PULLUP);
  pinMode(DLE_RIGHT, INPUT_PULLUP);
  pinMode(DLE_FIRE, INPUT_PULLUP);
  pinMode(DLE_SPACE, INPUT_PULLUP);
  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH 
  digitalWrite(LED_BUILTIN, HIGH);

}

// Handle Button
void handleButton(int keyIndex){
  
  // Handle the button press
  if (!digitalRead(keyPins[keyIndex])){
    
    // Button pressed
    if (!keyStates[keyIndex]){
      
      // Key not currently pressed
      keyStates[keyIndex] = true;
      bleKeyboard.press(keyCodes[keyIndex]);
      
    }
    
  }
  else {
    
    // Button not pressed
    if (keyStates[keyIndex]){
      
      // Key currently pressed
      keyStates[keyIndex] = false;
      bleKeyboard.release(keyCodes[keyIndex]);
      
    }
  }
  
}

setup.ino

// Setup
void setup()
{

  // Set Inputs
  setInputs();

  // ESP32 BLE Keyboard
  bleKeyboard.begin();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #26 – Radio Frequency – SparkFun Joystick Shield – Mk09

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFunJoystickShield #SparkFunThingPlusESP32WROOM #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

SparkFun Joystick Shield

——

SparkFun Joystick Shield

——

SparkFun Joystick Shield

——

SparkFun Joystick Shield Kit

The SparkFun Joystick Shield Kit contains all the parts you need to enable your Arduino with a joystick. The shield sits on top of your Arduino and turns it into a simple controller. Five momentary push buttons and a two-axis thumb joystick gives your Arduino functionality on the level of old Nintendo controllers. Soldering is required, but it’s relatively easy and requires minimal tools. We even have a step by step guide.

The momentary push buttons are connected to Arduino digital pins 2-6; when pressed they will pull the pin low. Vertical movement of the joystick will produce a proportional analog voltage on analog pin 0, likewise, horizontal movement of the joystick can be tracked on analog pin 1.

DL2302Mk04

1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

DLE_UP – Digital 16
DLE_DOWN – Digital 19
DLE_LEFT – Digital 18
DLE_RIGHT – Digital 17
DLE_FIRE – Digital 21
DLE_SPACE – Digital 5
VIN – +3.3V
GND – GND

——

DL2302Mk04p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - SparkFun Joystick Shield - Mk09
26-09
DL2301Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Lithium Ion Battery - 1 Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// ESP32 BLE Keyboard - NIMBLE
#define USE_NIMBLE
#include <BleKeyboard.h>

// ESP32 BLE Keyboard
BleKeyboard bleKeyboard;

// Game Controller Buttons
#define DLE_UP 16
#define DLE_DOWN 19
#define DLE_LEFT 18
#define DLE_RIGHT 17
#define DLE_FIRE 21
#define DLE_SPACE 5

// Button
bool keyStates[6] = {false, false, false, false, false, false};
int keyPins[6] = {DLE_UP, DLE_DOWN, DLE_LEFT, DLE_RIGHT, DLE_FIRE, DLE_SPACE};
uint8_t keyCodes[6] = {'w', 'x', 'a', 'd', 'y', ' '};

// Connect Notification Sent
bool connectNotificationSent = false;

// Software Version Information
String sver = "26-09";

void loop() {
  
  // Bluetooth Serial (ESP32SPP)
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// isBluetooth
void isBluetooth() {

  // Counter
  int counter;
  
  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Connect Notification Sent
    if (!connectNotificationSent) {
      
      connectNotificationSent = true;
      
    }

    // Button
    for(counter = 0; counter < 6; counter ++){
      
      handleButton(counter);
      
    }

  }

}

getGames.ino

// Games
// Set Inputs
void setInputs() {
  
  // Make the button line an input
  pinMode(DLE_UP, INPUT_PULLUP);
  pinMode(DLE_DOWN, INPUT_PULLUP);
  pinMode(DLE_LEFT, INPUT_PULLUP);
  pinMode(DLE_RIGHT, INPUT_PULLUP);
  pinMode(DLE_FIRE, INPUT_PULLUP);
  pinMode(DLE_SPACE, INPUT_PULLUP);

}

// Handle Button
void handleButton(int keyIndex){
  
  // Handle the button press
  if (!digitalRead(keyPins[keyIndex])){
    
    // Button pressed
    if (!keyStates[keyIndex]){
      
      // Key not currently pressed
      keyStates[keyIndex] = true;
      bleKeyboard.press(keyCodes[keyIndex]);
      
    }
    
  }
  else {
    
    // Button not pressed
    if (keyStates[keyIndex]){
      
      // Key currently pressed
      keyStates[keyIndex] = false;
      bleKeyboard.release(keyCodes[keyIndex]);
      
    }
  }
  
}

setup.ino

// Setup
void setup()
{

  // Set Inputs
  setInputs();

  // ESP32 BLE Keyboard
  bleKeyboard.begin();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #16: Sound – Metronome – Mk22

——

#DonLucElectronics #DonLuc #Sound #Metronome #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Metronome

——

Metronome

——

Metronome

——

Metronome

A metronome is a device that produces an audible click or other sound at a regular interval that can be set by the user, typically in Beats Per Minute (BPM). Metronomes may include synchronized visual motion. Musicians use the device to practise playing to a regular pulse. In the 20th century, electronic metronomes and software metronomes were invented.

Musicians practise with metronomes to improve their timing, especially the ability to stick to a regular tempo. Metronome practice helps internalize a clear sense of timing and tempo. Composers and conductors often use a metronome as a standard tempo reference, and may play, sing, or conduct to the metronome. The metronome is used by composers to derive beats per minute if they want to indicate that in a composition. Conductors use a metronome to note their preferred tempo in each section.

SparkFun Metro-Gnome

The SparkFun Metro-Gnome is a basic digital metronome used to keep time during music practice. This is a basic kit that goes together in 15-20 minutes for people learning to solder, and 5-10 minutes for those with a bit of experience.

DL2301Mk03

-1 x Metro-Gnome PCB
-1 x ATmega168
-2 x 7-Segment Red LED
-1 x 10uF Capacitor
-1 X 0.1uf Capacitor
-1 x 10k Resistor
-1 x 1N4148 Diode
-1 x Piezo Speaker
-1 x Mini Power Switch
-2 x Push Button Reset Switches
-1 x Battery Holder Pack
-4 x AA Alkaline Battery

ATmega168

Metro-Gnome
VIN – +6V
GND – GND

——

Metrognomev03

Metrognomev03.c

// Metronome-v03

#define F_CPU 1024000	// Adjust this to get the clock more precise

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#define BUZZER1 	1
#define BUZZER1_PORT	PORTB
#define BUZZER2		2
#define BUZZER2_PORT	PORTB

#define sbi(port_name, pin_number)   (port_name |= 1<<pin_number)
#define cbi(port_name, pin_number)   ((port_name) &= (uint8_t)~(1 << pin_number))

uint16_t countUp = F_CPU/1024;		// Dividing clock by 1024
uint16_t speed = 60;		// Program initially runs at 60 BPM
uint8_t leftDisplay = 6;		// Initialize output to show 60 BPM
uint8_t rightDisplay = 0;

void ioinit();
void display(int digit, int number);

// Interrupt Timer 1 makes the buzzer tick at proper intervals
ISR(TIMER1_COMPA_vect)
{
	int buzzPeriod = 100;
	uint32_t buzzLength = 1000;

	while(1)
    {
		//Subtract the buzzPeriod from the overall length
		if(buzzPeriod > buzzLength) break;
		buzzLength -= buzzPeriod;

		if(buzzPeriod > buzzLength) break;
		buzzLength -= buzzPeriod;

		//Toggle the buzzer at various speeds
		PINB = 0b00000010;
		_delay_us(buzzPeriod);
		
		PINB = 0b00000100;
		_delay_us(buzzPeriod);
    }
}

// Interrupt Timer 2 checks for button presses
ISR(TIMER0_COMPA_vect)
{
	// Check down button
    if( (PINB & (1<<4)) == 0)
	{
		if (speed == 1)		// If speed = 1 go up to 299
		{
			speed = 299;
			rightDisplay = 9;
			leftDisplay = 9;
		}
		else if ((rightDisplay == 0) && (leftDisplay == 0))
		{
			rightDisplay = 9;
			leftDisplay = 9;
			speed--;
		}
		else if (rightDisplay == 0)
		{
			rightDisplay = 9;
			leftDisplay--;
			speed--;
		}
		else
		{
			rightDisplay--;
			speed--;
		}
		// Reset counter and adjust compare register
		TCNT1 = 0x00;
		OCR1A = (countUp*60)/speed;
	}
	// Check up button
	if((PINB & (1<<5)) == 0)
	{
		if (speed == 299)
		{
			speed = 1;
			rightDisplay = 1;
			leftDisplay = 0;
		}
		else if ((rightDisplay == 9) && (leftDisplay == 9))
		{
			rightDisplay = 0;
			leftDisplay = 0;
			speed++;
		}		
		else if (rightDisplay == 9)
		{
			rightDisplay = 0;
			leftDisplay++;
			speed++;
		}
		else
		{
			rightDisplay++;
			speed++;
		}
		// Reset counter and adjust compare register
		TCNT1 = 0x00;
		OCR1A = (countUp*60)/speed;
	}
}

int main()
{
	int flag = 0;

	ioinit();
	
	while(1)	// Main loop PWM's the two displays at 1kHz
	{
		if (flag == 0)
		{
			cbi(PORTC, 1);	// Turn right display off
			display(0, leftDisplay);	// Output to left display
			flag = 1;
		}
		else
		{
			cbi(PORTC, 0);	// Turn left display off
			display(1, rightDisplay);	// Output to right display
			flag = 0;
		}
		_delay_us(10);
		PORTD = 0xFF;
		cbi(PORTC, 0);
		cbi(PORTC, 1);
		_delay_us(30);
	}
	
	return 0;
}

void ioinit()
{
	// set PORTB for Buzzer and buttons
	DDRB = DDRB | 0b00110110;
	PORTB = PORTB | 0b00110000;
	// set PORTC for DIGI select
	DDRC = 0b0000011;
	PINC = 0b0000011;
	// set PORTD for display
	DDRD = 0b11111111;

	// Set 16-bit Timer 1 for clicking
	TCCR1A = 0x00;
	TCCR1B = (_BV(WGM12) | _BV(CS12) | _BV(CS10));	// Divide clock by 1024, CTC mode
	OCR1A = (countUp*60)/speed;	// Set top of counter
	TIMSK1 = _BV(OCIE1A);	// Enable OCR1A interrupt

	// Set Timer 0 to check button press
	TCCR0A = _BV(WGM01);
	TCCR0B = _BV(CS00) | _BV(CS02);
	OCR0A = 100;		// OCCR0A can be adjusted to change the button debounce time
	TIMSK0 = _BV(OCIE0A);

	sei();	// Enable interrupts
}

// This will output the corresponding
// 'number' to digit 0 (left) or 1 (right)
void display(int digit, int number)
{
	//cbi(PORTC, digit);	// Ties display to ground
	
	if (digit == 0)
		sbi(PORTC, 0);	// Ties display to ground
	else if (digit == 1)
		sbi(PORTC, 1);
	
	switch(number)	// Set PIND, display pins, to correct output
	{
		case 0:
			PORTD = 0b11000000;
			break;
		case 1:
			PORTD = 0b11111001;
			break;
		case 2:
			PORTD = 0b10100100;
			break;
		case 3:
			PORTD = 0b10110000;
			break;
		case 4:
			PORTD = 0b10011001;
			break;
		case 5:
			PORTD = 0b10010010;
			break;
		case 6:
			PORTD = 0b10000010;
			break;
		case 7:
			PORTD = 0b11111000;
			break;
		case 8:
			PORTD = 0b10000000;
			break;
		case 9:
			PORTD = 0b10010000;
			break;
	}
	// Turn decimal point on if above 100 & 200
	if ((digit == 0) && (speed >= 200))
		cbi(PORTD, 7);
	if ((digit == 1) && (speed >= 100))
		cbi(PORTD, 7);
}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #26 – Radio Frequency – B4J – Mk08

——

#DonLucElectronics #DonLuc #RadioFrequency #B4J #Bluetooth #SparkFunThingPlusESP32WROOM #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

B4J

——

B4J

——

B4J

——

B4J

RAD development tool for cross platform desktop, server and IoT solutions. B4J is a 100% free development tool for desktop, server and IoT solutions. With B4J you can easily create desktop applications, console programs and server solutions. B4J apps can run on Windows, Mac, Linux and ARM boards such as Raspberry Pi. The compiled apps are standalone, without any external dependencies.

DL2301Mk01

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

TX0 – Digital 26
TR0 – Digital 27
VIN – +3.3V
GND – GND

DL2301Mk01p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - B4J - Mk08
26-08
DL2301Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x GPS Receiver - GP-20U7 (56 Channel)
1 x Lithium Ion Battery - 1 Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial (ESP32SPP)
#include "BluetoothSerial.h" 

// Bluetooth Serial (ESP32SPP)
BluetoothSerial SerialBT;

// Software Version Information
String sver = "26-08";

void loop() {

  // Bluetooth Serial (ESP32SPP)
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// isBluetooth
void isBluetooth() {

  // Input
  byte inputFromOtherSide;
  
  // Bluetooth Serial (ESP32SPP)
  if (SerialBT.available()) {

    // Input Read
    inputFromOtherSide = SerialBT.read();
    // Write
    SerialBT.write(inputFromOtherSide);

  }
  
}

setup.ino

// Setup
void setup()
{

  // Bluetooth Serial (ESP32SPP)
  SerialBT.begin("DLE");
  
  // Delay
  delay(1000);

}

——

B4J – Bluetooth

Bluetooth.b4j

#Region  Project Attributes 
	
	' Form Width and Form Height
	#MainFormWidth: 600
	#MainFormHeight: 400 
	
#End Region

Sub Process_Globals
	
	'Java OpenJDK 11
	Private fx As JFX
	' MainForm => Form
	Private MainForm As Form
	' Button
	Private btnConnect As Button
	Private btnSearch As Button
	Private btnSend As Button
	' List View
	Private ListView1 As ListView
	' Text Field
	Private txtInput As TextField
	' Text Area
	Private txtLog As TextArea
	
	' Bluetooth
	Private bt As Bluetooth
	' Async Streams
	Private astream As AsyncStreams
	' Boolean
	Private connected As Boolean
	Private searchingForDevices As Boolean
	' Bluetooth Connection
	Private currentConnection As BluetoothConnection
	
	' Map
	Private foundDevices As Map
	' Button
	Private btnDisconnect As Button
	' Label
	Private lblConnectionState As Label
	Private lblSearchState As Label
	' Image View
	Private ImageView1 As ImageView
	
End Sub

Sub AppStart (Form1 As Form, Args() As String)
	
	' App Start => MainForm = Form1
	MainForm = Form1
	MainForm.SetFormStyle("UNIFIED")
	' Load the layout file.
	MainForm.RootPane.LoadLayout("1") 
	' Show
	MainForm.Show
	' Bluetooth
	bt.Initialize("bt")
	foundDevices.Initialize
	If bt.IsEnabled Then
		bt.Listen
	End If
	' Update State
	UpdateState
	
End Sub

Private Sub UpdateState
	
	' Update State
	If bt.IsEnabled = False Then
		
		' No Bluetooth
		lblSearchState.Text = "Bluetooth not available"
		For Each n As Node In MainForm.RootPane
			n.Enabled = False
		Next
		
	Else
		
		' Bluetooth
		' Button
		btnSearch.Enabled = Not(searchingForDevices)
		btnConnect.Enabled = Not(connected) And ListView1.SelectedIndex > -1
		txtInput.Enabled = connected
		btnSend.Enabled = connected
		btnDisconnect.Enabled = connected
		
		' State => Connected or Disconnected
		Dim state As String
		If connected Then 
			state = "Connected: " & currentConnection.Name 
		Else 
			state = "Disconnected"
		End If
		' Label
		lblConnectionState.Text = state
		lblSearchState.Text = "Searching..."
		lblSearchState.Visible = searchingForDevices
		
	End If
	
End Sub


Private Sub btnSearch_Action
	
	' Button
	' Search Boolean
	Dim res As Boolean = bt.StartDiscovery
	If res Then
		
		' Searching For Devices
		searchingForDevices = True
		' List View
		ListView1.Items.Clear
		' Update State
		UpdateState
		
	Else
		
		' Error
		Log("Error starting discovery")
		
	End If
	
End Sub

Private Sub bt_DeviceFound (Name As String, MacAddress As String)
	
	' Button
	' Device Found => Description
	Dim description As String = Name & ": " & MacAddress
	' List View
	ListView1.Items.Add(description)
	' Found Devices
	foundDevices.Put(description, MacAddress)
	
End Sub

Private Sub bt_DiscoveryFinished
	
	' Button
	' Discovery Finished
	searchingForDevices = False
	' Update State
	UpdateState
	
End Sub

Private Sub btnConnect_Action
	
	' Button
	' Connect
	Dim address As String = foundDevices.Get(ListView1.SelectedItem)
	' Bluetooth
	bt.Connect(address)
	
End Sub

Private Sub bt_Connected (Success As Boolean, connection As BluetoothConnection)
	
	' Button
	Log($"Connected, success=${Success}"$)
	' Success
	If Success Then
		
		' Connection
		currentConnection = connection
		connected = True
		' AStream
		If astream.IsInitialized Then astream.Close
		astream.InitializePrefix(connection.InputStream, True, connection.OutputStream, "AStream")
		
	End If
	' Bluetooth Listen
	bt.Listen
	' Update State
	UpdateState
	
End Sub

Sub AStream_NewData (Buffer() As Byte)
	
	' AStream New Data
	' You => Arduino
	LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
	
End Sub


Sub AStream_Error
	
	' AStream Error
	connected = False
	' Update State
	UpdateState
	
End Sub

Sub AStream_Terminated
	
	' AStream Terminated
	AStream_Error
	
End Sub

Private Sub txtInput_Action
	
	' Button Send
	btnSend_Action
	
End Sub

Private Sub btnSend_Action
	
	' Button Send
	If txtInput.Text.Length > 0 Then
		
		' AStream
		' Me => B4J
		LogMessage("Me", txtInput.Text)
		' AStream Write
		astream.Write(txtInput.Text.GetBytes("utf8"))
		txtInput.Text = ""
		
	End If
	
End Sub

Private Sub LogMessage(From As String, Msg As String)
	
	' Log Message
	txtLog.Text = txtLog.Text & From & ": " & Msg & CRLF
	txtLog.SetSelection(txtLog.Text.Length, txtLog.Text.Length)
	
End Sub

Private Sub ListView1_SelectedIndexChanged(Index As Int)
	
	' Update State
	UpdateState
	
End Sub

Private Sub btnDisconnect_Action
	
	' Bluetooth Disconnect
	currentConnection.Disconnect
	' AStream Close
	If astream.IsInitialized Then astream.Close
	connected = False
	' Update State
	UpdateState
	
End Sub

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2022
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #26 – Radio Frequency – GPS Receiver – Mk07

——

#DonLucElectronics #DonLuc #RadioFrequency #Moteino #Send #Receive #GPSReceiver #OpenLog #Display #FreeIMU #Magnetometer #Accelerometer #Gyroscope #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

GPS Receiver

——

GPS Receiver

——

GPS Receiver

——

GPS Receiver – GP-20U7 (56 Channel)

The GP-20U7 is a compact GPS receiver with a built-in high performances all-in-one GPS chipset. The GP-20U7 accurately provides position, velocity, and time readings as well possessing high sensitivity and tracking capabilities. Thanks to the low power consumption this receiver requires, the GP-20U7 is ideal for portable applications such as tablet PCs, smart phones, and other devices requiring positioning capability.

This 56-channel GPS module, that supports a standard NMEA-0183 and uBlox 7 protocol, has low power consumption of 40mA@3.3V (Max), an antenna on board, and -162dBm tracking sensitivity. With 56 channels in search mode and 22 channels “All-In-View” tracking, the GP-20U7 is quite the work horse for its size.

DL2212Mk02

2 x Moteino R2 (RFM12B)
1 x GPS Receiver – GP-20U7 (56 Channel)
1 x SparkFun OpenLog
1 x microSD Card – 16GB
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom – Sensor Stick
2 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

Moteino R2 (Receive)

TX0 – Digital 1
TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2212Mk02pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - GPS Receiver - Mk07
26-07
Receive
DL2212Mk02pr.ino
2 x Moteino R2 (RFM12B)
1 x GPS Receiver - GP-20U7 (56 Channel)
1 x SparkFun OpenLog
1 x microSD Card - 16GB
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
2 x Lithium Ion Battery - 1Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun Micro OLED
#include <SFE_MicroOLED.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        1
// The network ID we are on
#define NETWORKID    99
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Need an instance of the RFM12B Radio Module
RFM12B radio;

// Process Message
// Message
String msg = "";
int firstClosingBracket = 0;
// Yaw Pitch Roll
String sYaw = "";
String sPitch = "";
String sRoll = "";
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// LED
int iLED = 9;

// SparkFun Micro OLED
#define PIN_RESET 9
#define DC_JUMPER 1
// I2C declaration
MicroOLED oled(PIN_RESET, DC_JUMPER);

// Software Version Information
String sver = "26-07";

void loop() {

  // is RFM12B Radio
  isRFM12BRadio();

  // Micro OLED
  isMicroOLED();

}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // msg = "<IMU|Yaw|Pitch|Roll|GPS Status|Latitude|Longitude|Date|Time|*"
  // msg = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|" + GPSSt 
  // + "|" + TargetLat + "|" TargetLon + "|" + TargetDat +"|" + TargetTim + "|*"
  firstClosingBracket = 0;
  // "<IMU|"
  firstClosingBracket = msg.indexOf('|');
  msg.remove(0, 5);
  // Yaw
  firstClosingBracket = msg.indexOf('|');
  sYaw = msg;
  sYaw.remove(firstClosingBracket);
  Yaw = sYaw.toFloat();
  // Pitch
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  sPitch = msg;
  sPitch.remove(firstClosingBracket);
  Pitch = sPitch.toFloat();
  // Roll
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  sRoll = msg;
  sRoll.remove(firstClosingBracket);
  Roll = sRoll.toFloat();

}

getMicroOLED.ino

// SparkFun Micro OLED
// Setup Micro OLED
void isSetupMicroOLED() {

  // Initialize the OLED
  oled.begin();
  // Clear the display's internal memory
  oled.clear(ALL);
  // Display what's in the buffer (splashscreen)
  oled.display();

  // Delay 1000 ms
  delay(1000);

  // Clear the buffer.
  oled.clear(PAGE);
  
}
// Micro OLED
void isMicroOLED() {

  // Text Display FreeIMU
  // Clear the display
  oled.clear(PAGE);
  // Set cursor to top-left
  oled.setCursor(0, 0);
  // Set font to type 0
  oled.setFontType(0);
  // FreeIMU
  oled.print("FreeIMU");
  oled.setCursor(0, 12);
  // Yaw
  oled.print("Y: ");
  oled.print(Yaw);
  oled.setCursor(0, 25);
  // Pitch
  oled.print("P: ");
  oled.print(Pitch);
  oled.setCursor(0, 39);
  // Roll
  oled.print("R: ");
  oled.print(Roll);
  oled.display();

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio()
{

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Transmitting
 
}
// is RFM12 BRadio
void isRFM12BRadio()
{

  // Receive
  if (radio.ReceiveComplete())
  {
    
    // CRC Pass
    if (radio.CRCPass())
    {
        
      // Message
      msg = "";
      
      // Can also use radio.GetDataLen() if you don't like pointers
      for (byte i = 0; i < *radio.DataLen; i++)
      {
        
       //Serial.print((char)radio.Data[i]);
        msg = msg + (char)radio.Data[i];
        
      }
      
      // Serial
      Serial.println( msg );
      
      // Turn the LED on HIGH
      digitalWrite( iLED , HIGH);
      
      // FreeIMU
      // Yaw Pitch Roll
      isFreeIMU();

      // ACK Requested
      if (radio.ACKRequested())
      {
        
        // Send ACK
        radio.SendACK();
        
      }

      // Turn the LED on LOW
      digitalWrite( iLED , LOW);
    
    }
    else
    {
      
      // BAD-CRC

    }

  } 
  
}

setup.ino

// Setup
void setup()
{

  // Serial
  Serial.begin(SERIAL_BAUD);

  // Give display time to power on
  delay(100);
  
  // Set up I2C bus
  Wire.begin();

  // Setup Micro OLED
  isSetupMicroOLED();

  // LED
  pinMode( iLED , OUTPUT);

  // RFM12B Radio
  isSetupRFM12BRadio();

}

——

Moteino R2 (Send)

TR0 – Digital 2
GPT – Digital 3
GPR – Digital 4
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2212Mk02ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - GPS Receiver - Mk07
26-07
Send
DL2212Mk02ps.ino
2 x Moteino R2 (RFM12B)
1 x GPS Receiver - GP-20U7 (56 Channel)
1 x SparkFun OpenLog
1 x microSD Card - 16GB
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
2 x Lithium Ion Battery - 1Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Sleep
#include <avr/sleep.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Includes and variables for IMU integration
// Accelerometer
#include <ADXL345.h>
// Magnetometer
#include <HMC58X3.h>
// MEMS Gyroscope
#include <ITG3200.h>
// Debug
#include "DebugUtils.h"
// FreeIMU
#include <CommunicationUtils.h>
#include <FreeIMU.h>
// GPS Receiver
#include <TinyGPS++.h>
// Software Serial
#include <SoftwareSerial.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        2
// The network ID we are on
#define NETWORKID    99
// The node ID we're sending to
#define GATEWAYID     1
// # of ms to wait for an ack
#define ACK_TIME     50
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Wait this many ms between sending packets
int interPacketDelay = 1000;
// Input
char input = 0;

// Need an instance of the RFM12B Radio Module
RFM12B radio;
// Send Size
byte sendSize = 0;
// Payload
char payload[100];
// Request ACK
bool requestACK = false;

// LED
int iLED = 9;

// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();

// Yaw Pitch Roll
String zzzzzz = "";
String sYaw = "";
String sPitch = "";
String sRoll = "";
float ypr[3];
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// GPS Receiver
#define gpsRXPIN 4
// This one is unused and doesnt have a conection
#define gpsTXPIN 3
// The TinyGPS++ object
TinyGPSPlus gps;
// Latitude
float TargetLat;
String sLat = "";
// Longitude
float TargetLon;
String sLon = "";
// GPS Date, Time
// GPS Date
String TargetDat;
// GPS Time
String TargetTim;
// GPS Status
String GPSSt = "";

// The serial connection to the GPS device
SoftwareSerial tGPS(gpsRXPIN, gpsTXPIN);

// Software Version Information
String sver = "26-07";

void loop()
{

  // isGPS
  isGPS();
  
  // isFreeIMU
  isFreeIMU();

  // is RFM12B Radio
  isRFM12BRadio();

  // Inter Packet Delay
  delay(interPacketDelay);
  
}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // Yaw Pitch Roll
  my3IMU.getYawPitchRoll(ypr);
  // Yaw
  Yaw = ypr[0];
  // Pitch
  Pitch = ypr[1];
  // Roll
  Roll = ypr[2];

}

getGPS.ino

// GPS Receiver
// Setup GPS
void setupGPS() {

  // Setup GPS
  tGPS.begin( 9600 );
  
}
// isGPS
void isGPS(){

  // Receives NEMA data from GPS receiver
  // This sketch displays information every time a new sentence is correctly encoded
  while ( tGPS.available() > 0)
    
    if (gps.encode( tGPS.read() ))
    {
     
       // GPS Vector Pointer Target
       displayInfo();
       // GPS Date, Time
       displayDTS();
       
    }
  
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
   
     while(true);
    
  }

}
// GPS Vector Pointer Target
void displayInfo(){

  // Location
  if (gps.location.isValid())
  {
    
     // Latitude
     TargetLat = gps.location.lat();
     // Longitude
     TargetLon = gps.location.lng();
     // GPS Status 2
     GPSSt = "Yes";
    
  }
  else
  {

     // GPS Status 0
     GPSSt = "No";
    
  }

}
// GPS Date, Time
void displayDTS(){

  // Date
  TargetDat = ""; 
  if (gps.date.isValid())
  {
    
     // Date
     // Year
     TargetDat += String(gps.date.year(), DEC);
     TargetDat += "/";
     // Month
     TargetDat += String(gps.date.month(), DEC);
     TargetDat += "/";
     // Day
     TargetDat += String(gps.date.day(), DEC);
    
  }

  // Time
  TargetTim = "";
  if (gps.time.isValid())
  {
    
     // Time
     // Hour
     TargetTim += String(gps.time.hour(), DEC);
     TargetTim += ":";
     // Minute
     TargetTim += String(gps.time.minute(), DEC);
     TargetTim += ":";
     // Secound
     TargetTim += String(gps.time.second(), DEC);
    
  }

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio(){

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Sleep right away to save power
  radio.Sleep();
  // Transmitting
  Serial.println("Transmitting...\n\n");
  
}
// is RFM12 BRadio
void isRFM12BRadio(){

  // sYaw, sPitch, sRoll ""
  sYaw = "";
  sPitch = "";
  sRoll = "";
  // Latitude and Longitude
  sLat = "";
  sLon = "";
  
  // sYaw, sPitch, sRoll concat
  sYaw.concat(Yaw);
  sPitch.concat(Pitch);
  sRoll.concat(Roll);

  // Latitude and Longitude
  sLat.concat( TargetLat );
  sLon.concat( TargetLon );

  // zzzzzz ""
  zzzzzz = "";

  // zzzzzz = "<IMU|Yaw|Pitch|Roll|GPS Status|Latitude|Longitude|Date|Time|*"
  // zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|" + GPSSt 
  // + "|" + TargetLat + "|" TargetLon + "|" + TargetDat +"|" + TargetTim + "|*"
  zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|" + GPSSt + "|" 
  + sLat + "|" + sLon + "|" + TargetDat + "|" + TargetTim + "|*";

  // sendSize Length
  sendSize = zzzzzz.length();

  // sendSize
  payload[sendSize];

  // sendSize, charAt
  for(byte i = 0; i < sendSize+1; i++){

    payload[i] = zzzzzz.charAt(i);
    
  }
    
  // payload
  Serial.print(payload);
  
  // Request ACK
  requestACK = sendSize;
  
  // Wakeup
  radio.Wakeup();
  
  // Turn the LED on HIGH
  digitalWrite( iLED , HIGH);
  
  // Send
  radio.Send(GATEWAYID, payload, sendSize, requestACK);

  // Request ACK
  if (requestACK)
  {
    
    Serial.print(" - waiting for ACK...");
    if (waitForAck()){
      
      Serial.print("Ok!");
      
    }
    else Serial.print("nothing...");
    
  }

  // Turn the LED on LOW
  digitalWrite( iLED , LOW);

  // Sleep
  radio.Sleep();

  // Serial
  Serial.println();
  
}
// Wait a few milliseconds for proper ACK, return true if received
static bool waitForAck(){
  
  // Now
  long now = millis();

  // ACK
  while (millis() - now <= ACK_TIME){
    

    if (radio.ACKReceived(GATEWAYID)){
      
      return true;

    }

  }
  
  return false;
  
}

setup.ino

// Setup
void setup(){

  // Serial
  Serial.begin(SERIAL_BAUD);

  // GPS Receiver
  // Setup GPS
  setupGPS();

  // LED
  pinMode( iLED , OUTPUT);

  // Set up I2C bus
  Wire.begin();

  // RFM12B Radio
  isSetupRFM12BRadio();

  // Pause
  delay(5);
  // Initialize IMU
  my3IMU.init();
  // Pause
  delay(5);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #26 – Radio Frequency – OpenLog – Mk06

——

#DonLucElectronics #DonLuc #RadioFrequency #Moteino #Send #Receive #OpenLog #Display #FreeIMU #Magnetometer #Accelerometer #Gyroscope #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

OpenLog

——

OpenLog

——

OpenLog

——

SparkFun OpenLog

The SparkFun OpenLog is an open source data logger that works over a simple serial connection and supports microSD cards up to 32GB. The OpenLog can store or “Log” huge amounts of serial data and act as a black box of sorts to store all the serial data that your project generates, for scientific or debugging purposes.

The SparkFun OpenLog uses an ATmega328 running at 16MHz thanks to the onboard resonator. The OpenLog draws approximately 2-3mA in idle mode. During a full record OpenLog can draw 10 to 20mA depending on the microSD card being used.

All data logged by the OpenLog is stored on the microSD card. Any 512MB to 32GB microSD card should work. OpenLog supports both FAT16 and FAT32 SD formats.

DL2212Mk01

2 x Moteino R2 (RFM12B)
1 x SparkFun OpenLog
1 x microSD Card – 16GB
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom – Sensor Stick
2 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

Moteino R2 (Receive)

TX0 – Digital 1
TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2212Mk01pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - OpenLog - Mk06
26-06
Receive
DL2212Mk01pr.ino
2 x Moteino R2 (RFM12B)
1 x SparkFun OpenLog
1 x microSD Card - 16GB
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
2 x Lithium Ion Battery - 1Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun Micro OLED
#include <SFE_MicroOLED.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        1
// The network ID we are on
#define NETWORKID    99
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Need an instance of the RFM12B Radio Module
RFM12B radio;

// Process Message
// Message
String msg = "";
int firstClosingBracket = 0;
// Yaw Pitch Roll
String sYaw = "";
String sPitch = "";
String sRoll = "";
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// LED
int iLED = 9;

// SparkFun Micro OLED
#define PIN_RESET 9
#define DC_JUMPER 1
// I2C declaration
MicroOLED oled(PIN_RESET, DC_JUMPER);

// Software Version Information
String sver = "26-06";

void loop() {

  // is RFM12B Radio
  isRFM12BRadio();

  // Micro OLED
  isMicroOLED();

}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // IMU Yaw Pitch Roll
  // msg = "<IMU|1000|1000|1000|*";
  // msg = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*"
  firstClosingBracket = 0;
  // "<IMU|"
  firstClosingBracket = msg.indexOf('|');
  msg.remove(0, 5);
  // Yaw
  firstClosingBracket = msg.indexOf('|');
  sYaw = msg;
  sYaw.remove(firstClosingBracket);
  Yaw = sYaw.toFloat();
  // Pitch
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  sPitch = msg;
  sPitch.remove(firstClosingBracket);
  Pitch = sPitch.toFloat();
  // Roll
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  sRoll = msg;
  sRoll.remove(firstClosingBracket);
  Roll = sRoll.toFloat();

}

getMicroOLED.ino

// SparkFun Micro OLED
// Setup Micro OLED
void isSetupMicroOLED() {

  // Initialize the OLED
  oled.begin();
  // Clear the display's internal memory
  oled.clear(ALL);
  // Display what's in the buffer (splashscreen)
  oled.display();

  // Delay 1000 ms
  delay(1000);

  // Clear the buffer.
  oled.clear(PAGE);
  
}
// Micro OLED
void isMicroOLED() {

  // Text Display FreeIMU
  // Clear the display
  oled.clear(PAGE);
  // Set cursor to top-left
  oled.setCursor(0, 0);
  // Set font to type 0
  oled.setFontType(0);
  // FreeIMU
  oled.print("FreeIMU");
  oled.setCursor(0, 12);
  // Yaw
  oled.print("Y: ");
  oled.print(Yaw);
  oled.setCursor(0, 25);
  // Pitch
  oled.print("P: ");
  oled.print(Pitch);
  oled.setCursor(0, 39);
  // Roll
  oled.print("R: ");
  oled.print(Roll);
  oled.display();

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio()
{

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Transmitting
 
}
// is RFM12 BRadio
void isRFM12BRadio()
{

  // Receive
  if (radio.ReceiveComplete())
  {
    
    // CRC Pass
    if (radio.CRCPass())
    {
        
      // Message
      msg = "";
      
      // Can also use radio.GetDataLen() if you don't like pointers
      for (byte i = 0; i < *radio.DataLen; i++)
      {
        
       //Serial.print((char)radio.Data[i]);
        msg = msg + (char)radio.Data[i];
        
      }
      
      // Serial
      Serial.println( msg );
      
      // Turn the LED on HIGH
      digitalWrite( iLED , HIGH);
      
      // FreeIMU
      // Yaw Pitch Roll
      isFreeIMU();
  
      // ACK Requested
      if (radio.ACKRequested())
      {
        
        // Send ACK
        radio.SendACK();
        
      }

      // Turn the LED on LOW
      digitalWrite( iLED , LOW);
    
    }
    else
    {
      
      // BAD-CRC

    }

  } 
  
}

setup.ino

// Setup
void setup()
{

  // Serial
  Serial.begin(SERIAL_BAUD);

  // Give display time to power on
  delay(100);
  
  // Set up I2C bus
  Wire.begin();

  // Setup Micro OLED
  isSetupMicroOLED();

  // LED
  pinMode( iLED , OUTPUT);

  // RFM12B Radio
  isSetupRFM12BRadio();

}

——

Moteino R2 (Send)

TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2212Mk01ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - OpenLog - Mk06
26-06
Send
DL2212Mk01ps.ino
2 x Moteino R2 (RFM12B)
1 x SparkFun OpenLog
1 x microSD Card - 16GB
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
2 x Lithium Ion Battery - 1Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Sleep
#include <avr/sleep.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Includes and variables for IMU integration
// Accelerometer
#include <ADXL345.h>
// Magnetometer
#include <HMC58X3.h>
// MEMS Gyroscope
#include <ITG3200.h>
// Debug
#include "DebugUtils.h"
// FreeIMU
#include <CommunicationUtils.h>
#include <FreeIMU.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        2
// The network ID we are on
#define NETWORKID    99
// The node ID we're sending to
#define GATEWAYID     1
// # of ms to wait for an ack
#define ACK_TIME     50
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Wait this many ms between sending packets
int interPacketDelay = 1000;
// Input
char input = 0;

// Need an instance of the RFM12B Radio Module
RFM12B radio;
// Send Size
byte sendSize = 0;
// Payload
char payload[100];
// Request ACK
bool requestACK = false;

// LED
int iLED = 9;

// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();

// Yaw Pitch Roll
String zzzzzz = "";
String sYaw = "";
String sPitch = "";
String sRoll = "";
float ypr[3];
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// Software Version Information
String sver = "26-06";

void loop()
{

  // isFreeIMU
  isFreeIMU();

  // is RFM12B Radio
  isRFM12BRadio();

  // Inter Packet Delay
  delay(interPacketDelay);
  
}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // Yaw Pitch Roll
  my3IMU.getYawPitchRoll(ypr);
  // Yaw
  Yaw = ypr[0];
  // Pitch
  Pitch = ypr[1];
  // Roll
  Roll = ypr[2];

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio(){

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Sleep right away to save power
  radio.Sleep();
  // Transmitting
  Serial.println("Transmitting...\n\n");
  
}
// is RFM12 BRadio
void isRFM12BRadio(){

  // sYaw, sPitch, sRoll ""
  sYaw = "";
  sPitch = "";
  sRoll = "";

  // sYaw, sPitch, sRoll concat
  sYaw.concat(Yaw);
  sPitch.concat(Pitch);
  sRoll.concat(Roll);

  // zzzzzz ""
  zzzzzz = "";

  // zzzzzz = "<IMU|1000|1000|1000|*";
  // zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*"
  zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*";

  // sendSize Length
  sendSize = zzzzzz.length();

  // sendSize
  payload[sendSize];

  // sendSize, charAt
  for(byte i = 0; i < sendSize+1; i++){

    payload[i] = zzzzzz.charAt(i);
    
  }
    
  // payload
  Serial.print(payload);
  
  // Request ACK
  requestACK = sendSize;
  
  // Wakeup
  radio.Wakeup();
  
  // Turn the LED on HIGH
  digitalWrite( iLED , HIGH);
  
  // Send
  radio.Send(GATEWAYID, payload, sendSize, requestACK);

  // Request ACK
  if (requestACK)
  {
    
    Serial.print(" - waiting for ACK...");
    if (waitForAck()){
      
      Serial.print("Ok!");
      
    }
    else Serial.print("nothing...");
    
  }

  // Turn the LED on LOW
  digitalWrite( iLED , LOW);

  // Sleep
  radio.Sleep();

  // Serial
  Serial.println();
  
}
// Wait a few milliseconds for proper ACK, return true if received
static bool waitForAck(){
  
  // Now
  long now = millis();

  // ACK
  while (millis() - now <= ACK_TIME){
    

    if (radio.ACKReceived(GATEWAYID)){
      
      return true;

    }

  }
  
  return false;
  
}

setup.ino

// Setup
void setup(){

  // Serial
  Serial.begin(SERIAL_BAUD);

  // LED
  pinMode( iLED , OUTPUT);

  // Set up I2C bus
  Wire.begin();

  // RFM12B Radio
  isSetupRFM12BRadio();

  // Pause
  delay(5);
  // Initialize IMU
  my3IMU.init();
  // Pause
  delay(5);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • Programming Language
  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #26 – Radio Frequency – Display – Mk05

——

#DonLucElectronics #DonLuc #RadioFrequency #Moteino #Send #Receive #Display #FreeIMU #Magnetometer #Accelerometer #Gyroscope #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Display

——

Display

——

Display

——

SparkFun Micro OLED Breakout

The SparkFun Qwiic Micro OLED Breakout is a Qwiic-enabled version of our popular Micro OLED display. The small monochrome, blue-on-black OLED screen presents incredibly clear images for your viewing pleasure. It’s the OLED display is crisp, and you can fit a deceivingly large amount of graphics on there. This breakout is perfect for adding graphics to your next project and displaying diagnostic information without resorting to a serial output, all with the ease of use of our own Qwiic Connect System.

This version of the Micro OLED Breakout is exactly the size of its non-Qwiic sibling, featuring a screen that is 64 pixels wide and 48 pixels tall and measuring 0.66″ across. But it has also been equipped with two Qwiic connectors, making it ideal for I2C operations. We’ve also added two mounting holes and a convenient Qwiic cable holder incorporated into a detachable tab on the board that can be easily removed thanks to a v-scored edge.

DL2211Mk09

2 x Moteino R2 (RFM12B)
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom – Sensor Stick
2 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

Moteino R2 (Receive)

TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2211Mk09pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Display - Mk05
26-05
Receive
DL2211Mk09pr.ino
2 x Moteino R2 (RFM12B)
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
2 x Lithium Ion Battery - 1Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun Micro OLED
#include <SFE_MicroOLED.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        1
// The network ID we are on
#define NETWORKID    99
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Need an instance of the RFM12B Radio Module
RFM12B radio;

// Process Message
// Message
String msg = "";
int firstClosingBracket = 0;
// Yaw Pitch Roll
String sYaw = "";
String sPitch = "";
String sRoll = "";
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// LED
int iLED = 9;

// SparkFun Micro OLED
#define PIN_RESET 9
#define DC_JUMPER 1
// I2C declaration
MicroOLED oled(PIN_RESET, DC_JUMPER);

// Software Version Information
String sver = "26-05";

void loop() {

  // is RFM12B Radio
  isRFM12BRadio();

  // Micro OLED
  isMicroOLED();

}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // IMU Yaw Pitch Roll
  // msg = "<IMU|1000|1000|1000|*";
  // msg = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*"
  firstClosingBracket = 0;
  // "<IMU|"
  firstClosingBracket = msg.indexOf('|');
  msg.remove(0, 5);
  // Yaw
  firstClosingBracket = msg.indexOf('|');
  sYaw = msg;
  sYaw.remove(firstClosingBracket);
  Yaw = sYaw.toFloat();
  // Pitch
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  sPitch = msg;
  sPitch.remove(firstClosingBracket);
  Pitch = sPitch.toFloat();
  // Roll
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  sRoll = msg;
  sRoll.remove(firstClosingBracket);
  Roll = sRoll.toFloat();

}

getMicroOLED.ino

// SparkFun Micro OLED
// Setup Micro OLED
void isSetupMicroOLED() {

  // Initialize the OLED
  oled.begin();
  // Clear the display's internal memory
  oled.clear(ALL);
  // Display what's in the buffer (splashscreen)
  oled.display();

  // Delay 1000 ms
  delay(1000);

  // Clear the buffer.
  oled.clear(PAGE);
  
}
// Micro OLED
void isMicroOLED() {

  // Text Display FreeIMU
  // Clear the display
  oled.clear(PAGE);
  // Set cursor to top-left
  oled.setCursor(0, 0);
  // Set font to type 0
  oled.setFontType(0);
  // FreeIMU
  oled.print("FreeIMU");
  oled.setCursor(0, 12);
  // Yaw
  oled.print("Y: ");
  oled.print(Yaw);
  oled.setCursor(0, 25);
  // Pitch
  oled.print("P: ");
  oled.print(Pitch);
  oled.setCursor(0, 39);
  // Roll
  oled.print("R: ");
  oled.print(Roll);
  oled.display();

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio()
{

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Transmitting
  Serial.println("Listening...");
  
}
// is RFM12 BRadio
void isRFM12BRadio()
{

  // Receive
  if (radio.ReceiveComplete())
  {
    
    // CRC Pass
    if (radio.CRCPass())
    {
      
      // Serial
      Serial.print('[');
      Serial.print(radio.GetSender());
      Serial.print("] ");
      
      // Message
      msg = "";
      
      // Can also use radio.GetDataLen() if you don't like pointers
      for (byte i = 0; i < *radio.DataLen; i++)
      {
        
        Serial.print((char)radio.Data[i]);
        msg = msg + (char)radio.Data[i];
        
      }

      // Turn the LED on HIGH
      digitalWrite( iLED , HIGH);
      
      // FreeIMU
      // Yaw Pitch Roll
      isFreeIMU();
  
      // ACK Requested
      if (radio.ACKRequested())
      {
        
        // Send ACK
        radio.SendACK();
        Serial.print(" - ACK Sent");
        
      }

      // Turn the LED on LOW
      digitalWrite( iLED , LOW);
    
    }
    else
    {
      
      // BAD-CRC
      Serial.print("BAD-CRC");

    }

    // Serial
    Serial.println();

  } 
  
}

setup.ino

// Setup
void setup()
{

  // Serial
  Serial.begin(SERIAL_BAUD);

  // Give display time to power on
  delay(100);
  
  // Set up I2C bus
  Wire.begin();

  // Setup Micro OLED
  isSetupMicroOLED();

  // LED
  pinMode( iLED , OUTPUT);

  // RFM12B Radio
  isSetupRFM12BRadio();

}

——

Moteino R2 (Send)

TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2211Mk09ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Display - Mk05
26-05
Send
DL2211Mk09ps.ino
2 x Moteino R2 (RFM12B)
1 x SparkFun Micro OLED Breakout (Qwiic)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
2 x Lithium Ion Battery - 1Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Sleep
#include <avr/sleep.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Includes and variables for IMU integration
// Accelerometer
#include <ADXL345.h>
// Magnetometer
#include <HMC58X3.h>
// MEMS Gyroscope
#include <ITG3200.h>
// Debug
#include "DebugUtils.h"
// FreeIMU
#include <CommunicationUtils.h>
#include <FreeIMU.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        2
// The network ID we are on
#define NETWORKID    99
// The node ID we're sending to
#define GATEWAYID     1
// # of ms to wait for an ack
#define ACK_TIME     50
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Wait this many ms between sending packets
int interPacketDelay = 1000;
// Input
char input = 0;

// Need an instance of the RFM12B Radio Module
RFM12B radio;
// Send Size
byte sendSize = 0;
// Payload
char payload[100];
// Request ACK
bool requestACK = false;

// LED
int iLED = 9;

// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();

// Yaw Pitch Roll
String zzzzzz = "";
String sYaw = "";
String sPitch = "";
String sRoll = "";
float ypr[3];
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// Software Version Information
String sver = "26-05";

void loop()
{

  // isFreeIMU
  isFreeIMU();

  // is RFM12B Radio
  isRFM12BRadio();

  // Inter Packet Delay
  delay(interPacketDelay);
  
}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // Yaw Pitch Roll
  my3IMU.getYawPitchRoll(ypr);
  // Yaw
  Yaw = ypr[0];
  // Pitch
  Pitch = ypr[1];
  // Roll
  Roll = ypr[2];

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio(){

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Sleep right away to save power
  radio.Sleep();
  // Transmitting
  Serial.println("Transmitting...\n\n");
  
}
// is RFM12 BRadio
void isRFM12BRadio(){

  // sYaw, sPitch, sRoll ""
  sYaw = "";
  sPitch = "";
  sRoll = "";

  // sYaw, sPitch, sRoll concat
  sYaw.concat(Yaw);
  sPitch.concat(Pitch);
  sRoll.concat(Roll);

  // zzzzzz ""
  zzzzzz = "";

  // zzzzzz = "<IMU|1000|1000|1000|*";
  // zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*"
  zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*";

  // sendSize Length
  sendSize = zzzzzz.length();

  // sendSize
  payload[sendSize];

  // sendSize, charAt
  for(byte i = 0; i < sendSize+1; i++){

    payload[i] = zzzzzz.charAt(i);
    
  }
    
  // payload
  Serial.print(payload);
  
  // Request ACK
  requestACK = sendSize;
  
  // Wakeup
  radio.Wakeup();
  
  // Turn the LED on HIGH
  digitalWrite( iLED , HIGH);
  
  // Send
  radio.Send(GATEWAYID, payload, sendSize, requestACK);

  // Request ACK
  if (requestACK)
  {
    
    Serial.print(" - waiting for ACK...");
    if (waitForAck()){
      
      Serial.print("Ok!");
      
    }
    else Serial.print("nothing...");
    
  }

  // Turn the LED on LOW
  digitalWrite( iLED , LOW);

  // Sleep
  radio.Sleep();

  // Serial
  Serial.println();
  
}
// Wait a few milliseconds for proper ACK, return true if received
static bool waitForAck(){
  
  // Now
  long now = millis();

  // ACK
  while (millis() - now <= ACK_TIME){
    

    if (radio.ACKReceived(GATEWAYID)){
      
      return true;

    }

  }
  
  return false;
  
}

setup.ino

// Setup
void setup(){

  // Serial
  Serial.begin(SERIAL_BAUD);

  // LED
  pinMode( iLED , OUTPUT);

  // Set up I2C bus
  Wire.begin();

  // RFM12B Radio
  isSetupRFM12BRadio();

  // Pause
  delay(5);
  // Initialize IMU
  my3IMU.init();
  // Pause
  delay(5);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #26 – Radio Frequency – FreeIMU – Mk04

——

#DonLucElectronics #DonLuc #RadioFrequency #Moteino #Send #Receive #FreeIMU #Magnetometer #Accelerometer #Gyroscope #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

FreeIMU

——

FreeIMU

——

FreeIMU

——

FreeIMU

Orientation and Motion Sensing are widely implemented on various consumer products, such as mobile phones, tablets and cameras as they enable immediate interaction with virtual information. The prototyping phase of any orientation and motion sensing capable device is however a quite difficult process as it may involve complex hardware designing, math algorithms and programming. FreeIMU, an Open Hardware Framework for prototyping orientation and motion sensing capable devices. The framework consists in a small circuit board containing various sensors and a software library, built on top of the Arduino platform. Both the hardware and library are released under open licences and supported by an active community allowing to be implemented into research and commercial projects.

DL2211Mk08

2 x Moteino R2 (RFM12B)
1 x SparkFun 9 Degrees of Freedom – Sensor Stick
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun FTDI Basic Breakout – 5V
1 x SparkFun Cerberus USB Cable

Moteino R2 (Receive)

TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
VIN – +3.3V
GND – GND

——

DL2211Mk08pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - FreeIMU - Mk04
26-04
Receive
DL2211Mk08pr.ino
2 x Moteino R2 (RFM12B)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
1 x Lithium Ion Battery - 1Ah
1 x SparkFun FTDI Basic Breakout - 5V
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        1
// The network ID we are on
#define NETWORKID    99
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Need an instance of the RFM12B Radio Module
RFM12B radio;

// LED
int iLED = 9;

// Software Version Information
String sver = "26-04";

void loop() {

  // is RFM12B Radio
  isRFM12BRadio();

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio()
{

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Transmitting
  Serial.println("Listening...");
  
}
// is RFM12 BRadio
void isRFM12BRadio()
{

  // Receive
  if (radio.ReceiveComplete())
  {
    
    // CRC Pass
    if (radio.CRCPass())
    {
      
      // Serial
      Serial.print('[');
      Serial.print(radio.GetSender());
      Serial.print("] ");
      // Can also use radio.GetDataLen() if you don't like pointers
      for (byte i = 0; i < *radio.DataLen; i++)
      {
        
        Serial.print((char)radio.Data[i]);
        
      }

      // Turn the LED on HIGH
      digitalWrite( iLED , HIGH);
  
      // ACK Requested
      if (radio.ACKRequested())
      {
        
        // Send ACK
        radio.SendACK();
        Serial.print(" - ACK Sent");
        
      }

      // Turn the LED on LOW
      digitalWrite( iLED , LOW);
    
    }
    else
    {
      
      // BAD-CRC
      Serial.print("BAD-CRC");

    }

    // Serial
    Serial.println();

  } 
  
}

setup.ino

// Setup
void setup()
{

  // Serial
  Serial.begin(SERIAL_BAUD);

  // LED
  pinMode( iLED , OUTPUT);

  // RFM12B Radio
  isSetupRFM12BRadio();

}

Moteino R2 (Send)

TR0 – Digital 2
LED – Digital 9
TR1 – Digital 10
TR2 – Digital 11
TR3 – Digital 12
TR4 – Digital 13
SDA – Analog A4
SCL – Analog A5
VIN – +3.3V
GND – GND

——

DL2211Mk08ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - FreeIMU - Mk04
26-04
Send
DL2211Mk08ps.ino
2 x Moteino R2 (RFM12B)
1 x SparkFun 9 Degrees of Freedom - Sensor Stick
1 x Lithium Ion Battery - 1Ah
1 x SparkFun FTDI Basic Breakout - 5V
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// RFM12B Radio
#include <RFM12B.h>
// Sleep
#include <avr/sleep.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Includes and variables for IMU integration
// Accelerometer
#include <ADXL345.h>
// Magnetometer
#include <HMC58X3.h>
// MEMS Gyroscope
#include <ITG3200.h>
// Debug
#include "DebugUtils.h"
// FreeIMU
#include <CommunicationUtils.h>
#include <FreeIMU.h>

// You will need to initialize the radio by telling it what ID
// it has and what network it's on
// The NodeID takes values from 1-127, 0 is reserved for sending 
// broadcast messages (send to all nodes)
// The Network ID takes values from 0-255
// By default the SPI-SS line used is D10 on Atmega328. 
// You can change it by calling .SetCS(pin) where pin can be {8,9,10}
// Network ID used for this unit
#define NODEID        2
// The network ID we are on
#define NETWORKID    99
// The node ID we're sending to
#define GATEWAYID     1
// # of ms to wait for an ack
#define ACK_TIME     50
// Serial
#define SERIAL_BAUD  115200

// Encryption is OPTIONAL
// to enable encryption you will need to:
// - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
// - to call .Encrypt(KEY) to start encrypting
// - to stop encrypting call .Encrypt(NULL)
uint8_t KEY[] = "ABCDABCDABCDABCD";

// Wait this many ms between sending packets
int interPacketDelay = 1000;
// Input
char input = 0;

// Need an instance of the RFM12B Radio Module
RFM12B radio;
// Send Size
byte sendSize = 0;
// Payload
char payload[100];
// Request ACK
bool requestACK = false;

// LED
int iLED = 9;

// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();

// Yaw Pitch Roll
String zzzzzz = "";
String sYaw = "";
String sPitch = "";
String sRoll = "";
float ypr[3];
float Yaw = 0;
float Pitch = 0;
float Roll = 0;

// Software Version Information
String sver = "26-04";

void loop()
{

  // isFreeIMU
  isFreeIMU();

  // is RFM12B Radio
  isRFM12BRadio();

  // Inter Packet Delay
  delay(interPacketDelay);
  
}

getFreeIMU.ino

// FreeIMU
// isFreeIMU
void isFreeIMU(){

  // FreeIMU
  // Yaw Pitch Roll
  my3IMU.getYawPitchRoll(ypr);
  // Yaw
  Yaw = ypr[0];
  // Pitch
  Pitch = ypr[1];
  // Roll
  Roll = ypr[2];

}

getRFM12BRadio.ino

// RFM12B Radio
void isSetupRFM12BRadio(){

  // RFM12B Radio
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  // Encryption
  radio.Encrypt(KEY);
  // Sleep right away to save power
  radio.Sleep();
  // Transmitting
  Serial.println("Transmitting...\n\n");
  
}
// is RFM12 BRadio
void isRFM12BRadio(){

  // sYaw, sPitch, sRoll ""
  sYaw = "";
  sPitch = "";
  sRoll = "";

  // sYaw, sPitch, sRoll concat
  sYaw.concat(Yaw);
  sPitch.concat(Pitch);
  sRoll.concat(Roll);

  // zzzzzz ""
  zzzzzz = "";

  // zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*"
  zzzzzz = "<IMU|" + sYaw + "|" + sPitch + "|" + sRoll + "|*";

  // sendSize Length
  sendSize = zzzzzz.length();

  // sendSize
  payload[sendSize];

  // sendSize, charAt
  for(byte i = 0; i < sendSize+1; i++){

    payload[i] = zzzzzz.charAt(i);
    
  }
    
  // payload
  Serial.print(payload);
  
  // Request ACK
  requestACK = sendSize;
  
  // Wakeup
  radio.Wakeup();
  
  // Turn the LED on HIGH
  digitalWrite( iLED , HIGH);
  
  // Send
  radio.Send(GATEWAYID, payload, sendSize, requestACK);

  // Request ACK
  if (requestACK)
  {
    
    Serial.print(" - waiting for ACK...");
    if (waitForAck()){
      
      Serial.print("Ok!");
      
    }
    else Serial.print("nothing...");
    
  }

  // Turn the LED on LOW
  digitalWrite( iLED , LOW);

  // Sleep
  radio.Sleep();

  // Serial
  Serial.println();
  
}
// Wait a few milliseconds for proper ACK, return true if received
static bool waitForAck(){
  
  // Now
  long now = millis();

  // ACK
  while (millis() - now <= ACK_TIME){
    

    if (radio.ACKReceived(GATEWAYID)){
      
      return true;

    }

  }
  
  return false;
  
}

setup.ino

// Setup
void setup(){

  // Serial
  Serial.begin(SERIAL_BAUD);

  // LED
  pinMode( iLED , OUTPUT);

  // Set up I2C bus
  Wire.begin();

  // RFM12B Radio
  isSetupRFM12BRadio();

  // Pause
  delay(5);
  // Initialize IMU
  my3IMU.init();
  // Pause
  delay(5);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

Luc Paquin – Curriculum Vitae – 2023
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #24 – RTOS – Bluetooth – Mk03

——

#DonLucElectronics #DonLuc #ESP32 #RTOS #FreeRTOS #Bluetooth #ThumbJoystick #Keyboard #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth

——

Bluetooth

——

Bluetooth

——

Joystick

A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. Joysticks are often used to control video games, and usually have one or more push-buttons whose state can also be read by the computer. A popular variation of the joystick used on modern video game consoles is the analog stick. Joysticks are also used for controlling machines such as cranes, trucks, underwater unmanned vehicles, wheelchairs, surveillance cameras, and zero turning radius lawn mowers. This is a joystick very similar to the analog joysticks on PS2 controllers. Directional movements are simply two potentiometers, one for each axis. Pots are 10k Ohm each. This joystick also has a select button that is actuated when the joystick is pressed down.

DL2210Mk04

1 x Adafruit HUZZAH32 – ESP32 Feather
1 x Lithium Ion Battery – 2500mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x SparkFun Cerberus USB Cable

ESP32 Feather

JY0 – Analog A0
JY1 – Analog A5
SE0 – Digital 12
LED – Digital 13
VIN – +3.3V
GND – GND

——

DL2210Mk04p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #24 - RTOS - Bluetooth - Mk03
24-03
DL2210Mk04p.ino
1 x Adafruit HUZZAH32 – ESP32 Feather
1 x Lithium Ion Battery - 2500mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// FreeRTOS ESP32
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
// ESP32 BLE Keyboard
#include <BleKeyboard.h>

// ESP32 BLE Keyboard
BleKeyboard bleKeyboard;

// Connections to joystick
// Vertical
const int VERT = A0;
// Horizontal
const int HORIZ = A5;
// Pushbutton
const int SEL = 12;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int selec;

// Led Built In
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif

// Define two tasks for Blink
void isTaskBlink( void *pvParameters );

// Software Version Information
String sver = "24-03";

void loop() {

  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Thumb Joystick
    isThumbJoystick();

  }

  // Delay
  delay( 1000 );
  
}

getTasks.ino

// Tasks
// Setup Task
void isSetupTask(){

  // Now set up two tasks to run independently
  // TaskBlink
  xTaskCreatePinnedToCore(
    isTaskBlink
    ,  "TaskBlink"   // A name just for humans
    ,  1024  // This stack size can be checked & adjusted by reading.
    ,  NULL
    ,  2  // Priority, with 2 being the highest, and 0 being the lowest.
    ,  NULL 
    ,  ARDUINO_RUNNING_CORE);

  // Now the task scheduler, which takes over control of scheduling individual tasks,
  // is automatically started.
  
}
// This is a Task Blink
void isTaskBlink(void *pvParameters)
{
  
  (void) pvParameters;

  // Blink
  // Turns on an LED on for 2 second, then off for 2 second, repeatedly

  // Initialize digital LED_BUILTIN on pin 13 as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  // A Task shall never return or exit
  for (;;) 
  {
    
    // Turn the LED on (HIGH is the voltage level)
    digitalWrite(LED_BUILTIN, HIGH);
    // One tick delay in between reads
    vTaskDelay(2000);
    // Turn the LED off by making the voltage LOW
    digitalWrite(LED_BUILTIN, LOW);
    // One tick delay in between reads
    vTaskDelay(2000);
    
  }
  
}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 2047 for the vertical and horizontal values
  // Will be 0-4095
  // Vertical
  vertical = analogRead(VERT);
  if (vertical == 4095) {

    // Volume Up
    bleKeyboard.write(KEY_MEDIA_VOLUME_UP);
    
  } else if (vertical == 0) {

    // Volume Down
    bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN);
    
  }
  // Horizontal
  // Will be 0-4095
  horizontal = analogRead(HORIZ);
  if (horizontal == 4095) {

    // Previous Track
    bleKeyboard.write(KEY_MEDIA_PREVIOUS_TRACK);
    
  } else if (horizontal == 0) {

    // Next Track
    bleKeyboard.write(KEY_MEDIA_NEXT_TRACK);
    
  }
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  selec = digitalRead(SEL);
  if (selec == 0) {

    // Play/Pause media key
    bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
    
  }

}

setup.ino

// Setup
void setup() {

  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);

  // ESP32 BLE Keyboard
  bleKeyboard.begin();

  // Setup Task
  isSetupTask();
  
}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #23: E-Textiles – Coin Cell Battery – Mk08

——

#DonLucElectronics #DonLuc #ETextiles #Wearable #FLORA #BME280 #CCS811 #CoinCell #RTC #SD #Arduino #Project #Programming #Electronics #Microcontrollers #Consultant

——

Coin Cell Battery

——

Coin Cell Battery

——

Coin Cell Battery

——

Coin Cell Battery Holder – 2 x CR2032 (Enclosed)

This is a simple coin cell battery holder that can enclose two CR2032 batteries inside itself, and safely kept closed via two phillips head screws. Each battery holder will run batteries in series, output up to 6V, and is equipped with an On/Off slide switch and two 6″ power wires (one positive and one negative) on the back.

DL2205Mk03

1 x FLORA – Version 1.0a
1 x SparkFun Environmental Combo CCS811/BME280
1 x DS3231 Precision RTC FeatherWing
1 x MicroSD card breakout board+
1 x MicroSD card 8 Gb
1 x CR1220 Coin Cell Battery
1 x LED Red
1 x 220 Ohm
1 x Coin Cell Battery Holder – 2 x CR2032
2 x CR2032 Coin Cell Battery
1 x SparkFun Cerberus USB Cable

FLORA – Version 1.0a

CLK – ICSP 3
DO – ICSP 1
DI – ICSP 4
CS – Digital 10
LER – Digital 6
SCL – Digital 3
SDA – Digital 2
VIN – +5V
VIN – +3.3V
GND – GND

——

DL2205Mk03p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #23: E-Textiles - Coin Cell Battery - Mk08
23-08
DL2205Mk03p.ino
1 x FLORA - Version 1.0a
1 x SparkFun Environmental Combo CCS811/BME280
1 x DS3231 Precision RTC FeatherWing
1 x MicroSD card breakout board+
1 x MicroSD card 8 Gb
1 x CR1220 Coin Cell Battery
1 x LED Red
1 x 220 Ohm
1 x Coin Cell Battery Holder - 2 x CR2032
2 x CR2032 Coin Cell Battery
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Wire
#include <Wire.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// Date and time DS3231 RTC
#include <RTClib.h>
// Serial Peripheral Interface (SPI)
#include <SPI.h>
// Secure Digital (SD Card)
#include <SD.h>

// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
BME280 myBME280;
// Temperature Celsius
float BMEtempC = 0;
// Humidity
float BMEhumid = 0;
// Altitude Meters
float BMEaltitudeM = 0;
// Barometric Pressure
float BMEpressure = 0;

// SparkFun CCS811 - eCO2 & tVOC
// Default I2C Address
#define CCS811_ADDR 0x5B 
CCS811 myCCS811(CCS811_ADDR);
// eCO2
float CCS811CO2 = 0;
// TVOC
float CCS811TVOC = 0;

// Date and time functions using a DS3231 RTC
RTC_DS3231 RTC;
String sDate;
String sTime;

// Secure Digital (SD Card)
const int chipSelect = 10;
String zzzzzz = "";

// LED Red
const int iLEDR = 6;

// Software Version Information
String sver = "23-08";

void loop() {

  // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
  isBME280();

  // SparkFun CCS811 - eCO2 & tVOC
  isCCS811();

  // Dates and Time
  timeRTC();

  // MicroSD Card
  isSD();

  // 1 Seconds
  delay( 1000 );

}

getBME280.ino

// SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
// isBME280 - Temperature, Humidity, Altitude and Barometric Pressure
void isBME280(){

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity() ;
  // Altitude Meters
  BMEaltitudeM = myBME280.readFloatAltitudeMeters();
  // Barometric Pressure
  BMEpressure = myBME280.readFloatPressure();
  
}

getCCS811.ino

// CCS811 - eCO2 & tVOC
// isCCS811 - eCO2 & tVOC
void isCCS811(){

  // This sends the temperature & humidity data to the CCS811
  myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);

  // Calling this function updates the global tVOC and eCO2 variables
  myCCS811.readAlgorithmResults();

  // eCO2 Concentration
  CCS811CO2 = myCCS811.getCO2();
  
  // tVOC Concentration
  CCS811TVOC = myCCS811.getTVOC();
  
}

getRTCDS3231.ino

// DS3231 Precision RTC
// Setup RTC
void setupRTC() {

  // DS3231 Precision RTC   
  RTC.begin();
  if (! RTC.begin()) {
    
    while (1);
    
  }
  
  DateTime now = RTC.now();

  if (RTC.lostPower()) {
    
    // Following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // August 2, 2021 at 13:53:0 you would call:
    // RTC.adjust(DateTime(2022, 4, 26, 11, 39, 0));
    
  }
  
}
// timeRTC
void timeRTC() {

    // DS3231 Precision RTC
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = RTC.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);
  
    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);

}

getSD.ino

// MicroSD Card
// MicroSD Setup
void setupSD() {

    // MicroSD Card
   // See if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {

    // Don't do anything more:
    while (1);
    
  }

}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  // Version|Date|Time|Temperature Celsius|Humidity|Altitude Meters|Barometric Pressure
  //|eCO2 Concentration|tVOC Concentration|
  zzzzzz = sver + "|" + sDate + "|" + sTime + "|" 
  + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|"
  + CCS811CO2 + "|" + CCS811TVOC + "|";

  // Open the file. Note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("DLE22Log.txt", FILE_WRITE);

  // If the file is available, write to it:
  if (dataFile) {
    
    // Write
    dataFile.println( zzzzzz );
    dataFile.close();

  }

}

setup.ino

// Setup
void setup() {

  // Delay
  delay( 100 );
  
  // Set up I2C bus
  Wire.begin();

  // Delay
  delay( 50 );

  // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Setup RTC
  setupRTC();

  //MicroSD Card
  setupSD();

  // LED Red
  pinMode( iLEDR , OUTPUT);
  // Turn the LED Red on HIGH
  digitalWrite( iLEDR , HIGH);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Categories
Archives