Cleanup hardware docs and mostly finalize the calibration jig software setup
This commit is contained in:
parent
18f5226415
commit
b3bf34d661
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 480 KiB |
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
# calibration_jig
|
||||||
|
|
||||||
|
An Arduino based build that allows testing and reading various sensors (used elsewhere) values for calibration prior to setup with the main dashboards and deployment.
|
|
@ -1,5 +1,6 @@
|
||||||
#include <FreeRTOS_SAMD21.h>
|
#include <FreeRTOS_SAMD21.h>
|
||||||
#include <semphr.h>
|
#include <semphr.h>
|
||||||
|
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
#include "Adafruit_GFX.h"
|
#include "Adafruit_GFX.h"
|
||||||
|
@ -7,13 +8,13 @@
|
||||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||||
#include <Fonts/FreeMonoBold18pt7b.h>
|
#include <Fonts/FreeMonoBold18pt7b.h>
|
||||||
#include <Fonts/FreeMono12pt7b.h>
|
#include <Fonts/FreeMono12pt7b.h>
|
||||||
//FreeMono18pt7b.h
|
|
||||||
//FreeMono24pt7b.h
|
// Various sensors used for calibration data reads
|
||||||
//FreeMono9pt7b.h
|
#include <Wire.h>
|
||||||
//FreeMonoBold12pt7b.h
|
#include <I2CSoilMoistureSensor.h>
|
||||||
//FreeMonoBold18pt7b.h
|
#include "Adafruit_seesaw.h"
|
||||||
//FreeMonoBold24pt7b.h
|
Adafruit_seesaw sensor_soil_adafruit;
|
||||||
//FreeMonoBold9pt7b.h
|
I2CSoilMoistureSensor sensor_soil_catnip;
|
||||||
|
|
||||||
// Various tunables
|
// Various tunables
|
||||||
#define ERROR_LED_PIN 13
|
#define ERROR_LED_PIN 13
|
||||||
|
@ -56,9 +57,11 @@ void TaskLCD(void *pvParameters);
|
||||||
|
|
||||||
// UI screens
|
// UI screens
|
||||||
void screenClear();
|
void screenClear();
|
||||||
void screenSoilStemma();
|
void screenI2CDIP(bool readValue);
|
||||||
void screenSoilCatnip();
|
void screenSoilStemma(bool readValue);
|
||||||
void screenWaterLevelETape();
|
void screenSoilCatnip(bool readValue);
|
||||||
|
void screenWaterLevelETape(bool readValue);
|
||||||
|
void screenWaterLevelETapeI2C(bool readValue);
|
||||||
|
|
||||||
// Color conversion (RGB888 -> RGB565 used by Adafruit GFX)
|
// Color conversion (RGB888 -> RGB565 used by Adafruit GFX)
|
||||||
uint16_t RGB565(uint8_t r, uint8_t g, uint8_t b) {
|
uint16_t RGB565(uint8_t r, uint8_t g, uint8_t b) {
|
||||||
|
@ -87,6 +90,9 @@ void setup() {
|
||||||
// ; // wait for serial port to connect. Needed for native USB, on LEONARDO, MICRO, YUN, and other 32u4 based boards.
|
// ; // wait for serial port to connect. Needed for native USB, on LEONARDO, MICRO, YUN, and other 32u4 based boards.
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
pinMode(A0, INPUT);
|
||||||
|
|
||||||
pixel.begin();
|
pixel.begin();
|
||||||
pixel.clear();
|
pixel.clear();
|
||||||
pixel.setBrightness(PIXEL_MAX_BRIGHTNESS);
|
pixel.setBrightness(PIXEL_MAX_BRIGHTNESS);
|
||||||
|
@ -162,7 +168,7 @@ void TaskBlink(void *pvParameters) {
|
||||||
void TaskLCD(void *pvParameters) {
|
void TaskLCD(void *pvParameters) {
|
||||||
(void) pvParameters;
|
(void) pvParameters;
|
||||||
|
|
||||||
void (*screens[3])() = {screenSoilStemma, screenSoilCatnip, screenWaterLevelETape};
|
void (*screens[5])(bool) = {screenI2CDIP, screenSoilStemma, screenSoilCatnip, screenWaterLevelETape, screenWaterLevelETapeI2C};
|
||||||
int current = 0;
|
int current = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -176,7 +182,7 @@ void TaskLCD(void *pvParameters) {
|
||||||
if (current >= sizeof(screens) / sizeof(screens[0])) {
|
if (current >= sizeof(screens) / sizeof(screens[0])) {
|
||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
screens[current]();
|
screens[current](false);
|
||||||
}
|
}
|
||||||
if (xSemaphoreTake(sem_btn_down, 50 / portTICK_PERIOD_MS) == pdPASS) {
|
if (xSemaphoreTake(sem_btn_down, 50 / portTICK_PERIOD_MS) == pdPASS) {
|
||||||
screenClear();
|
screenClear();
|
||||||
|
@ -188,13 +194,14 @@ void TaskLCD(void *pvParameters) {
|
||||||
if (current < 0) {
|
if (current < 0) {
|
||||||
current = sizeof(screens) / sizeof(screens[0]) - 1;
|
current = sizeof(screens) / sizeof(screens[0]) - 1;
|
||||||
}
|
}
|
||||||
screens[current]();
|
screens[current](false);
|
||||||
}
|
}
|
||||||
if (xSemaphoreTake(sem_btn_ok, 50 / portTICK_PERIOD_MS) == pdPASS) {
|
if (xSemaphoreTake(sem_btn_ok, 50 / portTICK_PERIOD_MS) == pdPASS) {
|
||||||
tft.fillRect(tft.width() - 50, 0, 50, 20, RGB565(0, 0, 0));
|
tft.fillRect(tft.width() - 50, 0, 50, 20, RGB565(0, 0, 0));
|
||||||
tft.setFont(&FreeMonoBold9pt7b);
|
tft.setFont(&FreeMonoBold9pt7b);
|
||||||
tft.setCursor(tft.width() - 50, 15);
|
tft.setCursor(tft.width() - 50, 15);
|
||||||
tft.print("OK");
|
tft.print("OK");
|
||||||
|
screens[current](true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +223,59 @@ void screenClear() {
|
||||||
tft.fillScreen(RGB565(0, 0, 0));
|
tft.fillScreen(RGB565(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenSoilStemma() {
|
void pixelDataReadAlert() {
|
||||||
|
pixel.setPixelColor(0, pixel.Color(0, 0, 255));
|
||||||
|
pixel.setBrightness(PIXEL_MAX_BRIGHTNESS);
|
||||||
|
pixel.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void screenI2CDIP(bool readValue) {
|
||||||
|
byte dip_1 = 0;
|
||||||
|
byte dip_2 = 0;
|
||||||
|
|
||||||
|
if (readValue) {
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
pixelDataReadAlert();
|
||||||
|
screenClear();
|
||||||
|
Wire.requestFrom(0x65, 2);
|
||||||
|
// Wait for data to become available -- can be a delayed response due to # of pins to enumerate
|
||||||
|
while (!Wire.available());
|
||||||
|
dip_1 = Wire.read();
|
||||||
|
dip_2 = Wire.read();
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.setFont(&FreeMonoBold18pt7b);
|
||||||
|
tft.setCursor(0, 25);
|
||||||
|
tft.println("DIP");
|
||||||
|
tft.setFont(&FreeMono12pt7b);
|
||||||
|
tft.println("i2c DIP switch");
|
||||||
|
tft.println("16 pin");
|
||||||
|
tft.println("i2c address: 0x65");
|
||||||
|
tft.println("");
|
||||||
|
tft.setFont(&FreeMonoBold9pt7b);
|
||||||
|
tft.println("--Press OK To Read Value--");
|
||||||
|
tft.println("");
|
||||||
|
tft.print("DIP 1: ");
|
||||||
|
tft.println(dip_1, BIN);
|
||||||
|
tft.print("DIP 2: ");
|
||||||
|
tft.println(dip_2, BIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void screenSoilStemma(bool readValue) {
|
||||||
|
float tempC = 0;
|
||||||
|
uint16_t capread = 0;
|
||||||
|
|
||||||
|
if (readValue) {
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
pixelDataReadAlert();
|
||||||
|
screenClear();
|
||||||
|
sensor_soil_adafruit.begin(0x36);
|
||||||
|
tempC = sensor_soil_adafruit.getTemp();
|
||||||
|
capread = sensor_soil_adafruit.touchRead(0);
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
tft.setFont(&FreeMonoBold18pt7b);
|
tft.setFont(&FreeMonoBold18pt7b);
|
||||||
tft.setCursor(0, 25);
|
tft.setCursor(0, 25);
|
||||||
tft.println("Soil");
|
tft.println("Soil");
|
||||||
|
@ -229,11 +288,27 @@ void screenSoilStemma() {
|
||||||
tft.setFont(&FreeMonoBold9pt7b);
|
tft.setFont(&FreeMonoBold9pt7b);
|
||||||
tft.println("--Press OK To Read Value--");
|
tft.println("--Press OK To Read Value--");
|
||||||
tft.println("");
|
tft.println("");
|
||||||
tft.println("Value: [value]");
|
tft.print("Temperature: "); tft.print(tempC); tft.println("*C");
|
||||||
|
tft.print("Capacitive: "); tft.println(capread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void screenSoilCatnip() {
|
void screenSoilCatnip(bool readValue) {
|
||||||
|
unsigned int capacitance = 0;
|
||||||
|
float temp_c = 0;
|
||||||
|
unsigned int light = 0;
|
||||||
|
if (readValue) {
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
pixelDataReadAlert();
|
||||||
|
screenClear();
|
||||||
|
sensor_soil_catnip.begin();
|
||||||
|
while (sensor_soil_catnip.isBusy()) delay(50); // available since FW 2.3
|
||||||
|
capacitance = sensor_soil_catnip.getCapacitance();
|
||||||
|
temp_c = sensor_soil_catnip.getTemperature() / (float)10;
|
||||||
|
light = sensor_soil_catnip.getLight(true);
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
tft.setFont(&FreeMonoBold18pt7b);
|
tft.setFont(&FreeMonoBold18pt7b);
|
||||||
tft.setCursor(0, 25);
|
tft.setCursor(0, 25);
|
||||||
tft.println("Soil");
|
tft.println("Soil");
|
||||||
|
@ -244,12 +319,22 @@ void screenSoilCatnip() {
|
||||||
tft.setFont(&FreeMonoBold9pt7b);
|
tft.setFont(&FreeMonoBold9pt7b);
|
||||||
tft.println("--Press OK To Read Value--");
|
tft.println("--Press OK To Read Value--");
|
||||||
tft.println("");
|
tft.println("");
|
||||||
tft.println("Capacitance: [value]");
|
tft.print("Capacitance: "); tft.println(capacitance);
|
||||||
tft.println("Temperature: [value]");
|
tft.print("Temperature: "); tft.print(temp_c); tft.println("*C");
|
||||||
tft.println("Light: [value]");
|
tft.print("Light: "); tft.println(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenWaterLevelETape() {
|
void screenWaterLevelETape(bool readValue) {
|
||||||
|
float value = 0;
|
||||||
|
|
||||||
|
if (readValue) {
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
pixelDataReadAlert();
|
||||||
|
screenClear();
|
||||||
|
value = analogRead(A0);
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
tft.setFont(&FreeMonoBold18pt7b);
|
tft.setFont(&FreeMonoBold18pt7b);
|
||||||
tft.setCursor(0, 25);
|
tft.setCursor(0, 25);
|
||||||
tft.println("Water Level");
|
tft.println("Water Level");
|
||||||
|
@ -260,5 +345,27 @@ void screenWaterLevelETape() {
|
||||||
tft.setFont(&FreeMonoBold9pt7b);
|
tft.setFont(&FreeMonoBold9pt7b);
|
||||||
tft.println("--Press OK To Read Value--");
|
tft.println("--Press OK To Read Value--");
|
||||||
tft.println("");
|
tft.println("");
|
||||||
tft.println("Value: [value]");
|
tft.print("Value: ");
|
||||||
|
tft.print(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void screenWaterLevelETapeI2C(bool readValue) {
|
||||||
|
if (readValue) {
|
||||||
|
taskENTER_CRITICAL();
|
||||||
|
pixelDataReadAlert();
|
||||||
|
screenClear();
|
||||||
|
taskEXIT_CRITICAL();
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.setFont(&FreeMonoBold18pt7b);
|
||||||
|
tft.setCursor(0, 25);
|
||||||
|
tft.println("Water Level");
|
||||||
|
tft.setFont(&FreeMono12pt7b);
|
||||||
|
tft.println("Milone eTape");
|
||||||
|
tft.println("i2c address: 0x5F");
|
||||||
|
tft.println("");
|
||||||
|
tft.setFont(&FreeMonoBold9pt7b);
|
||||||
|
tft.println("--Press OK To Read Value--");
|
||||||
|
tft.println("");
|
||||||
|
tft.println("Value: unknown");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,4 @@ A *simple* i2c based dip switch that can be queried as a sensor.
|
||||||
|
|
||||||
This build uses an ATTiny 2313 / 4313 for the i2c slave with an 8 pin dip switch. The status of all 8 pins on the dip switch are returned via i2c as a single byte that can be used to determine state of all 8.
|
This build uses an ATTiny 2313 / 4313 for the i2c slave with an 8 pin dip switch. The status of all 8 pins on the dip switch are returned via i2c as a single byte that can be used to determine state of all 8.
|
||||||
|
|
||||||
## Folders
|
|
||||||
|
|
||||||
### slave_sender
|
|
||||||
|
|
||||||
The main ATTiny code that reads the dip switch states and sends back a single byte with each dip's state encoded as a ```0``` for ```off``` and ```1``` for on.
|
The main ATTiny code that reads the dip switch states and sends back a single byte with each dip's state encoded as a ```0``` for ```off``` and ```1``` for on.
|
||||||
|
|
||||||
### master_reader
|
|
||||||
|
|
||||||
Sample code used on an Arduino for testing purposes.
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
# master_reader
|
|
||||||
|
|
||||||
Sample code used on an Arduino for testing purposes.
|
|
|
@ -1,32 +0,0 @@
|
||||||
// Wire Master Reader
|
|
||||||
// by Nicholas Zambetti <http://www.zambetti.com>
|
|
||||||
|
|
||||||
// Demonstrates use of the Wire library
|
|
||||||
// Reads data from an I2C/TWI slave device
|
|
||||||
// Refer to the "Wire Slave Sender" example for use with this
|
|
||||||
|
|
||||||
// Created 29 March 2006
|
|
||||||
|
|
||||||
// This example code is in the public domain.
|
|
||||||
|
|
||||||
|
|
||||||
#include <Wire.h>
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Wire.begin(); // join i2c bus (address optional for master)
|
|
||||||
Serial.begin(115200); // start serial for output
|
|
||||||
while (!Serial);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
Wire.requestFrom(0x65, 2);
|
|
||||||
// Wait for data to become available -- can be a delayed response due to # of pins to enumerate
|
|
||||||
while(!Wire.available());
|
|
||||||
byte dip_1 = Wire.read();
|
|
||||||
byte dip_2 = Wire.read();
|
|
||||||
Serial.print("DIP 1: ");
|
|
||||||
Serial.println(dip_1, BIN);
|
|
||||||
Serial.print("DIP 2: ");
|
|
||||||
Serial.println(dip_2, BIN);
|
|
||||||
delay(500);
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
# slave_sender
|
|
||||||
|
|
||||||
The main ATTiny code that reads the dip switch states and sends back a single byte with each dip's state encoded as a ```0``` for ```off``` and ```1``` for on.
|
|
Loading…
Reference in New Issue