Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inter-micro
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Environment Agency
inter-micro
Commits
b504883b
Commit
b504883b
authored
Nov 02, 2016
by
Patrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call RP.begin before Serial.begin, plus intro comment texts
parent
9ac8e8d5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
101 deletions
+82
-101
red_peg/examples/b_temp_mon/b_temp_mon.ino~
red_peg/examples/b_temp_mon/b_temp_mon.ino~
+0
-66
red_peg/examples/c_sensor_blink/c_sensor_blink.ino
red_peg/examples/c_sensor_blink/c_sensor_blink.ino
+9
-4
red_peg/examples/rp_ma4_20/rp_ma4_20.ino
red_peg/examples/rp_ma4_20/rp_ma4_20.ino
+11
-5
red_peg/examples/rp_maxbotix/rp_maxbotix.ino
red_peg/examples/rp_maxbotix/rp_maxbotix.ino
+7
-11
red_peg/examples/rp_rtc_ds1307/rp_rtc_ds1307.ino
red_peg/examples/rp_rtc_ds1307/rp_rtc_ds1307.ino
+9
-4
red_peg/examples/rp_sd_logger/rp_sd_logger.ino
red_peg/examples/rp_sd_logger/rp_sd_logger.ino
+11
-5
red_peg/examples/rp_sensor_active/rp_sensor_active.ino
red_peg/examples/rp_sensor_active/rp_sensor_active.ino
+14
-5
red_peg/examples/rp_temp_mon/rp_temp_mon.ino
red_peg/examples/rp_temp_mon/rp_temp_mon.ino
+9
-1
red_peg/examples/set_the_time/set_the_time.ino
red_peg/examples/set_the_time/set_the_time.ino
+12
-0
No files found.
red_peg/examples/b_temp_mon/b_temp_mon.ino~
deleted
100644 → 0
View file @
9ac8e8d5
#include <Wire.h>
#include <MCP342x.h>
/*
Read a TMP36 sensor from MCP3428, channel 3
*/
#define BAUD 115200
// 0x68 is the default address for all MCP342x devices
// on Red-Peg, the MCP3428 address is set to 0x6F
uint8_t address = 0x6F;
MCP342x adc = MCP342x(address);
void setup(void)
{
Serial.begin(BAUD);
Serial.println("starting temp_mon");
Wire.begin();
// Reset devices
MCP342x::generalCallReset();
delay(1); // MC342x needs 300us to settle, wait 1ms
// Check device present
Wire.requestFrom(address, (uint8_t)1);
if (!Wire.available()) {
Serial.print("No device found at address ");
Serial.println(address, HEX);
while (1)
;
} else {
Serial.println("MCP3248 found");
}
}
void loop(void)
{
long value = 0;
MCP342x::Config status;
// Initiate a conversion; convertAndRead() will wait until it can be read
uint8_t err = adc.convertAndRead(MCP342x::channel3, MCP342x::oneShot,
MCP342x::resolution16, MCP342x::gain1,
1000000, value, status);
if (err) {
Serial.print("Convert error: ");
Serial.println(err);
}
else {
float voltage = value * (2.0 / 32575.0);
float temp = (voltage-0.5) * 100;
Serial.print("Value: ");
Serial.print(value);
Serial.print(", ");
Serial.print(voltage);
Serial.print("V, ");
Serial.print(temp);
Serial.print(" degC");
Serial.println();
}
delay(1000);
}
red_peg/examples/c_sensor_blink/c_sensor_blink.ino
View file @
b504883b
/* sensor_blink
*
* toggle the sensor active pin on Red-Peg board,
* without using the red_peg library
*
*/
#define SENSOR_ACTIVE_PIN 6
#define BAUD 115200
// the setup function runs once when you press reset or power the board
void
setup
()
{
Serial
.
begin
(
BAUD
);
Serial
.
println
(
F
(
"start sensor_blink"
));
...
...
@@ -9,10 +15,9 @@ void setup() {
pinMode
(
SENSOR_ACTIVE_PIN
,
OUTPUT
);
}
// the loop function runs over and over again forever
void
loop
()
{
digitalWrite
(
SENSOR_ACTIVE_PIN
,
HIGH
);
delay
(
1000
);
// wait for a second
delay
(
1000
);
digitalWrite
(
SENSOR_ACTIVE_PIN
,
LOW
);
delay
(
1000
);
// wait for a second
delay
(
1000
);
}
red_peg/examples/rp_ma4_20/rp_ma4_20.ino
View file @
b504883b
/* rp_ma4_20
*
* Take readings from the 4–20mA sensor port and show the
* ADC reading, mA value and equivalent 0–7000mm level reading
*
*/
#include <red_peg.h>
red_peg
RP
;
void
setup
()
{
RP
.
begin
();
delay
(
100
);
Serial
.
begin
(
BAUD
);
Serial
.
println
(
"starting rp_ma4_20"
);
RP
.
begin
();
}
void
loop
()
{
...
...
@@ -13,7 +21,7 @@ void loop() {
delay
(
100
);
t_SensorData
depth
=
RP
.
get
(
MA4_20
);
RP
.
sensorsOff
();
if
(
depth
.
sensor
==
MA4_20
)
{
Serial
.
print
(
"Value: "
);
Serial
.
print
(
depth
.
reading
);
...
...
@@ -23,8 +31,6 @@ void loop() {
Serial
.
print
(
RP
.
level
(
depth
,
7000L
));
Serial
.
print
(
" mm"
);
Serial
.
println
();
}
else
{
Serial
.
println
(
"no return from ADC"
);
delay
(
1000
);
}
delay
(
1000
);
}
red_peg/examples/rp_maxbotix/rp_maxbotix.ino
View file @
b504883b
/*
/* rp_maxbotix
*
* Reading the MB 7060 sensor to give distance readings
*
* It is recommended to providing an external power supply
* as the maxbotix ultrasound sensors can draw more than
* the 0.5A that a USB port is able to supply
*
* Powering from USB only may lead to some crashes/restarts
* because of the current draw
*
*
*/
#include <red_peg.h>
red_peg
RP
;
void
setup
()
{
delay
(
2
000
);
delay
(
1
000
);
RP
.
begin
();
delay
(
100
);
Serial
.
begin
(
BAUD
);
Serial
.
println
(
"starting rp_maxbotix"
);
...
...
@@ -28,7 +24,7 @@ void loop() {
delay
(
500
);
t_SensorData
depth
=
RP
.
get
(
ANA
);
RP
.
sensorsOff
();
if
(
depth
.
sensor
==
ANA
)
{
RP
.
print_data
(
depth
);
Serial
.
print
(
"Value: "
);
...
...
red_peg/examples/rp_rtc_ds1307/rp_rtc_ds1307.ino
View file @
b504883b
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
/* rp_rtc_ds1307
*
* Read the date and time from the Red-Peg onboard RTC
* report over serial.
*
*/
#include <red_peg.h>
red_peg
RP
;
void
setup
()
{
Serial
.
begin
(
115200
);
Serial
.
println
(
F
(
"start rp_rtc_ds1307"
));
RP
.
begin
();
RP
.
sensorsOn
();
delay
(
100
);
Serial
.
begin
(
BAUD
);
Serial
.
println
(
F
(
"start rp_rtc_ds1307"
));
}
void
loop
()
{
...
...
@@ -29,7 +34,7 @@ void loop () {
Serial
.
print
(
"Z"
);
Serial
.
println
();
}
else
{
Serial
.
println
(
F
(
"no RTC message received.
\n
Last message is:"
));
Serial
.
println
(
F
(
"no RTC message received.
\
r\
n
Last message is:"
));
RP
.
print_data
(
the_time
);
}
delay
(
10000
);
...
...
red_peg/examples/rp_sd_logger/rp_sd_logger.ino
View file @
b504883b
/* rp_sd_logger
*
* Record the TMP36 sensor values to the Red-Peg shield onboard
* SD card under the file: readings.csv
*
*/
#include <SPI.h>
#include <SdFat.h>
SdFat
SD
;
...
...
@@ -7,10 +14,11 @@ red_peg RP;
void
setup
()
{
RP
.
begin
();
delay
(
100
);
// Open serial communications and wait for port to open:
Serial
.
begin
(
BAUD
);
Serial
.
println
(
"starting rp_sd_logger"
);
RP
.
begin
();
Serial
.
print
(
"Initializing SD card..."
);
pinMode
(
10
,
OUTPUT
);
...
...
@@ -54,10 +62,10 @@ void loop()
myFile
.
print
(
RP
.
degC
(
temp
));
// and a new line
myFile
.
println
();
// close the file:
myFile
.
close
();
// Then print what we sent to the Serial port
RP
.
print_data
(
temp
);
Serial
.
println
(
"done."
);
...
...
@@ -67,5 +75,3 @@ void loop()
}
}
}
red_peg/examples/rp_sensor_active/rp_sensor_active.ino
View file @
b504883b
/* rp_sensor_active
*
* toggles the sensor power and slave microcontroller
* on and off every second
* if you attach an LED + resistor across the
* 0–5V port, it will light when the port powers on
*/
#include <red_peg.h>
red_peg
RP
;
// the setup function runs once when you press reset or power the board
void
setup
()
{
RP
.
begin
();
delay
(
100
);
Serial
.
begin
(
BAUD
);
Serial
.
println
(
F
(
"start rp_sensor_active"
));
RP
.
begin
();
}
// the loop function runs over and over again forever
void
loop
()
{
RP
.
sensorsOn
();
delay
(
1000
);
// wait for a second
Serial
.
print
(
"ON..."
);
delay
(
1000
);
RP
.
sensorsOff
();
delay
(
1000
);
// wait for a second
Serial
.
println
(
"OFF"
);
delay
(
1000
);
}
red_peg/examples/rp_temp_mon/rp_temp_mon.ino
View file @
b504883b
/* rp_temp_mon
*
* Take a reading from a TMP36 sensor in the 0–2V port
* on the red peg board and report it to the Serial monitor
*
*/
#include <red_peg.h>
red_peg
RP
;
void
setup
()
{
Serial
.
begin
(
BAUD
);
RP
.
begin
();
RP
.
sensorsOn
();
delay
(
100
);
Serial
.
begin
(
BAUD
);
Serial
.
println
(
F
(
"start rp_temp_mon"
));
}
void
loop
()
{
...
...
red_peg/examples/set_the_time/set_the_time.ino
View file @
b504883b
/* set_the_time
*
* Helper sketch to set a custom time on a DS1307
* (such as the one on the Red-Peg board).
* Type the date and time into the serial monitor, in the
* format: T YYYY MM DD hh mm ss
* Will then report the current time every 10 seconds
*
* Requires the Adafruit RTClib library
*
*/
#include <Wire.h>
#include <RTClib.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment