Marvin: Difference between revisions
m (gateway link) |
(functional'ish code) |
||
| Line 5: | Line 5: | ||
Source code here: https://github.com/iotacademy/marvin | Source code here: https://github.com/iotacademy/marvin | ||
The device is a bare PCB with a USB on one end. Plugging this in to a computer shows up as a Arduino Leonardo and can be reprogrammed as such from the Arduino IDE. There is also a micro usb connection presumably | The device is a bare PCB with a USB on one end. Plugging this in to a computer shows up as a Arduino Leonardo and can be reprogrammed as such from the Arduino IDE. There is also a micro usb connection presumably duplicating the male PCB connector. | ||
== Docs == | |||
Note that this version varies from original kickstarter project, it uses the [https://www.microchip.com/wwwproducts/en/RN2903 Microchip RN2903] at 915 Mhz for US. | Note that this version varies from original kickstarter project, it uses the [https://www.microchip.com/wwwproducts/en/RN2903 Microchip RN2903] at 915 Mhz for US. | ||
Datasheet: http://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en578921 (available from digikey and others for < $15) | Datasheet: http://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en578921 (available from digikey and others for < $15) | ||
Command Refernce: http://ww1.microchip.com/downloads/en/DeviceDoc/40001811A.pdf | |||
== Pics == | |||
[[File:Marvin-PCB.jpg|800px]] | [[File:Marvin-PCB.jpg|800px]] | ||
[[File:Marvin-PCB-Back.jpg|800px]] | [[File:Marvin-PCB-Back.jpg|800px]] | ||
== Sketch == | |||
This is a basic sketch that allows for interaction over serial <code>sys ver</code> for example returns the firmware version. Connection can be made using arduino serial monitor or any serial terminal program with configuration set to 57,600bps 8N1, all messages must end with <CR> + <LF>. | |||
<pre> | |||
/* | |||
Marvin Hello | |||
VER: RN2903 0.9.8 Feb 14 2017 20:17:03 | |||
*/ | |||
// LoRa module params | |||
const int RESET_PORT = 5; | |||
const int POWER_PORT = 6; | |||
int sensorPin = A3; // select the input pin for the potentiometer | |||
int pirPin = 4; | |||
int ledA = 13; // select the pin for the LED | |||
int ledB = 11; | |||
int sensorValue = 0; // variable to store the value coming from the sensor | |||
unsigned long lastTime = 0; | |||
unsigned long nextTime = 1; | |||
void setup() { | |||
pinMode(ledA, OUTPUT); | |||
pinMode(ledB, OUTPUT); | |||
pinMode(pirPin, INPUT); | |||
// Virtual Serial thru USB connection | |||
Serial.begin(57600); | |||
// Leonardo UART to RN2903A module | |||
Serial1.begin(57600); | |||
// wait to init | |||
while (!Serial) { | |||
// twiddle thumbs here | |||
} | |||
// Enable power to the RN2483 | |||
pinMode(POWER_PORT, OUTPUT); | |||
digitalWrite(POWER_PORT, HIGH); | |||
Serial.println(">> Powering Module"); | |||
delay(1000); | |||
// Disable reset pin | |||
pinMode(RESET_PORT, OUTPUT); | |||
digitalWrite(RESET_PORT, HIGH); | |||
} | |||
void loop() { | |||
static bool blinkOn = false; | |||
// proxy data between USB/Serial & Module/Serial | |||
if (Serial1.available() > 0) | |||
Serial.write(Serial1.read()); | |||
if (Serial.available() > 0) | |||
Serial1.write(Serial.read()); | |||
// Turn on LED when there's motion | |||
digitalWrite(ledB, !digitalRead(pirPin)); | |||
// Serial.println(sensorValue); | |||
if (millis() >= nextTime) { | |||
// read the value from the sensor: | |||
sensorValue = analogRead(sensorPin); | |||
nextTime = millis() + sensorValue; | |||
if (!blinkOn) { | |||
digitalWrite(ledA, LOW); | |||
//analogWrite(ledA, int(sensorValue / 4)); | |||
} else { | |||
// analogWrite(ledA, 0); | |||
digitalWrite(ledA, HIGH); | |||
} | |||
blinkOn = !blinkOn; | |||
lastTime = millis(); | |||
} | |||
delay(20); | |||
} | |||
</pre> | |||
Revision as of 18:37, 8 January 2018
See also: MTCDT (Ethernet/LoRa gateway)
Some kind of LoRa device http://www.rdmmakerspace.nl/Marvin/
Source code here: https://github.com/iotacademy/marvin
The device is a bare PCB with a USB on one end. Plugging this in to a computer shows up as a Arduino Leonardo and can be reprogrammed as such from the Arduino IDE. There is also a micro usb connection presumably duplicating the male PCB connector.
Docs
Note that this version varies from original kickstarter project, it uses the Microchip RN2903 at 915 Mhz for US.
Datasheet: http://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en578921 (available from digikey and others for < $15)
Command Refernce: http://ww1.microchip.com/downloads/en/DeviceDoc/40001811A.pdf
Pics
Sketch
This is a basic sketch that allows for interaction over serial sys ver for example returns the firmware version. Connection can be made using arduino serial monitor or any serial terminal program with configuration set to 57,600bps 8N1, all messages must end with <CR> + <LF>.
/*
Marvin Hello
VER: RN2903 0.9.8 Feb 14 2017 20:17:03
*/
// LoRa module params
const int RESET_PORT = 5;
const int POWER_PORT = 6;
int sensorPin = A3; // select the input pin for the potentiometer
int pirPin = 4;
int ledA = 13; // select the pin for the LED
int ledB = 11;
int sensorValue = 0; // variable to store the value coming from the sensor
unsigned long lastTime = 0;
unsigned long nextTime = 1;
void setup() {
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(pirPin, INPUT);
// Virtual Serial thru USB connection
Serial.begin(57600);
// Leonardo UART to RN2903A module
Serial1.begin(57600);
// wait to init
while (!Serial) {
// twiddle thumbs here
}
// Enable power to the RN2483
pinMode(POWER_PORT, OUTPUT);
digitalWrite(POWER_PORT, HIGH);
Serial.println(">> Powering Module");
delay(1000);
// Disable reset pin
pinMode(RESET_PORT, OUTPUT);
digitalWrite(RESET_PORT, HIGH);
}
void loop() {
static bool blinkOn = false;
// proxy data between USB/Serial & Module/Serial
if (Serial1.available() > 0)
Serial.write(Serial1.read());
if (Serial.available() > 0)
Serial1.write(Serial.read());
// Turn on LED when there's motion
digitalWrite(ledB, !digitalRead(pirPin));
// Serial.println(sensorValue);
if (millis() >= nextTime) {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
nextTime = millis() + sensorValue;
if (!blinkOn) {
digitalWrite(ledA, LOW);
//analogWrite(ledA, int(sensorValue / 4));
} else {
// analogWrite(ledA, 0);
digitalWrite(ledA, HIGH);
}
blinkOn = !blinkOn;
lastTime = millis();
}
delay(20);
}