ワイヤレスマイク送信機のサンプルを追加

ワイヤレスマイク送信機のサンプルを追加

error: pathspec '2_example/example65_mic/example65_mic.ino' did not match any file(s) known to git

--- 2_example/example65_mic/example65_mic.ino
+++ 2_example/example65_mic/example65_mic.ino
@@ -0,0 +1,162 @@
+/*******************************************************************************
+Example 65 アナログ入力ポートから録音した音声を送信する
+
+                                                Copyright (c) 2017 Wataru KUNINO
+********************************************************************************
+　マイク入力ポート：GPIO 34 ADC1_CH6
+　　　　　　　　　　IoT Express		A2ピン(P3 3番ピン)
+　　　　　　　　　　WeMos D1 R32		Analog 3ピン
+　　　　　　　　　　ESP-WROOM-32		6番ピン
+
+　録音開始入力ポート：GPIO 0 を Lレベルへ移行する
+　　　　　　　　　　IoT Express		BOOTスイッチを押す
+
+　受信用ソフト：toolsフォルダ内のget_sound.sh(Raspberry Pi用)などを使用する
+*******************************************************************************/
+
+#include <WiFi.h>                           // ESP32用WiFiライブラリ
+#include <WiFiUdp.h>                        // UDP通信を行うライブラリ
+#include "esp_sleep.h"                      // ESP32用Deep Sleep ライブラリ
+#define PIN_AIN 34                          // GPIO 34 ADC1_CH6(6番ピン)をADCに
+#define PIN_EN 2                            // GPIO 2(24番ピン)をセンサの電源に
+#define PIN_WAKE GPIO_NUM_0                 // GPIO 0をスリープ解除信号へ設定
+#define TIMEOUT 20000                       // タイムアウト 20秒
+#define SSID "1234ABCD"                     // 無線LANアクセスポイントのSSID
+#define PASS "password"                     // パスワード
+#define SENDTO "192.168.0.255"              // 送信先のIPアドレス
+#define PORT 1024                           // 送信のポート番号
+#define SLEEP_P 1*60*1000000                // スリープ時間 1分(uint32_t)
+#define DEVICE "sound_1,"                   // デバイス名(5文字+"_"+番号+",")
+#define FILENAME "/sound.wav"               // 音声ファイル名(ダウンロード用)
+#define SOUND_LEN 3*8000                    // 音声長 8000=約1秒
+
+WiFiUDP udp;                                // UDP通信用のインスタンスを定義
+WiFiServer server(80);                      // Wi-Fiサーバ(ポート80=HTTP)定義
+unsigned long TIME;                         // 写真公開時刻(起動後の経過時間)
+
+byte snd[SOUND_LEN];						// 音声録音用変数
+int snd_size=0;                             // 音声データの大きさ(バイト)
+const byte Wave_Header0[2]={0,0};
+const byte Wave_Header1[8]={16,0,0,0,1,0,1,0};
+const byte Wave_Header2[4]={0x40,0x1F,0,0};	// 8000Hz -> 00 00 1F 40
+const byte Wave_Header3[4]={1,0,8,0};
+
+int snd_rec(byte *snd, int len, int port){
+	unsigned long time,time_trig=0;
+	int i=0, wait_us=125;					// 8kHz時 サンプリング間隔 125us
+
+	while(i<len){
+		time=micros();
+		if(time < time_trig) continue;		// 未達時
+		snd[i]=(byte)(analogRead(PIN_AIN)>>4);  // アナログ入力 12ビット→8ビット
+		time_trig += wait_us;
+		i++;
+		if(time_trig < wait_us) break;		// 時間カウンタのオーバフロー
+	}
+	return i;
+}
+
+void setup(){
+    pinMode(PIN_AIN,INPUT);                 // アナログ入力端子の設定
+    pinMode(PIN_EN,OUTPUT);                 // センサ用の電源を出力に
+    Serial.begin(115200);                   // 動作確認のためのシリアル出力開始
+    Serial.println("eg.65 Microphone");     // タイトルをシリアル出力表示
+    TIME=millis();
+    digitalWrite(PIN_EN,HIGH);
+    Serial.print("Recording... ");
+	snd_size=snd_rec(snd,SOUND_LEN,PIN_AIN);// 音声入力
+	Serial.print(millis()-TIME);
+    Serial.println("s Done");
+	if(snd_size<82) sleep();
+    WiFi.mode(WIFI_STA);                    // 無線LANをSTAモードに設定
+    WiFi.begin(SSID,PASS);                  // 無線LANアクセスポイントへ接続
+    while(WiFi.status() != WL_CONNECTED){   // 接続に成功するまで待つ
+        delay(500);                         // 待ち時間処理
+        digitalWrite(PIN_EN,!digitalRead(PIN_EN));      // LEDの点滅
+        Serial.print(".");
+    }
+    digitalWrite(PIN_EN,HIGH);
+    udp.beginPacket(SENDTO, PORT);          // UDP送信先を設定
+    udp.print(DEVICE);                      // デバイス名を送信
+    udp.print(snd_size+44);                 // ファイルサイズを送信
+    udp.print(", http://");                 // デバイス名を送信
+    udp.print(WiFi.localIP());              // 本機のIPアドレスを送信
+    udp.println(FILENAME);                  // ファイル名を送信
+    udp.endPacket();                        // UDP送信の終了(実際に送信する)
+    Serial.print("http://");                // デバイス名を送信
+    Serial.print(WiFi.localIP());           // 本機のIPアドレスを送信
+    Serial.println(FILENAME);               // ファイル名を送信
+    TIME=millis()+TIMEOUT;                  // 終了時刻を保存(現時刻＋TIMEOUT)
+    server.begin();                         // HTTPサーバを起動する
+}
+
+void loop(){
+    WiFiClient client;                      // Wi-Fiクライアントの定義
+    char c;                                 // 文字変数を定義
+    char s[65];                             // 文字列変数を定義 65バイト64文字
+    int i,len=0;                            // 文字列等の長さカウント用の変数
+    int t=0;                                // 待ち受け時間のカウント用の変数
+
+    if(millis() > TIME) sleep();            // 終了時刻になったらsleep()を実行
+    client = server.available();            // 接続されたクライアントを生成
+    if(!client)return;                      // loop()の先頭に戻る
+    Serial.println("Connected");            // シリアル出力表示
+    while(client.connected()){              // 当該クライアントの接続状態を確認
+        if(client.available()){             // クライアントからのデータを確認
+            t=0;                            // 待ち時間変数をリセット
+            c=client.read();                // データを文字変数cに代入
+            if(c=='\n'){                    // 改行を検出した時
+                if(len>5 && strncmp(s,"GET /",5)==0) break;
+                len=0;                      // 文字列長を0に
+            }else if(c!='\r' && c!='\0'){
+                s[len]=c;                   // 文字列変数に文字cを追加
+                len++;                      // 変数lenに1を加算
+                s[len]='\0';                // 文字列を終端
+                if(len>=64) len=63;         // 文字列変数の上限
+            }
+        }
+        if(t>TIMEOUT){                      // TIMEOUTに到達したら終了
+            client.stop();                  // セッションを閉じる
+            sleep();                        // sleep()へ
+        }
+        delay(1); t++;                      // 変数tの値を1だけ増加させる
+    }
+    delay(1);                               // クライアントの準備待ち時間
+    if(!client.connected()) return;         // 切断されていた場合はloopの先頭へ
+    Serial.println(s);                      // 受信した命令をシリアル出力表示
+    client.println("HTTP/1.0 200 OK");                  // HTTP OKを応答
+    client.println("Content-Type: audio/wav");          // WAVコンテンツ
+    client.println("Connection: close");                // 応答後に閉じる
+    client.println();                                   // ヘッダの終了
+    client.write("RIFF",4);					// RIFF 					->[4]
+    i = snd_size + 44 - 8;					// ファイルサイズ-8
+    client.write(i & 0xFF);					// サイズ・最下位バイト	 	->[5]
+    client.write((i>>8) & 0xFF);			// サイズ・第2位バイト	 	->[6]
+    client.write(Wave_Header0,2);			// サイズ・第3-4位バイト 	->[8]
+    client.write("WAVEfmt ",8);				// "Wave","fmt "			->[16]
+    client.write(Wave_Header1,8);			// 16,0,0,0,1,0,1,0			->[24]
+    client.write(Wave_Header2,4);			// 68,172,0,0				->[28]
+    client.write(Wave_Header2,4);			// 68,172,0,0				->[32]
+    client.write(Wave_Header3,4);			// 1,0,8,0					->[36]
+    client.write("data",4);					//	"data"					->[40]
+    i = snd_size + 44 - 126;				// ファイルサイズ-126
+    client.write(i & 0xFF);					// サイズ・最下位バイト	 	->[41]
+    client.write((i>>8) & 0xFF);			// サイズ・最下位バイト	 	->[42]
+    client.write("\0\0",2);					// サイズ3-4
+    len=0; t=0;                         // 変数lenとtを再利用
+    for(i=0;i<snd_size;i++) client.write(snd[i]);
+    client.flush();                         // ESP32用 ERR_CONNECTION_RESET対策
+    client.stop();                          // クライアントの切断
+    Serial.print(snd_size+44);              // ファイルサイズをシリアル出力表示
+    Serial.println(" Bytes");               // シリアル出力表示
+    sleep();                                // sleep()へ
+}
+
+void sleep(){
+    Serial.println("Bye");                  // 終了表示
+    delay(200);                             // 送信待ち時間
+    esp_sleep_enable_ext0_wakeup(PIN_WAKE,0);  // 1=High, 0=Low
+                                            // センサの状態が変化すると
+                                            // スリープを解除するように設定
+    esp_deep_sleep_start();                 // Deep Sleepモードへ移行
+}


Added .ino-file

Added .ino-file

error: pathspec 'LibreMonitor.ino' did not match any file(s) known to git

--- LibreMonitor.ino
+++ LibreMonitor.ino
@@ -0,0 +1,754 @@
+///
+///   LibreMonitor
+///
+///   Copyright (c) 2015 Uwe Petersen, all right reserved
+///
+///   Wiring connections:
+///
+///      BM019            RFDuino/Simblee
+///      DIN:  pin 2      IRQ:  GPIO pin 2
+///      SS:   pin 3      SS:   GPIO pin 3
+///      MISO: pin 4      MISO: GPIO pin 4
+///      MOSI: pin 5      MOSI: GPIO pin 5
+///      SCK:  pin 6      SCK:  GPIO pin 6
+///      SS0:  pin 7      +3V-pin
+///      GND:  pin 10     GND-pin
+///
+///      BM019            BM019
+///      SS0:  pin 7       VDD:  pin 8 (Output 3,3V from BM019)
+///
+///      BM019            Lipo Power source (I use a 100mAh lip which lasts a full day
+///      VIN:  pin 9      "+" of lipo / lipo charger
+///      GND:  pin 10     GND/"-" of lipo / lipo charger
+///
+///      You can place a switch between GND of lipo/lipo-charger and GND of the BM019
+///
+///      If wired as suggested above, then you have to change the Simblee SPI pins for SS, MOSI, MISO and SCK.
+///      This is done in the variant.h file. In my case this file is located in
+///
+///         /Users/[my user name]/Library/Arduino15/packages/Simblee/hardware/Simblee/1.0.0/variants/Simblee
+///
+///      In this file set the defines for the SPI pins as follows:
+///
+///         #define PIN_SPI_SS           (3u)
+///         #define PIN_SPI_MOSI         (5u)
+///         #define PIN_SPI_MISO         (4u)
+///         #define PIN_SPI_SCK          (6u)
+///
+///
+///   Acknowledgements:
+///
+///      RFDuinoUBP
+///
+///         This code uses portions of RFduinoUB, which can be retrieved from
+///              https://github.com/cconway/RFduinoUBP under the following license:
+///         The MIT License (MIT)
+///         Copyright (c) 2015 cconway
+///         Permission is hereby granted, free of charge, to any person obtaining a copy
+///         of this software and associated documentation files (the "Software"), to deal
+///         in the Software without restriction, including without limitation the rights
+///         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+///         copies of the Software, and to permit persons to whom the Software is
+///         furnished to do so, subject to the following conditions:
+///         The above copyright notice and this permission notice shall be included in all
+///         copies or substantial portions of the Software.
+///         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+///         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+///         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+///         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+///         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+///         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+///         SOFTWARE.
+///
+///      Solutions Cubed LLC
+///
+///         The author is grateful to Solutions Cubed LLC, see http://www.solutions-cubed.com,
+///         for providing helpful code samples for their BM019 nfc module, portions of which are
+///         used within this code.
+///
+
+// Include application, user and local libraries
+#include <SimbleeBLE.h>
+#include <SimbleeForMobile.h>
+#include <SPI.h>               // the sensor communicates using SPI, so include the library
+// This code uses the SLIP protocol to transer the data via bluetooth, see https://github.com/cconway/RFduinoUBP
+#include <constants.h>
+#include <crc8.h>
+#include <data_types.h>
+#include <libUBP.h>
+#include <SPIstuff.h>
+
+
+// Define variables and constants
+
+/* CR95HF Commands */
+#define IDN               0x01  // identification number of CR95HF
+#define SELECT_PROTOCOL   0x02  // select protocol
+#define POLL              0x03  // poll
+#define SENDRECEIVE       0x04  // send and receive data (most commonly used)
+#define READ              0x05  // read values from registers internal to CR95HF
+#define WRITE             0x06  // write values to registers internal to CR95HF
+#define ECHO              0x55
+
+// send receive commands for ISO/IEC 15693 protocol
+#define INVENTORY               0x01  // receives information about tags in range
+#define STAY_QUIET              0x02  // selected unit will not send back a response
+#define READ_BLOCK              0x20  // read single block of memory from RF tag
+#define WRITE_BLOCK             0x21  // write single block to memory of RF tag
+#define LOCK_BLOCK              0x22  // permanently locks a block of memory on RF tag
+#define READ_BLOCKS             0x23  // reads multiple blocks of memory from RF tag
+#define WRITE_BLOCKS            0x24  // writes multiple blocks of memory to RF tag
+#define SELECT                  0x25  // used to select a specific tag for communication via the uid
+#define RESET_TO_READY          0x26  // resets RF tag to ready state
+#define WRITE_AFI               0x27  // writes application family identifier to RF tag
+#define LOCK_AFI                0x28  // permanently locks application family identifier
+#define WRITE_DSFID             0x29  // writes data storage format identifier to RF tag
+#define LOCK_DSFID              0x2A  // permanentlylocks data storage format identifier
+#define GET_SYSTEM_INFORMATION  0x2B  // gets information from RF tag that includes memory
+// block size in bytes and number of memory blocks
+#define GET_BLOCKS_SECURITY_STATUS  0x2C
+
+// Request flag with bits set these rules:
+//     Bit  Flag name           Description
+//      1   Sub-carrier flag    0 ... single sub-carrier used
+//                              1 ... two sub-carriers used
+//      2   Data rate flag      0 ... low data rate is used
+//                              1 ... high data rate is used
+//      3   Inventory flag      State determines how bits 5-8 are defined
+//                              0 ... flag not set
+//                              1 ... flag set
+//      4   Protocol            0: no protocol extension
+//          extension flag      1: protocol format is extended
+//   If Inventory flag = 0 (not set):
+//      5   Select flag         0: request shall be executed based on setting of the address flag
+//                              1: request shall be executed only by devices in the selected state
+//      6   Address flag        0: request is not addressed
+//                              1: request is addressed, optional UID field is present
+//      7   Option flag         Meaning is defined by the command description, if not used set to 0
+//      8   reserved
+//   If Inventory flag = 1 (set):
+//      5   AFI flag            0: AFI field is not present
+//                              1: AFI field is present
+//      6   Number of           0: 16 slots
+//          slots flag          1: 1 slot
+//      7   Option flag         Meaning is defined by the command description, if not used set to 0
+//      8   reserved
+//
+//  Helper bit field by to quickly calculate integers from hex and vice versa:
+//      Bit no.:     8   7   6   5      4   3   2   1
+//      value:     128  64  32  16      8   4   2   1
+//      choose:      0   0   0   0      4   0   2   1   result is 0x03
+//
+// request flags byte, 0x26 means:
+//   single sub carrier, high data rate, inventory flag set, no protocoll extentsion, AFI not present, one slot)
+
+
+// Settings
+
+//#define DEBUG
+
+const int SS_PIN = 3;   // Slave Select pin, changed to new value on 2016-03-21
+const int IRQ_PIN = 2;  // IRQ/DIN pin used for wake-up pulse
+byte RXBuffer[400];     // receive buffer
+byte dataBuffer[400];   // buffer for Freestyle Libre byte data
+byte NFCReady = 0;      // used to track NFC state
+const int SPI_FREQUENCY = 2000; // max. for CR95HF is 2000 = 2 MHz
+//const uint64_t SLEEP_DURATION = 20000;  // Duration of Simblee ultra low power mode in ms
+const uint64_t SLEEP_DURATION = 120000;  // Duration of Simblee ultra low power mode in ms
+
+// Code
+
+void setupPins() {
+  Serial.println("Setting Simblee pins ...");
+  pinMode(IRQ_PIN, OUTPUT);
+  pinMode(SS_PIN, OUTPUT);
+  // Commented out by Uwi on 15.11.2015: was not needed obviously
+  //    digitalWrite(SS_PIN, HIGH);
+  Serial.println("... done setting Simblee pins.");
+}
+
+void setupSPI() {
+  Serial.println("Setting up SPI ...");
+  SPI.begin();
+  SPI.setDataMode(SPI_MODE0);
+  SPI.setBitOrder(MSBFIRST);
+  SPI.setFrequency(SPI_FREQUENCY);
+  Serial.println("... done setting up SPI.");
+}
+// --------------------------
+
+void setupBluetoothConnection() {
+  Serial.println("Setup Bluetooth stack and start connection...");
+  SimbleeBLE.deviceName = "LibreCGM";
+  SimbleeBLE.customUUID = "2220";
+  SimbleeBLE.advertisementData = "data";
+  SimbleeBLE.advertisementInterval = MILLISECONDS(500);  // Default was 300
+  SimbleeBLE.txPowerLevel = 4;  // Possible values: -20, -16, -12, -8, -4, 0 or +4 (dbM)  // up to 20016-05-17 this was 0
+  //    SimbleeBLE.txPowerLevel = -4;  // Possible values: -20, -16, -12, -8, -4, 0 or +4 (dbM)  // up to 20016-05-17 this was 0
+  SimbleeBLE.begin();           // Start the BLE stack
+  Serial.println("... done seting up Bluetooth stack and starting connection.");
+}
+
+// Add setup code
+void setup() {
+  Serial.begin(9600);
+  setupPins();  // set RFduino/Simblee pins
+  setupSPI();
+
+  Serial.println("Please provide power to the BM019 within the next 5 seconds ...");
+  delay(5000);
+
+  sendWakeupPulse(IRQ_PIN);  // wake up BM019 and set to SPI (since SS_0 is wired up to be HIGH)
+  readWakeUPEventRegister(SS_PIN, RXBuffer);
+  setupBluetoothConnection();
+}
+
+
+
+// SetProtocol_Command programs the CR95HF for ISO/IEC 15693 operation.
+// If the correct response is received the serial monitor is used to display successful programming.
+// Warning: if the parameters of the protocol are changed, e.g. sub carrier, then the request flags
+// of the other commands (e.g. inventory, read single block) have to be changed accordingly.
+void SetProtocol_Command() {
+
+  // step 1 send the command
+  digitalWrite(SS_PIN, LOW);
+  SPI.transfer(0x00);  // SPI control byte to send command to CR95HF
+  SPI.transfer(0x02);  // Set protocol command
+  SPI.transfer(0x02);  // length of data to follow
+  SPI.transfer(0x01);  // code for ISO/IEC 15693
+  SPI.transfer(0x0F);  // Up till 2016-06-13: crc16, single, 30%, wait for SOF (wrong: Wait for SOF, 100% modulation, append CRC)
+  //    SPI.transfer(0x0D);  // Up till 2016-06-13: crc16, single, 30%, wait for SOF (wrong: Wait for SOF, 100% modulation, append CRC)
+  digitalWrite(SS_PIN, HIGH);
+  delay(1);
+
+  // step 2, poll for data ready
+  pollSPIUntilResponsIsReady(SS_PIN, RXBuffer);
+
+  // step 3, read the data
+  receiveSPIResponse(SS_PIN, RXBuffer);
+#ifdef DEBUG
+  Serial.println("RXBuffer is");
+  for (byte i = 0; i < 2; i++) {
+    Serial.print(RXBuffer[i], HEX);
+    Serial.print(" ");
+  }
+#endif
+  if ((RXBuffer[0] == 0) & (RXBuffer[1] == 0)) {
+    Serial.println("PROTOCOL SET-");  //
+    NFCReady = 1; // NFC is ready
+  } else {
+    Serial.println("BAD RESPONSE TO SET PROTOCOL");
+    NFCReady = 0; // NFC not ready
+  }
+  Serial.println(" ");
+}
+
+// Reads the single block of 8 bytes with number blockNum from the BM019.
+// The BM019 has 244 Blocks of 8 bytes that can be read via ISO 15693 commands. The blocks are numbered 0 to 243.
+// Returns the result code of the command response (that indicates wether there was success or an error)
+byte ReadSingleBlockReturn(int blockNum) {
+
+  RXBuffer[0] = SENDRECEIVE;   // command code for send receive CR95HF command
+  RXBuffer[1] = 0x03;          // length of data that follows (3 bytes)
+  //    RXBuffer[2] = 0x02;          // request Flags byte, single carrier, high data rate
+  RXBuffer[2] = 0x03;        // request Flags byte dual carrier, high data rate
+  RXBuffer[3] = 0x20;          // Inventory Command for ISO/IEC 15693
+  RXBuffer[4] = blockNum;      // Block number
+
+  // step 1 send the command
+  sendSPICommand(SS_PIN, RXBuffer, 5);
+
+  // step 2, poll for data ready
+  pollSPIUntilResponsIsReady(SS_PIN, RXBuffer);
+
+  // step 3, read the data
+  receiveSPIResponse(SS_PIN, RXBuffer);
+
+  delay(1);
+#ifdef DEBUG
+  // Print to Serial
+  if (RXBuffer[0] == 128)  {
+    Serial.printf("The block #%d:", blockNum);
+    for (byte i = 3; i < RXBuffer[1] + 3 - 4; i++) {
+      Serial.print(RXBuffer[i], HEX);
+      Serial.print(" ");
+    }
+  } else {
+    Serial.print("NO Single block available - ");
+    Serial.print("RESPONSE CODE: ");
+    Serial.println(RXBuffer[0], HEX);
+  }
+  Serial.println(" ");
+#endif
+
+  return RXBuffer[0];  // result code of command response
+}
+
+
+
+/// @brief  Sends command to BM019 and receives response serveral times until response with no error, max maxTrial times.
+/// @detail After maxTrials trials the last response is returned, even  if there is still an error.
+/// @detail Warning: Ensure that RXBuffer has appropriate size.
+/// @param  ssPin slave select pin for SPI digital write
+/// @param  RXBuffer buffer used for command and response
+/// @param  maxTrials max number of trials
+void runSPICommandUntilNoError(int ssPin, byte *command, int length, byte *RXBuffer, int maxTrials) {
+
+  int count = 0;
+  bool success;
+  do {
+    delay(1);
+#ifdef DEBUG
+    Serial.printf("Before: Count: %d, success: %b, RXBuffer[0]: %x \r\n", count, success, RXBuffer[0]);
+#endif
+    count++;
+
+    // clear RXBuffer with zeros
+    memset(RXBuffer, 0, sizeof(RXBuffer));
+
+    // run SPI command
+    sendPollReceiveSPINew(ssPin, command, sizeof(command), RXBuffer);
+    success = responseHasNoError(RXBuffer);
+
+#ifdef DEBUG
+    Serial.printf("After: Count: %d, success: %b, RXBuffer[0]: %x \r\n", count, success, RXBuffer[0]);
+#endif
+
+  } while ( !success && (count < maxTrials));
+  delay(1);
+#ifdef DEBUG
+  Serial.printf("Exiting at count: %d, RXBuffer[0]: %x \r\n", count, RXBuffer[0]);
+#endif
+}
+
+/// @brief  Sends IDN command to BM019 and receives response serveral times until response with no error, max maxTrial times.
+/// @detail After maxTrials trials the last response is returned, even  if there is still an error.
+/// @detail Warning: Ensure that RXBuffer has appropriate size.
+/// @param  ssPin slave select pin for SPI digital write
+/// @param  RXBuffer buffer used for command and response
+/// @param  maxTrials max number of trials
+void runIDNCommandUntilNoError(int ssPin, byte *command, int length, byte *RXBuffer, int maxTrials) {
+
+  int count = 0;
+  bool success;
+  do {
+
+#ifdef DEBUG
+    Serial.printf("Before: Count: %d, success: %b, RXBuffer[0]: %x \r\n", count, success, RXBuffer[0]);
+#endif
+    count++;
+
+    // clear RXBuffer with zeros
+    memset(RXBuffer, 0, sizeof(RXBuffer));
+
+    // run SPI command
+    sendPollReceiveSPINew(ssPin, command, sizeof(command), RXBuffer);
+    success = idnResponseHasNoError(RXBuffer);
+
+#ifdef DEBUG
+    Serial.printf("After: Count: %d, success: %b, RXBuffer[0]: %x \r\n", count, success, RXBuffer[0]);
+#endif
+  } while ( !success && (count < maxTrials));
+  delay(10);
+#ifdef DEBUG
+  Serial.printf("Exiting at count: %d, RXBuffer[0]: %x \r\n", count, RXBuffer[0]);
+#endif
+}
+
+
+/// Runs the system information command several times, i.e. maxTrials times or until a response with no error is gotten, whatever happens first.
+/// @param ssPin SS_PIN used for SPI
+/// @param RXBuffer buffer used for send and receive
+/// @param maxTrials maximum number of trials. If reached, the result is returned, even if there still is an error present
+/// @brief  Get system information from BM019
+/// @details  The response is read into RXBuffer and that's it, no matter if there is an error or not.
+/// @n Command format for CR95HF:
+/// @n 8 bits for request flags,
+/// @n 8 bits for the get system information command,i.e 0x2B,
+/// @n 64 bits for an optional UID (not used in non-addressed modes).
+/// @details Example get system info command (CR95HF command embedded in BM019 command):
+/// @details 0x04 ... BM019 send/receive command code
+/// @details 0x02 ... BM019 length of CR95HF command data that follows
+/// @details 0x02 ... CR95HF request flags byte (high data rate used)
+/// @details 0x2B ... CR95HF get system information command
+/// @n
+/// @n
+/// @details Example CR95HF response with no error:
+/// @details 0x80      ... result code
+/// @details 0x12      ... length of following data (12 bytes)
+/// @details 0x00      ... response flags
+/// @details 0x0F      ... info flags
+/// @details 0x69 0x55 0x19 0x38 0x42 0x20 0x02 0xE0 ... data: UID
+/// @details 0x00      ... DSFID (supported and field is present in response if bit 1 of info flags is set)
+/// @details 0x00      ... AFI (supported and field is present in response if bit 2 of info flags is set)
+/// @details 0x3F 0X03 ... memory size (supported and field is present in response if bit 3 of info flags is set)
+/// @details 0x20      ... IC Ref (supported and field is present in response if bit 4 of info flags is set)
+/// @details 0xB4 0xA9 ... CRC16
+/// @details 0x00      ... error
+/// @n
+/// @details Example CR95HF response with error (bit 0 of response flag is set)
+/// @details 0x01      ... response flags
+/// @details 0x01      ... error code (returned when error bit is set)
+/// @details 0xB4 0xA9 ... CRC16
+/// @details 0X01      ... (error CRC16 or collision error bits)
+void runSystemInformationCommandUntilNoError(int ssPin, byte *RXBuffer, int maxTrials) {
+#ifdef DEBUG
+  Serial.printf("ssPin: %d, maxTrials: %d, RXBuffer[0]: %x \r\n", ssPin, maxTrials, RXBuffer[0]);
+#endif
+  byte command[4];
+  command[0] = 0x04;   // command code for send receive CR95HF command
+  command[1] = 0x02;   // length of data that follows (3 bytes)
+  command[2] = 0x03;   // request Flags byte, dual sub carrier
+  //    command[2] = 0x02;   // request Flags byte, single sub carrier
+  command[3] = 0x2B;   // get system information command for ISO/IEC 15693
+  delay(10);
+#ifdef DEBUG
+  Serial.printf("ssPin: %d, maxTrials: %d, RXBuffer[0]: %x \r\n", ssPin, maxTrials, RXBuffer[0]);
+#endif
+  // run command until no error, but only max 10 times
+  runSPICommandUntilNoError(ssPin, command, sizeof(command), RXBuffer, maxTrials);
+}
+
+/// Runs the inventory  command several times, i.e. maxTrials times or until a response with no error is gotten, whatever happens first.
+/// @param ssPin SS_PIN used for SPI
+/// @param RXBuffer buffer used for send and receive
+/// @param maxTrials maximum number of trials. If reached, the result is returned, even if there still is an error present
+void runIDNCommand(int ssPin, byte *RXBuffer, int maxTrials) {
+
+#ifdef DEBUG
+  Serial.printf("ssPin: %d, maxTrials: %d, RXBuffer[0]: %x \r\n", ssPin, maxTrials, RXBuffer[0]);
+#endif
+
+  byte command[2];
+  command[0] = 0x01;   // command code for send receive CR95HF command
+  command[1] = 0x00;   // length of data that follows (0 bytes)
+  delay(10);
+
+#ifdef DEBUG
+  Serial.printf("ssPin: %d, maxTrials: %d, RXBuffer[0]: %x \r\n", ssPin, maxTrials, RXBuffer[0]);
+#endif
+  // run command until no error, but only max 10 times
+  runIDNCommandUntilNoError(ssPin, command, sizeof(command), RXBuffer, maxTrials);
+}
+
+
+//Example response of CR95HF for inventory command and data positions/indices
+//+------+--------+----------------------------------------------------------------------+
+//|Result| Length | Data                                                                 |
+//| code |        +--------+-----+---------------------------------------+---------+-----+
+//|      |        |Response|     |                                       |         |     |
+//|      |        | flags  |DSFID| UID                                   |CRC16    |Error|
+//+------+--------+--------+---------------------------------------------+---------+-----+
+//| 0x80 |0x0D(13)| 0x00   |0x00 |0x51 0x69 0x19 0x38 0x42 0x20 0x02 0xE0|0x84 0x28|0x00 |
+//+------+--------+--------+-----+---------------------------------------+---------+-----+
+//|   0  |  1     |   2    |  3  | 4    5    6    7    8    9    10   11 | 12   13 | 14  |
+//+------+--------+--------+-----+---------------------------------------+---------+-----+
+//                    0       1    2    3    4    5    6    7     8    9   10   11   12
+//
+
+/// Retreive idn data from RXBuffer from IDN command
+/// This ist the struct later to be transmitted via bluetooth
+/// @detail There is no error possible in the response since this is just pure device information and thus not rely on RFID and a tag in the field
+/// @param RXBuffer buffer containing the response from the IDN command
+/// @param idnType struct with retreived data
+IDNDataType idnDataFromIDNResponse(byte *RXBuffer) {
+
+  IDNDataType idnData;
+  idnData.resultCode = RXBuffer[0];
+
+  // Device ID has 13 bytes
+  for (int i = 0; i < 13; i++) {
+    idnData.deviceID[i] = RXBuffer[i + 2]; // TODO: cchek and continue here
+  }
+
+  // ROM CRC are the last two bytes of the data
+  int length = RXBuffer[2];
+  idnData.romCRC[0] = RXBuffer[length - 2];
+  idnData.romCRC[1] = RXBuffer[length - 1];
+
+  return idnData;
+}
+
+
+
+/// Retreive system information from RXBuffer from system information command
+/// This ist the struct later to be transmitted via bluetooth
+/// @param RXBuffer buffer containing the response from the system information command
+/// @param SystemInformationType struct with retreived data
+SystemInformationDataType systemInformationDataFromGetSystemInformationResponse(byte *RXBuffer) {
+  //    SystemInformationType retreiveSystemInformationValues(byte *RXBuffer) {
+
+  SystemInformationDataType systemInformationData;
+
+  systemInformationData.resultCode = RXBuffer[0];
+  systemInformationData.responseFlags = RXBuffer[2];
+
+  // check for no error in result code and handle accordingly
+  if (systemInformationData.resultCode == 0x80) { // no error in result code
+
+    // check for no error in response flags
+    if ((systemInformationData.responseFlags & 0x01) == 0) {
+      // no error in response flags
+      systemInformationData.infoFlags = RXBuffer[3];
+      for (int i = 0; i < 8; i++) {
+        systemInformationData.uid[i] = RXBuffer[11 - i];
+      }
+      systemInformationData.errorCode = RXBuffer[RXBuffer[1] + 2 - 1];
+    } else {
+      // error case
+      systemInformationData.errorCode = RXBuffer[3];
+    }
+  } else {
+    // error case
+    clearBuffer(systemInformationData.uid);
+    systemInformationData.errorCode = RXBuffer[3];
+  }
+  return systemInformationData;
+}
+
+
+/// Sends a packet of data (c-struct) via bluetooth to a smartphone application
+/// @detail Any packet to be transfered is a c-struct. These structs are defined in data_types.h.
+/// @param packetIdentifier identifier that can be used to treat a packet separately in the app. Identifiers are defined in constants.h
+/// @param txFlags don't know yet, what these are fore
+/// @param *packetBytes pointer on the c-struct, that is the packet
+/// @param byteCount number of bytes to be transfered
+bool pumpViaBluetooth(unsigned short packetIdentifier, UBP_TxFlags txFlags, const char *packetBytes, unsigned short byteCount) {
+
+  bool success = UBP_queuePacketTransmission(packetIdentifier, txFlags, packetBytes, byteCount);
+
+  delay(1);
+#ifdef DEBUG
+  if (success) Serial.println("Packet queued successfully");
+  else Serial.println("Failed to enqueue packet");
+#endif
+  // put your main code here, to run repeatedly:
+  while (UBP_isBusy() == true) UBP_pump();
+}
+
+/// Returns the voltage on the RFDuino VDD pin as a float in Volts.
+/// Code is from the RFDuino Forum, see http://forum.rfduino.com/index.php?topic=265.0 for details
+float voltageOnVDD() {
+  analogReference(VBG);                // Sets the Reference to 1.2V band gap
+  analogSelection(VDD_1_3_PS);         // Selects VDD with 1/3 prescaling as the analog source
+  int sensorValue = analogRead(1);     // the pin has no meaning, it uses VDD pin
+  return sensorValue * (3.6 / 1023.0); // convert value to voltage;
+}
+
+/// Print all data of systemInformationData to serial console
+void printSystemInformationData(SystemInformationDataType systemInformationData) {
+
+  Serial.println("Printing system information data to serial output:");
+
+  Serial.printf("Result code: %x\r\n", systemInformationData.resultCode);
+  Serial.printf("Response flags: %x\r\n", systemInformationData.responseFlags);
+
+  Serial.printf("uid: %x", systemInformationData.uid[0]);
+  for (int i = 1; i < 8; i++) {
+    Serial.printf(":%x", systemInformationData.uid[i]);
+  }
+  Serial.println("");
+
+  Serial.printf("Error code: %x\r\n", systemInformationData.errorCode);
+}
+
+///===================================================================================================
+// The loop
+///===================================================================================================
+
+void loop() {
+
+#ifdef DEBUG
+  Serial.println("In the loop");
+#endif
+
+  // Start up BM019 if not yet started
+  if (NFCReady == 0) {
+
+    delay(100);
+    SetProtocol_Command(); // ISO 15693 settings
+    Serial.println("After SetProtocoll_Command()");
+    delay(100);
+
+  } else {
+
+
+    // ------- Read system information from BM019 ----------------------------------------------------------------------------
+    //#ifdef DEBUG
+    Serial.println("Get system information command ...");
+    //#endif
+    runSystemInformationCommandUntilNoError(SS_PIN, RXBuffer, 10);
+
+#ifdef DEBUG
+    Serial.println("... retreive system information ...");
+#endif
+    SystemInformationDataType systemInformationData = systemInformationDataFromGetSystemInformationResponse(RXBuffer);
+
+
+
+    //------- Read IDN information from BM019 (IDN Command) -------------------------------------------------------------------
+
+    //#ifdef DEBUG
+    Serial.println("IDN command ...");
+    //#endif
+    runIDNCommand(SS_PIN, RXBuffer, 10);
+#ifdef DEBUG
+    Serial.println("... retreive IDN information ...");
+#endif
+    IDNDataType idnData = idnDataFromIDNResponse(RXBuffer);
+
+
+
+    // ----------- Read 43 data blocks into RXBuffer ---------------
+
+    //#ifdef DEBUG
+    Serial.println("Read all data");
+    //#endif
+
+    for (int i = 0; i < sizeof(RXBuffer); i++) {
+      RXBuffer[i] = 0;
+    }
+    for (int i = 0; i < sizeof(dataBuffer); i++) {
+      dataBuffer[i] = 0;
+    }
+
+    byte resultCode = 0;
+    int trials = 0;
+    int maxTrials = 10;
+    for (int i = 0; i < 43; i++) { // Need only 43 of 244 blocks
+      resultCode = ReadSingleBlockReturn(i);
+
+#ifdef DEBUG
+      printf("resultCode 0x%x\n\r", resultCode);
+#endif
+      if (resultCode != 0x80 && trials < maxTrials) {
+        printf("Error 0x%x\n\r", resultCode);
+        i--;        // repeat same block if error occured, but
+        trials++;   // not more than maxTrials times per block
+      } else if (trials >= maxTrials) {
+        break;
+      } else {
+        trials = 0;
+
+        for (int j = 3; j < RXBuffer[1] + 3 - 4; j++) {
+          dataBuffer[i * 8 + j - 3] = RXBuffer[j];
+#ifdef DEBUG
+          Serial.print(RXBuffer[j], HEX);
+          Serial.print(" ");
+#endif
+        }
+      }
+    }
+
+    // ----------- All data collected, send BM019 to hibernate -------------------------
+
+    //#ifdef DEBUG
+    Serial.println("Sending CR95HF to hibernate ...");
+    //#endif
+    sendCR95HFToHibernate(SS_PIN);
+
+
+
+    // ------- Transmit system information data via bluetooth. By convention this is the first transmission -----------------
+
+    bool ergo = pumpViaBluetooth(SYSTEM_INFORMATION_DATA, UBP_TxFlagIsRPC, (char *) &systemInformationData, sizeof(SystemInformationDataType));
+#ifdef DEBUG
+    printSystemInformationData(systemInformationData);
+#endif
+
+
+
+    //-------- transmit dataBuffer via bluetooth ---------------------------------------------------------
+
+    AllBytesDataType allBytes;
+#ifdef DEBUG
+    Serial.println("----about to send all data bytes packet");
+#endif
+    for (int i = 0; i < sizeof(allBytes.allBytes); i++) {
+      allBytes.allBytes[i] = 0;
+    }
+    for (int i = 0; i < 344; i++) {
+      allBytes.allBytes[i] = dataBuffer[i];
+    }
+    //#ifdef DEBUG
+    Serial.printf("Sizeof ist : %d\n", sizeof(AllBytesDataType));
+    //#endif
+    bool success = UBP_queuePacketTransmission(ALL_BYTES, UBP_TxFlagIsRPC, (char *) &allBytes, sizeof(AllBytesDataType));
+#ifdef DEBUG
+    if (success) Serial.println("----all data bytes packet queued successfully");
+    else Serial.println("----Failed to enqueue all data bytes packet");
+#endif
+    while (UBP_isBusy() == true) UBP_pump();
+
+    //-------- Read Battery level and Simblee temperature and transmit via bluetooth ---------------------
+
+    BatteryDataType batteryData;
+    batteryData.voltage = voltageOnVDD();
+    batteryData.temperature = Simblee_temperature(CELSIUS);
+
+#ifdef DEBUG
+    Serial.printf("Battery voltage: %f\r\n", batteryData.voltage);
+#endif
+    // Transmitt via bluetooth
+    success = UBP_queuePacketTransmission(BATTERY_DATA, UBP_TxFlagIsRPC, (char *) &batteryData, sizeof(BatteryDataType));
+    //        if (success) Serial.println("Battery data packet queued successfully");
+    //        else Serial.println("Failed to enqueue battery data packet");
+    // put your main code here, to run repeatedly:
+    while (UBP_isBusy() == true) UBP_pump();
+
+#ifdef DEBUG
+    Serial.printf("Sent Battery voltage: %f\r\n", batteryData.voltage);
+#endif
+
+
+    //-------- transmit IDN data via bluetooth. By convention this is the last transmission -----------------
+
+    ergo = pumpViaBluetooth(IDN_DATA, UBP_TxFlagNone, (char *) &idnData, sizeof(IDNDataType));
+    success = UBP_queuePacketTransmission(IDN_DATA, UBP_TxFlagIsRPC, (char *) &idnData, sizeof(IDNDataType));
+    delay(10);
+#ifdef DEBUG
+    if (success) Serial.println("IDN data packet queued successfully");
+    else Serial.println("Failed to enqueue IDN data packet");
+#endif
+    // put your main code here, to run repeatedly:
+    while (UBP_isBusy() == true) UBP_pump();
+
+#ifdef DEBUG
+    Serial.printf("IDN: %x", idnData.deviceID[0]);
+    for (int i = 1; i < 13; i++) {
+      Serial.printf(":%x", idnData.deviceID[i]);
+    }
+    Serial.println("... done");
+#endif
+
+
+    //--------- send Simblee into ultra low power mode ---------------------------------------------------
+
+    //#ifdef DEBUG
+    Serial.println("Sending RFDuino to sleep ...");
+    //#endif
+    Simblee_ULPDelay(SLEEP_DURATION); //
+
+
+    //--------- send Simblee woke up again, now also wake up BM019 and repeat the loope cycle ------------
+
+#ifdef DEBUG
+    Serial.println("... RFDuino woke up again");
+    Serial.println("Wake up CR95HF with wake up pulse...");
+#endif
+    sendWakeupPulse(IRQ_PIN);  // Wake up BM019 (low pulse on IRQ_PIN)
+    readWakeUPEventRegister(SS_PIN, RXBuffer);
+    setupSPI();
+
+    delay(10);
+    SetProtocol_Command(); // ISO 15693 settings
+    delay(100);
+
+#ifdef DEBUG
+    Serial.println("... CR95HF woke up again. Receiving wake up response");
+#endif
+  }
+}
+
+


use digital pins for 1-wire VCC & GND

use digital pins for 1-wire VCC & GND

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/wsnook/farm.git/'


It's working! Time to abstractify...

It's working! Time to abstractify...

error: pathspec 'Motor' did not match any file(s) known to git
error: pathspec 'Speed/testTimerTwo/testTimerTwo.ino' did not match any file(s) known to git


CTD Code for Qduino

CTD Code for Qduino

error: pathspec 'OpenCTD_qDuino.ino/OpenCTD_qDuino.ino.ino' did not match any file(s) known to git

--- OpenCTD_qDuino.ino/OpenCTD_qDuino.ino.ino
+++ OpenCTD_qDuino.ino/OpenCTD_qDuino.ino.ino
@@ -0,0 +1,125 @@
+//Wire and MS5803_I2C libraries for communicating with the pressure sensor.
+
+#include <Wire.h>
+#include <SparkFun_MS5803_I2C.h>
+
+//EC Circuit uses software serial
+#include <SoftwareSerial.h>     // For use by EC circuit.
+
+//OneWire is used to get data from both temperature and conductivity sensors
+#include <OneWire.h>
+
+//DallasTemperature is used to query the temeprature sensors
+#include <DallasTemperature.h>
+
+// For the SD card reader.
+#include <SPI.h>
+#include <SD.h>
+
+// Declare global variables.
+float tempA;
+float tempB;
+float tempC;
+
+float EC_float = 0;  // Electrical conductivity.
+
+char EC_data[48];    // A 48 byte character array to hold incoming data from the conductivity circuit.
+char *EC;            // Character pointer for string parsing.
+
+byte received_from_sensor = 0;  // How many characters have been received.
+byte string_received = 0;       // Whether it received a string from the EC circuit.
+
+SoftwareSerial ecSerial(8, 9);      // Define the SoftwareSerial port for conductivity.
+OneWire oneWire(6);        // Define the OneWire port for temperature.
+DallasTemperature sensors(&oneWire);  // Define DallasTemperature input based on OneWire.
+MS5803 sensor(ADDRESS_HIGH);          // Define pressure sensor.
+
+double pressure_abs; //define absolute pressure variable
+
+// Starts it up.
+//
+void setup(void) {
+
+  Serial.begin(9600);   // Set baud rate.
+  ecSerial.begin(9600); // Set baud rate for conductivty circuit.
+
+  pinMode(10, OUTPUT);  // Set data output pin for the SD card reader.
+
+  // Test to see if the SD card reader is functioning.
+  if (!SD.begin(4)) {
+    Serial.println("Card failed");  // Log to serial monitor if SD card doesn't work.
+    return;
+  }
+  delay(500);  // Wait half a second before continuing.
+
+  sensor.reset(); //reset pressure sensor
+  sensor.begin(); //initialize pressure sensor
+  sensors.begin();  // Intialize the temperature sensors.
+
+  delay(250);       // Wait a quarter second to continue.
+
+}
+
+void loop(void) {
+
+  // Read any pending data from the EC circuit.
+  if (ecSerial.available() > 0) {
+    received_from_sensor = ecSerial.readBytesUntil(13, EC_data, 48);
+
+    // Null terminate the data by setting the value after the final character to 0.
+    EC_data[received_from_sensor] = 0;
+  }
+
+  // Parse data, if EC_data begins with a digit, not a letter (testing ASCII values).
+  if ((EC_data[0] >= 48) && (EC_data[0] <=57)) {
+    parse_data();
+  }
+
+  delay(10);  // Wait 10 milliseconds.
+
+  // Read temperature sensors.
+  sensors.requestTemperatures();
+  tempA = sensors.getTempCByIndex(0);
+  tempB = sensors.getTempCByIndex(1);
+  tempC = sensors.getTempCByIndex(2);
+
+  // Log to the SD card...
+  File dataFile = SD.open("datalog.txt", FILE_WRITE);
+  if (dataFile) {
+    dataFile.print(sensor.getPressure(ADC_4096));
+    dataFile.print("  ");
+    dataFile.print(tempA);
+    dataFile.print("  ");
+    dataFile.print(tempB);
+    dataFile.print("  ");
+    dataFile.print(tempC);
+    dataFile.print("  ");
+    dataFile.println(EC);
+    dataFile.close();
+  }
+  else {
+
+  }
+
+  // Log to the serial monitor.
+  Serial.print(sensor.getPressure(ADC_4096));
+  Serial.print("  ");
+  Serial.print(tempA);
+  Serial.print("  ");
+  Serial.print(tempB);
+  Serial.print("  ");
+  Serial.print(tempC);
+  Serial.print("  ");
+  Serial.print(EC);
+  Serial.println("");
+
+  delay(50);  // Wait 50 milliseconds.
+}
+
+
+// Parses data from the EC Circuit.
+void parse_data() {
+
+  EC = strtok(EC_data, ",");
+
+}


version active 13/9

version active 13/9

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/janiversen/SolarPower.git/'


Adding the arduino code

Adding the arduino code

error: pathspec 'src/TemperatureHumidityMonitor.ino' did not match any file(s) known to git

--- src/TemperatureHumidityMonitor.ino
+++ src/TemperatureHumidityMonitor.ino
@@ -0,0 +1,156 @@
+//
+// Arduino temperature & humidity monitor/logger
+//
+// ------------------------------------------------------------------------
+//
+// The MIT License (MIT)
+//
+// Copyright (c) 2014 Dan Cotora
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+//
+// ------------------------------------------------------------------------
+//
+// This Arduino code can be used to monitor the current temperature and humidity
+// from a DHT sensor and log the data to an SD card.
+//
+// The program also relies on a DS1307 RTC for time keeping.
+//
+// Data is read and recorded on the SD card every 60 seconds.
+//
+
+#include <Wire.h>
+#include <DHT.h>
+#include <RTClib.h>
+#include <SdFat.h>
+
+#define DHTPIN 7
+#define DHTVCCPIN 2
+#define DHTTYPE DHT22
+#define CSPIN 4
+#define LEDPIN 9
+
+RTC_DS1307 RTC;
+DHT dht(DHTPIN, DHTTYPE);
+SdFat sd;
+SdFile csvFile;
+
+void setup() {
+  pinMode(DHTVCCPIN, OUTPUT);
+  pinMode(LEDPIN, OUTPUT);
+
+  Serial.begin(9600);
+
+  Serial.println("Initializing the microSD card...");
+  while (!sd.begin(CSPIN, SPI_HALF_SPEED)) {
+    sd.initErrorPrint();
+    delay(1000);
+  }
+
+  Serial.println("Initializing RTC...");
+  Wire.begin();
+  RTC.begin();
+
+  Serial.println("Initializing the DHT sensor...");
+  dht.begin();
+}
+
+void loop() {
+  // Power the DHT sensor
+  digitalWrite(DHTVCCPIN, HIGH);
+  digitalWrite(LEDPIN, HIGH);
+
+  // Wait 1 second for the sensor and SD card to stabilize
+  delay(1000);
+
+  // Get the current date
+  DateTime now = RTC.now();
+
+  // Read the temperature and the humidity
+  float h = dht.readHumidity();
+  float t = dht.readTemperature();
+
+  // Turn off the sensor
+  digitalWrite(DHTVCCPIN, LOW);
+
+  // Check if returns are valid, if they are NaN (not a number) then something went wrong!
+  if (isnan(t) || isnan(h)) {
+    Serial.println("Failed to read from DHT sensor");
+    digitalWrite(LEDPIN, LOW);
+    return;
+  }
+
+  // Open the CSV file for writing
+  while (!csvFile.open("monitor.csv", O_RDWR | O_CREAT | O_AT_END)) {
+    sd.errorPrint("Failed to open monitor.csv for writing");
+    delay(1000);
+  }
+
+  // Print the current date to the console
+  Serial.print(now.year(), DEC);
+  Serial.print('/');
+  Serial.print(now.month(), DEC);
+  Serial.print('/');
+  Serial.print(now.day(), DEC);
+  Serial.print(' ');
+  Serial.print(now.hour(), DEC);
+  Serial.print(':');
+  Serial.print(now.minute(), DEC);
+  Serial.print(':');
+  Serial.print(now.second(), DEC);
+  Serial.print("\t");
+
+  // Print the temperature and the humidity in the console
+  Serial.print("Humidity: ");
+  Serial.print(h);
+  Serial.print(" %\t");
+  Serial.print("Temperature: ");
+  Serial.print(t);
+  Serial.println(" *C");
+
+  // Write the current date in the CSV file
+  csvFile.print(now.year(), DEC);
+  csvFile.print('/');
+  csvFile.print(now.month(), DEC);
+  csvFile.print('/');
+  csvFile.print(now.day(), DEC);
+  csvFile.print(' ');
+  csvFile.print(now.hour(), DEC);
+  csvFile.print(':');
+  csvFile.print(now.minute(), DEC);
+  csvFile.print(':');
+  csvFile.print(now.second(), DEC);
+  csvFile.print(",");
+
+  // Write the temperature and the humidity in the CSV file
+  csvFile.print(h);
+  csvFile.print(",");
+  csvFile.println(t);
+
+  // Close the file
+  while (!csvFile.close()) {
+    sd.errorPrint("Failed to close monitor.csv");
+    delay(1000);
+  }
+
+  digitalWrite(LEDPIN, LOW);
+
+  // Wait 60 seconds
+  delay(60000);
+}


OSCILLATOR: first sketch

OSCILLATOR: first sketch

error: pathspec 'Oscillator/Oscillator.ino' did not match any file(s) known to git


Added particle.io app code.

Added particle.io app code.

error: pathspec 'hue-light-simulator.ino' did not match any file(s) known to git

--- hue-light-simulator.ino
+++ hue-light-simulator.ino
@@ -0,0 +1,105 @@
+boolean gPowerState = true;
+float gHue = 0.5;
+float gSaturation = 1;
+float gBrightness = 0.4;
+
+void setup()
+{
+   RGB.control(true);
+
+   updateLED();
+
+   Spark.function("powerState", powerState);
+   Spark.function("hue", hue);
+   Spark.function("saturation", saturation);
+   Spark.function("brightness", brightness);
+}
+
+int powerState(String value) {
+    int result = -1;
+
+    if (value.length() > 0) {
+        gPowerState = (value.toInt() == 1);
+        result = gPowerState;
+    }
+
+    updateLED();
+
+    return result;
+}
+
+int hue(String value) {
+    int result = -1;
+
+    if (value.length() > 0) {
+        gHue = (float)value.toInt() / 100.0;
+        result = hue.toInt();
+    }
+
+    updateLED();
+
+    return result;
+}
+
+int saturation(String value) {
+    int result = -1;
+
+    if (value.length() > 0) {
+        gSaturation = (float)value.toInt() / 100.0;
+        result = value.toInt();
+    }
+
+    updateLED();
+
+    return result;
+}
+
+int brightness(String value) {
+    int result = -1;
+
+    if (value.length() > 0) {
+        gBrightness = (float)value.toInt() / 100.0;
+        result = value.toInt();
+    }
+
+    updateLED();
+
+    return result;
+}
+
+float hueToRGB(float p, float q, float t) {
+    if(t < 0.0) t += 1.0;
+    if(t > 1.0) t -= 1.0;
+    if(t < 1.0/6.0) return p + (q - p) * 6.0 * t;
+    if(t < 1.0/2.0) return q;
+    if(t < 2.0/3.0) return p + (q - p) * (2.0/3.0 - t) * 6.0;
+
+    return p;
+}
+
+void applyHSL(float h, float s, float l) {
+    float r = 0;
+    float g = 0;
+    float b = 0;
+
+    if(s == 0) {
+        r = g = b = l;
+    } else {
+        float q = l < 0.5 ? l * (1.0 + s) : l + s - l * s;
+        float p = 2.0 * l - q;
+        r = hueToRGB(p, q, h + 1.0/3.0);
+        g = hueToRGB(p, q, h);
+        b = hueToRGB(p, q, h - 1.0/3.0);
+    }
+
+    RGB.color((int)(r*255.0), (int)(g*255.0), (int)(b*255.0));
+    RGB.brightness((int)(l*255.0));
+}
+
+void updateLED() {
+    if (gPowerState) {
+        applyHSL(gHue, gSaturation, gBrightness);
+    } else {
+        applyHSL(0, 0, 0);
+    }
+}


Initial Commit

Initial Commit

error: pathspec 'readSensors/readSensors.ino' did not match any file(s) known to git

--- readSensors/readSensors.ino
+++ readSensors/readSensors.ino
@@ -0,0 +1,203 @@
+
+#include <stdarg.h>
+#include <stdio.h>
+
+
+const int muxPin = A0;
+const int capacitorAnalogPin1 = A1;
+const int capacitorAnalogPin2 = A2;
+
+const int imuPinX = A3;
+const int imuPinY = A4;
+const int imuPinZ = A5;
+
+const int tempMux = 0;
+const int resistanceMux = 1;
+const int pressureMux = 2;
+
+const int capacitorChargePin1 = 3;
+const int capacitorChargePin2 = 4;
+
+const int imuRate = 5.; /* sampling rate in Hz */
+const float capacitorRate = .1; //dedicate to capacitor every  10 seconds
+const int muxRate = 3.0;
+
+int muxChoice = 0;
+const int capacitorResistorValue = 1000;
+
+unsigned long imuTime = 0;
+unsigned long capacitorTime = 0;
+unsigned long capacitorStartTime = 0;
+unsigned long muxTime = 0;
+
+void p(char *fmt, ... ){
+
+  int buffer = 1024;
+
+  char tmp[buffer]; // resulting string limited to 128 chars
+  va_list args;
+  va_start (args, fmt );
+  vsnprintf(tmp, buffer, fmt, args);
+  va_end (args);
+  Serial.print(tmp);
+}
+
+void jsonprint(char * key, float value, unsigned long time){
+  p("{\"%s\": %f, \"time\": %u}\n", key, value, time);
+}
+
+int my_putc( char c, FILE *t) {
+  Serial.write( c );
+}
+void setup(){
+  Serial.begin(115200);
+  DDRD = DDRD | B11100000; // set digital ports 5-7 as writes for mux
+  pinMode(capacitorChargePin1, OUTPUT);
+  pinMode(capacitorChargePin2, OUTPUT);
+  digitalWrite(capacitorChargePin1, LOW); //discharge capacitor
+  digitalWrite(capacitorChargePin2, LOW); //discharge capacitor
+  fdevopen( &my_putc, 0);
+
+}
+
+void loop(){
+  samplePorts();
+}
+
+void capacitorRead(){
+  const int length = 200;
+  printf("in capacitor read");
+  int capacitor1Data [length] = {0};
+  int capacitor2Data [length] = {0};
+  long capacitorTimeData[length] = {0};
+
+  printf("after allocation");
+
+  long looptimestart = micros();
+  while(analogRead(capacitorAnalogPin1) > 0){         // wait until capacitor is completely discharged
+
+    if (micros() - looptimestart > 1000*2){ //too long in loop (infinite loop threat)
+      //Serial.print("break discharge, analog: " + analogRead(capacitorAnalogPin));
+      break;
+    }
+  }
+  printf("discharged capacitor");
+  PORTD = capacitorChargePin1 | capacitorChargePin2; // set capacitorChargePin HIGH and capacitor charging
+  long startTime = micros();
+  looptimestart = micros();
+
+  int index = 0;
+  int cap1Value = 0;
+  int cap2Value = 0;
+
+  do{       // 647 is 63.2% of 1023, which corresponds to full-scale voltage
+
+    cap1Value = analogRead(capacitorAnalogPin1);
+    cap2Value = analogRead(capacitorAnalogPin2);
+    long tt = micros();
+    capacitor1Data[index] = cap1Value;
+    capacitor2Data[index] = cap2Value;
+    capacitorTimeData[index] = tt;
+    index++;
+
+    delay(10);
+
+    if (tt - looptimestart > 1000*2){ //too long in loop (infinite loop threat)
+      //Serial.print("break charge loop, analog: " + analogRead(capacitorAnalogPin));
+      break;
+    }
+  }
+  while ( cap1Value < 800 || cap2Value < 800);
+  delay(100);
+  printf("{\"capacitor1\": [%d", capacitor1Data[0]);
+  for (int i = 1; i< index;i++){
+    delay(100);
+    printf(", %d", capacitor1Data[i]);
+
+  }
+  delay(10);
+
+  printf("],\"capacitor2\": [%d", capacitor2Data[0]);
+  for (int i = 1; i< index;i++){
+    delay(10);
+
+    printf(", %d", capacitor2Data[i]);
+  }
+  delay(10);
+
+  printf("],\"capacitorIime\": [%d", capacitorTimeData[0]);
+  for (int i = 1; i< index;i++){
+    delay(10);
+
+    printf(", %l", capacitorTimeData[i]);
+  }
+  delay(10);
+
+  printf("],\"time\": %l\n", millis());
+
+  /* dicharge the capacitor  */
+  digitalWrite(capacitorChargePin1, LOW);             // set charge pin to  LOW
+  digitalWrite(capacitorChargePin2, LOW);             // set charge pin to  LOW
+}
+
+void samplePorts() /*sample ports and send over serial according to rates*/
+
+{
+  unsigned long time = millis();
+
+  if (time - imuTime > 1000/imuRate) /* sample imu pins */ {
+    unsigned long t = millis();
+    int imuX = analogRead(imuPinX);
+    int imuY = analogRead(imuPinY);
+    int imuZ = analogRead(imuPinZ);
+
+    p("{\"imux\": %d, \"imuy\": %d, \"imuz\": %d, \"time\": %u}\n", imuX, imuY, imuZ, time);
+
+    imuTime = time;
+  }
+
+  if (time - capacitorTime > 1000/capacitorRate) /* sample capacitorPin */ {
+    capacitorRead();
+    capacitorTime = millis();
+  }
+
+  if (time - muxTime > 1000/muxRate) /* sample mux */ {
+
+    switch(muxChoice){
+    case 0:
+      PORTD = tempMux;
+      break;
+    case 1:
+      PORTD = resistanceMux;
+      break;
+    case 2:
+      PORTD = pressureMux;
+      break;
+    }
+
+    int muxVal = analogRead(muxPin);
+    muxTime = time;
+
+    switch(muxChoice){
+    case 0:
+      jsonprint("temperature", muxVal, millis());
+      break;
+    case 1:
+      jsonprint("resistance", muxVal, millis());
+      break;
+    case 2:
+      jsonprint("pressure", muxVal, millis());
+      break;
+    }
+
+    muxChoice = (muxChoice+1)%3;
+
+  }
+
+}
+
+
+
+
+
+


sketch to dump 1 sector of memory to serial monitor

error: pathspec 'reader_test/reader_test.ino' did not match any file(s) known to git

--- reader_test/reader_test.ino
+++ reader_test/reader_test.ino
@@ -0,0 +1,92 @@
+#include <SoftwareSerial.h>
+
+#define RDM880_RX 2
+#define RDM880_TX 3
+#define bufferSize 255
+
+#define STX 0xAA
+#define ETX 0xBB
+
+#define CMD_READ 0x20
+#define CMD_GET_SNR 0x25
+
+SoftwareSerial RDM880(RDM880_RX, RDM880_TX);
+char txrxbuffer[bufferSize];
+
+const int ledPin = 13;
+
+void setup() {
+	Serial.begin(57600);
+	RDM880.begin(9600);
+	pinMode(ledPin, OUTPUT);
+}
+
+void loop() {
+	bool standby = true;
+	bool responseFlag = false;
+
+
+}
+
+unsigned char checksum(unsigned char A[], int numElements) {
+	int i = 0;
+	unsigned char BCC = A[0];
+
+	for(i = 1; i < numElements - 1; i++) {
+		BCC ^= A[i];
+	}
+
+	return BCC;
+}
+
+void MF_SNR(unsigned char DADD) {
+	unsigned char A[] = { DADD, 0x03, CMD_GET_SNR, 0x26, 0x00 };
+	unsigned char BCC = checksum(A, sizeof(A)/sizeof(A[0]));
+	unsigned char CMD[] = { STX, DADD, 0x03, CMD_GET_SNR, 0x26, 0x00, BCC, ETX };
+	RDM880.write(CMD, sizeof(CMD)/sizeof(CMD[0]));
+}
+
+unsigned char detectCard(bool responseFlag) {
+  int i = 0;
+  unsigned char response[bufferSize];
+  response[7] = NULL;
+
+  while(RDM880.available()) {
+    response[i] = RDM880.read();
+    Serial.print(response[i], HEX);
+    Serial.print(" ");
+    i++;
+  }
+
+  if (response[7] != NULL)
+    return true;
+  else
+    return false;
+}
+
+void MF_READ(unsigned char numBlocks, unsigned char startSector) {
+	int i = 0;
+	unsigned A[] = { TX, 0x00, 0x0A, CMD_READ, 0x01, numBlocks, startSector,
+                        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+    unsigned char BCC = checksum(A, sizeof(A)/sizeof(A[0]));
+    unsigned char CMD[] = { STX, 0x00, 0x0A, CMD_READ, 0x01, numBlocks, startSector,
+                          0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, BCC, ETX };
+	unsigned char response[bufferSize];
+
+  	// send command
+	RDM880.write(CMD, sizeof(CMD)/sizeof(CMD[0]));
+
+  	// get response packet and print
+	while(RDM880.available()) {
+		response[i] = RDM880.read();
+		Serial.print(response[i], HEX);
+		if(i == 7)
+			Serial.println();
+		else if(i == 23 || i == 39 || i == 55 || i == 71 || i == 87)
+			Serial.println();
+		else if()
+		else
+			Serial.print(" ");
+		i++;
+	}
+}


we want to know where we are heading …

we want to know where we are heading …

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/trinamic/T-Bone.git/'


Folder structure

Folder structure

error: pathspec 'Arduino/LightController/LightController.ino' did not match any file(s) known to git

--- Arduino/LightController/LightController.ino
+++ Arduino/LightController/LightController.ino
@@ -0,0 +1,203 @@
+/*
+ * Name:	LightController.ino
+ * Author:	User "benjaf" at plantedtank.net forums
+ * URL:		https://github.com/benjaf/LightController
+ *
+ * This is an 'advanced' 24 hour light scheduler.
+ * It allows for easy creation of pretty much any 24 hour light schedule imaginable within the limitations of the Arduino used.
+ * Limitations:
+ * - Schedule cannot exceed 24 hours (no handling of differences based on weekday, time of year etc.)
+ * - Max number of channels: Defined by the number of PWN pins available on the Arduino used
+ * - Max number of on/off cycles during a day: Any
+ * - Precision:
+ *   - PWN duty cycle: 0-255
+ *   - Time-to-PWM precision: 1 second (making the shortest fade timespan in which full PWM resolution is used 255 seconds)
+ *
+ * This is not intended to be a complete aquarium or light controller.
+ * It merely provides you with the code to handle light scheduling!
+ *
+ * You will need to download and install "RTClib" for this to work.
+ *
+ * I have NOT included any code for interfaces (Serial, LCD, etc.), nor any delays.
+ * That would make the sketch more context-specific because it depends on the users actual setup.
+ * Communication via Serial is easy to find documentation on elsewhere.
+ * It should be noted that this code contains no delays! If you start sending data (i.e. via Serial)
+ * you might want to make sure this is only done at apropriate intervals.
+ *
+ * This version uses 2 PWM pins because I only have 2 channels in my setup.
+ * More channels are easy to add, but some basic understanding of arrays is recommended.
+ * Fore more advanced changes, the user (you) should have basic understanding of programming.
+ * This includes:
+ * - For-loops (and break conditions)
+ * - Multi-dimensional arrays
+ *
+ * As is probably evident from the code, I am not that experianced with writing software for microcontrollers.
+ * Several optimizations are possible, but I tried to shoot for at least some degree of readability.
+ */
+
+/*
+ * Copyright (c) 2013, User "benjaf" at plantedtank.net forums
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <Wire.h>
+#include <RTClib.h>
+
+// ----------------------- Pins -----------------------
+// PWM Pins
+// Please note: Some PWM pins should not be used for lights -
+// On the Uno these are pins 5 and 6. They do not behave like the others
+// due to some shared timers!
+#define L1Pin 9
+#define L2Pin 10
+// ... and so on
+
+// ----------------------- Named Values -----------------------
+#define CHANNELS 2		// Number of channels, change if more are required
+#define MAXPERIODS 5	// Max number of light periods, change if more are required
+
+// These are just used to make the lookup code more easily readable:
+#define START_H 0
+#define START_M 1
+#define END_H 2
+#define END_M 3
+#define INTENSITY 4
+
+// ----------------------- Variables -----------------------
+// RTC
+RTC_DS1307 RTC;
+
+// Time
+int Hours, Minutes, Seconds;
+
+// ----------------------- Lights -----------------------
+// Light period format: {HourStart, MinuteStart, HourEnd, MinuteEnd, Intensity}
+
+// Gap between light periods is used to fade/increase intensity gradually
+// Example: {0, 0, 8, 0, 0}, {8, 30, 11, 0, 255} ...
+// Explanation:
+//  00:00 - 08:00 -> Light OFF
+//  08:00 - 08:30 -> Increment light towards desired intensity
+//  08:30 - 11:00 -> Light Fully ON
+
+// Min intensity value: 0 (OFF)
+// Max intensity value: 255 (Fully ON)
+// First StartTime value MUST be 00:00
+// SOME EndTime value MUST be 24:00
+
+// Any row ending with 24:00 will be considered last.
+// Not all periods must be filled with meaningfull values for each channel.
+// Periods must always be chronological and without overlaps.
+// There must always be rows defined for the max number of periods, but not all have to be valid
+// Example: {{0, 0, 24, 0, 255},{0, 0, 0, 0, 0},{0, 0, 0, 0, 0},{0, 0, 0, 0, 0}}
+// Explanation:
+// Channel is ALWAYS FULLY ON.
+// As the first period never ends, the remaining rows are only there to fill out the necessary space.
+
+// Add more timing tables if more channels are added
+
+int lightMatrix[CHANNELS][MAXPERIODS][5] =
+{
+	{
+		{0, 0, 8, 0, 0},
+		{8, 30, 11, 0, 255},
+		{11, 10, 13, 0, 0},
+		{13, 10, 20, 0, 255},
+		{20, 30, 24, 0, 0}
+	},{
+		{0, 0, 7, 45, 0},
+		{8, 0, 11, 0, 255},
+		{11, 10, 13, 0, 0},
+		{13, 10, 20, 30, 255},
+		{20, 45, 24, 0, 0}
+	}
+	// ... and so on
+};
+
+// Current light intensity table
+// Number of values should match number of channels (i.e. {0,0,0} for 3 channels)
+int lightValue[CHANNELS] = {0, 0};
+
+// ----------------------- Functions -----------------------
+void UpdateLights(long seconds)		// Update light intensity values
+{
+	for(int channel = 0; channel < CHANNELS; channel++) {  		// For each Channel
+		for(int period = 0; period < MAXPERIODS; period++) {    // For each possible period
+			long pEnd = GetSeconds(lightMatrix[channel][period][END_H], lightMatrix[channel][period][END_M], 0);	// Get period end time in seconds
+			if(pEnd >= seconds) {				// Period is currently happening
+				lightValue[channel] = lightMatrix[channel][period][INTENSITY];	// Set light to defined value
+				break;		// Found correct period, don't check the rest
+			} else {		// Period has not yet happened
+				long pNextStart = GetSeconds(lightMatrix[channel][period+1][START_H], lightMatrix[channel][period+1][START_M], 0); // Get next period start time in seconds
+				if(pNextStart > seconds) {					// Currently in between periods
+					int preVal = lightMatrix[channel][period][INTENSITY];		// Old light value
+					int postVal = lightMatrix[channel][period+1][INTENSITY];	// New light value
+					int tDur = pNextStart - pEnd; 			// Transition duration
+					int intensityDiff = postVal - preVal;	// Difference in light intesity between periods
+					if(intensityDiff > 0) {		// Intensity increasing
+						lightValue[channel] = (int)((seconds - pEnd) * ((float)intensityDiff / tDur));		// Light value
+					} else {					// Intensity decreasing
+						lightValue[channel] = preVal - (int)((seconds - pEnd) * ((float)(0-intensityDiff) / tDur));	// Light value
+					}
+					break;	// Found correct period, don't check the rest
+				}
+			}
+		}
+	}
+}
+
+long GetSeconds(int hours, int minutes, int seconds)	// Convert HH:mm:ss -> Seconds since midnight
+{
+	return ((long)hours * 60 * 60) + (minutes * 60) + seconds ;
+}
+
+// ----------------------- Setup -----------------------
+void setup()
+{
+	// Set analog pins
+	pinMode(L1Pin, OUTPUT);
+	pinMode(L2Pin, OUTPUT);
+	// ... and so on
+
+	// Clock
+	Wire.begin();
+	RTC.begin();
+	//RTC.adjust(DateTime(__DATE__, __TIME__));  // Set RTC time, only use for 1 (ONE) run. Will reset time at each device reset!
+}
+
+// ----------------------- Loop -----------------------
+void loop(){
+	// Get Time
+	DateTime now = RTC.now();
+	Hours = now.hour();
+	Minutes = now.minute();
+	Seconds = now.second();
+
+	// Update actual light intensity to match values defined in lightValue[]
+	UpdateLights(GetSeconds(Hours, Minutes, Seconds));
+	analogWrite(L1Pin, lightValue[0]);
+	analogWrite(L2Pin, lightValue[1]);
+	// ... and so on
+}


first commit of adaptive and configurable wemos dht sensor

error: pathspec 'Arduino/AdaptiveDHTWemosMiniMQTSensor/AdaptiveDHTWemosMiniMQTSensor.ino' did not match any file(s) known to git

--- Arduino/AdaptiveDHTWemosMiniMQTSensor/AdaptiveDHTWemosMiniMQTSensor.ino
+++ Arduino/AdaptiveDHTWemosMiniMQTSensor/AdaptiveDHTWemosMiniMQTSensor.ino
@@ -0,0 +1,59 @@
+#include <DHT.h>
+#include "config.h"
+#include <PubSubClient.h>
+#include <ESP8266WiFi.h>
+
+#define SECONDS_DS(seconds)  ((seconds)*1000000UL)
+
+WiFiClient espClient;
+PubSubClient client(espClient);
+DHT dht(DHTPIN, DHTTYPE);
+
+long lastMsg=0;
+int value =0;
+const char* mqtt_server = MQTTSERVER;
+char msg[71];
+char str_humidity[10], str_temperature[10];
+
+void setup()
+{
+  pinMode(D0, WAKEUP_PULLUP);
+ setup_wifi();
+ float h = dht.readHumidity();
+
+}
+
+
+void setup_wifi() {
+  WiFi.begin(WIFINETWORK, WIFIPASSWORD);
+  client.setServer(mqtt_server, 1883);
+}
+
+void reconnect() {
+  while (!client.connected()) {
+    String clientId = "ESP8266Client-";
+    clientId += String(random(0xffff), HEX);
+    // Attempt to connect
+    if (client.connect(clientId.c_str())) {
+      float h = dht.readHumidity();
+    float t = dht.readTemperature();
+    dtostrf(h, 1, 2, str_humidity);
+    dtostrf(t, 1, 2, str_temperature);
+    snprintf (msg, 75, "1,%s,%s",str_humidity,str_temperature);
+    client.publish(MQTOPIC, msg);
+    int time=55;
+    if(ADAPTIVECLAUSE)
+      time=time*ADAPTIVEMULTIPLIER;
+    delay(3000);
+    ESP.deepSleep(SECONDS_DS(time));
+    } else {
+      delay(2000);
+    }
+  }
+}
+
+void loop() {
+   if (!client.connected()) {
+    reconnect();
+  }
+}


Added sensor code.

Added sensor code.

error: pathspec 'sensors/plantSensors.ino' did not match any file(s) known to git

--- sensors/plantSensors.ino
+++ sensors/plantSensors.ino
@@ -0,0 +1,65 @@
+#include<Wire.h>
+#include "DHT11.h"
+
+#define moistureSensor 5
+#define tempSensor 4
+#define DHT11PIN 8
+#define lightSensor 3
+
+dht11 DHT11;
+
+void setup() {
+  // Serial Begin so we can see the data from the mosture sensor in our serial input window.
+  Serial.begin(9600);
+}
+
+double Thermistor(int RawADC) {
+  double temp;
+  temp = log(((10240000/RawADC) - 10000));
+  temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temp * temp ))* temp );
+  temp = temp - 273.15;
+  return temp;
+}
+
+void loop() {
+  Serial.println("Sensor data");
+  Serial.println("--------------------");
+
+  // read the input on analog pin 0:
+  int moistureValue = analogRead(moistureSensor);
+  Serial.print("Moisture: ");
+  Serial.println(moistureValue);
+
+  int tempValue=analogRead(tempSensor);
+  double temp =  Thermistor(tempValue);
+  Serial.print("Temp. : ");
+  Serial.print(temp);
+  Serial.println(" Celsius");
+
+  int chk = DHT11.read(DHT11PIN);
+
+  switch (chk) {
+    case DHTLIB_OK:
+    Serial.print("Humidity (%): ");
+    Serial.println((float)DHT11.humidity, 2);
+    Serial.print("Temp. (oC): ");
+    Serial.println((float)DHT11.temperature, 2);
+    break;
+    case DHTLIB_ERROR_CHECKSUM:
+    Serial.println("Checksum error");
+    break;
+    case DHTLIB_ERROR_TIMEOUT:
+    Serial.println("Time out error");
+    break;
+    default:
+    Serial.println("Unknown error");
+    break;
+  }
+
+  int lightValue = analogRead(lightSensor);
+  Serial.print("Light: ");
+  Serial.println(lightValue);
+
+  delay(1000);        // delay 1 second between reads
+}
+


Create multiple_animations.ino

Create multiple_animations.ino

error: pathspec 'multiple_animations.ino' did not match any file(s) known to git

--- multiple_animations.ino
+++ multiple_animations.ino
@@ -0,0 +1,127 @@
+/*********************************************************************/
+// Example of running multiple animations/patterns at the same time
+// on different parts of the same LED strip.  Seperate "working" or
+// "temporary" arrays are used for each section.  Whenever one of
+// these working arrays is updated then the data is copied to the
+// "leds" array so it can be displayed.
+//
+// Animation A [ledsA] is running a chase effect.
+// Animation B [ledsB] is cycling through the rainbow.
+// Animation C [ledsC] is running a scanner/cylon type effect.
+// Animation D [ledsD] is lighting up random pixels.
+//
+// Note that there is only one FastLED.show() call in the program.
+//
+//
+// Marc Miller,  April 2019
+/*********************************************************************/
+
+#include "FastLED.h"
+#define LED_TYPE LPD8806
+#define DATA_PIN 11
+#define CLOCK_PIN 13
+#define COLOR_ORDER GRB
+#define MASTER_BRIGHTNESS 255
+
+#define NUM_LEDS 32
+
+//Note: numA thru numD values must add up to NUM_LEDS
+#define numA 5    //pixels 0-4
+#define numB 3    //pixels 5-7
+#define numC 16   //pixels 8-23
+#define numD 8    //pixels 24-31
+
+CRGB leds[NUM_LEDS];  //what actually gets displayed
+CRGB ledsA[numA];     //numA thru numD are "working" arrays
+CRGB ledsB[numB];
+CRGB ledsC[numC];
+CRGB ledsD[numD];
+
+
+/*********************************************************************/
+void setup() {
+  Serial.begin(115200);  //allow for output to serial monitor
+  delay(2500);  //power up delay
+  FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
+  FastLED.setBrightness(MASTER_BRIGHTNESS);
+  FastLED.clear();
+  Serial.println("setup done");
+}//end_setup
+
+
+/*********************************************************************/
+void loop() {
+
+  //--------------Animation A--------------
+  static uint8_t color;
+  EVERY_N_MILLISECONDS(180) {
+    fadeToBlackBy( ledsA, numA, 230);
+    static uint8_t i = 0;
+    ledsA[i] = CHSV( color+random8(0,10), 160, 255 );
+    i++;
+    if (i == numA) { i = 0; }  //reset
+
+    //copy ledsA data to leds
+    for (uint8_t i=0; i<numA; i++) { leds[i] = ledsA[i]; }
+  }
+
+  EVERY_N_SECONDS(2) {
+    color = random8();
+  }
+
+
+  //--------------Animation B--------------
+  const uint8_t delta = 255/numB/5;
+  static uint8_t count;
+  EVERY_N_MILLISECONDS(60) { count++; }
+  fill_rainbow(ledsB, numB, count, -1*delta );
+
+  //copy ledsB data to leds
+  for (uint8_t i=0; i<numB; i++) { leds[i+numA] = ledsB[i]; }
+
+
+  //--------------Animation C--------------
+  for (uint8_t i=0; i<numC; i++) {
+    uint8_t blue = (millis()/30)+(i*3);
+    if (blue < 128) {
+      ledsC[i] = CRGB(200, 0, 0);
+    } else {
+      ledsC[i] = CRGB(50, 0, blue);
+    }
+  }
+  fadeToBlackBy( ledsC, numC, 220);
+  uint8_t pos = beatsin8(20,0,numC-1);
+  ledsC[pos] = CRGB::Green;
+
+  //copy ledsC data to leds
+  for (uint8_t i=0; i<numC; i++) { leds[i+numA+numB] = ledsC[i]; }
+
+
+  //--------------Animation D--------------
+  EVERY_N_MILLISECONDS(400) {
+    for (uint8_t i=0; i<3; i++) {  //lightup some random pixels
+      uint8_t pick = random8(numD);
+      static uint8_t hue;
+      ledsD[pick] = CHSV( hue, random8(128,200), random8(200,255) );
+      hue = hue + random8(4,8);
+    }
+
+    //copy ledsD data to leds
+    for (uint8_t i=0; i<numD; i++) { leds[i+numA+numB+numC] = ledsD[i]; }
+  }
+
+  EVERY_N_MILLISECONDS(200) {
+    uint8_t pick = random8(numD);
+    ledsD[pick] = CRGB::Black;
+
+    //copy ledsD data to leds
+    for (uint8_t i=0; i<numD; i++) { leds[i+numA+numB+numC] = ledsD[i]; }
+  }
+
+
+
+  //display all the updates on leds array
+  FastLED.show();
+
+}//end_main_loop
+


Add serial output

Add serial output

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/jaredkotoff/CSUFIEEECS.git/'


message

message

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/markwatneyy/ttt_arduino.git/'


Added the actual code.

Added the actual code.

error: pathspec 'code/lissajous/lissajous.ino' did not match any file(s) known to git

--- code/lissajous/lissajous.ino
+++ code/lissajous/lissajous.ino
@@ -0,0 +1,47 @@
+// Sweep
+// by BARRAGAN <http://barraganstudio.com>
+// This example code is in the public domain.
+
+
+#include <Servo.h>
+
+Servo servox;  // create servo object to control a servo
+Servo servoy; // a maximum of eight servo objects can be created
+
+double pos = 0;    // variable to store the servo position
+float spd = 0.005;
+float facter = 1.0;
+float starter = 0;
+int adjx = 90;
+int adjy = 90;
+float decay = 60000;
+
+void setup()
+{
+  servox.attach(9);  // attaches the servo on pin 9 to the servo object
+  servoy.attach(10);  // attaches the servo on pin 10 to the servo object
+  pinMode(2, INPUT_PULLUP);
+  randomSeed(analogRead(0));
+}
+
+
+void loop()
+{
+  while (digitalRead(2) != 0)
+  {
+    delay(10);
+    facter = random(2001, 2021)/1000.0;
+    starter = random(3141)/1000.0;
+  }
+  for(pos = 0; pos < decay*0.9; pos += 1)
+  {
+    adjx = int(90 + int(70 * (1 - pos/decay) * sin(pos * spd)));
+    adjy = int(90 + int(70 * (1 - pos/decay) * sin(starter + (pos * spd * facter))));
+    servox.write(adjx);
+    servoy.write(adjy);
+    delay(1);                       // waits 15ms for the servo to reach the position
+  }
+  servox.write(90);
+  servoy.write(90);
+}
+


firmware: consistent logging & de-cruft

firmware: consistent logging & de-cruft

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/wsnook/farm.git/'


Create mp3due.ino

Create mp3due.ino

test of library working on ... (glichy)

error: pathspec 'mp3due.ino' did not match any file(s) known to git

--- mp3due.ino
+++ mp3due.ino
@@ -0,0 +1,174 @@
+//#include <avr/pgmspace.h>
+
+#define PCM_BUFBYTES  3000U  // more than enough to cover the largest that one packet will ever expand to
+
+#include "mp3due.h"
+#include "riddle.h"
+
+#define sboolean int //rww - argh (in SP qboolean type is merely #define'd as an int, but I do not want to do that for MP over the whole base)
+#define qtrue  true
+#define qfalse  false
+
+
+
+byte raw_buffer[8192]; //8kB
+
+
+
+/**************************************************************************************************************************************************************************/
+
+
+// fake cvar stuff
+  //
+  typedef struct
+  {
+    int integer;
+  } cvar_t;
+
+
+
+
+// expects data already loaded, filename arg is for error printing only
+//
+// returns success/fail
+//
+sboolean MP3_IsValid( const char *psLocalFilename, void *pvData, int iDataLen, sboolean bStereoDesired /* = qfalse */)
+{
+  char *psError = C_MP3_IsValid(pvData, iDataLen, bStereoDesired);
+  if (psError)
+  {
+    Serial.print(sprintf("%s(%s)\n",psError, psLocalFilename));
+  }
+  return !psError;
+}
+
+// expects data already loaded, filename arg is for error printing only
+//
+// returns unpacked length, or 0 for errors (which will be printed internally)
+//
+int MP3_GetUnpackedSize( const char *psLocalFilename, void *pvData, int iDataLen, sboolean qbIgnoreID3Tag /* = qfalse */ , sboolean bStereoDesired /* = qfalse */ )
+{
+  int iUnpackedSize = 0;
+
+  // always do this now that we have fast-unpack code for measuring output size... (much safer than relying on tags that may have been edited, or if MP3 has been re-saved with same tag)
+  //
+  if (1)//qbIgnoreID3Tag || !MP3_ReadSpecialTagInfo((byte *)pvData, iDataLen, NULL, &iUnpackedSize))
+  {
+    char *psError = C_MP3_GetUnpackedSize( pvData, iDataLen, &iUnpackedSize, bStereoDesired);
+
+    if (psError)
+    {
+      Serial.print(sprintf("%s\n(File: %s)\n",psError, psLocalFilename));
+      return 0;
+    }
+  }
+
+  return iUnpackedSize;
+}
+
+// expects data already loaded, filename arg is for error printing only
+//
+// returns byte count of unpacked data (effectively a success/fail bool)
+//
+int MP3_UnpackRawPCM( const char *psLocalFilename, void *pvData, int iDataLen, void *pbUnpackBuffer, sboolean bStereoDesired /* = qfalse */)
+{
+  int iUnpackedSize;
+  char *psError = C_MP3_UnpackRawPCM( pvData, iDataLen, &iUnpackedSize, pbUnpackBuffer, bStereoDesired);
+
+  if (psError)
+  {
+      Serial.print(sprintf("%s\n(File: %s)\n",psError, psLocalFilename));
+    return 0;
+  }
+
+  return iUnpackedSize;
+}
+
+
+// psLocalFilename is just for error reporting (if any)...
+//
+sboolean MP3Stream_InitPlayingTimeFields( LP_MP3STREAM lpMP3Stream, const char *psLocalFilename, void *pvData, int iDataLen, sboolean bStereoDesired /* = qfalse */)
+{
+  sboolean bRetval = qfalse;
+
+  int iRate, iWidth, iChannels;
+
+  char *psError = C_MP3_GetHeaderData(pvData, iDataLen, &iRate, &iWidth, &iChannels, bStereoDesired );
+  if (psError)
+  {
+    //Com_Printf(va(S_COLOR_RED"MP3Stream_InitPlayingTimeFields(): %s\n(File: %s)\n",psError, psLocalFilename));
+      Serial.print(sprintf("MP3Stream_InitPlayingTimeFields(): %s\n(File: %s)\n",psError, psLocalFilename));
+  }
+  else
+  {
+    int iUnpackLength = MP3_GetUnpackedSize( psLocalFilename, pvData, iDataLen, qfalse, // sboolean qbIgnoreID3Tag
+                          bStereoDesired);
+    if (iUnpackLength)
+    {
+      lpMP3Stream->iTimeQuery_UnpackedLength  = iUnpackLength;
+      lpMP3Stream->iTimeQuery_SampleRate    = iRate;
+      lpMP3Stream->iTimeQuery_Channels    = iChannels;
+      lpMP3Stream->iTimeQuery_Width     = iWidth;
+
+      bRetval = qtrue;
+    }
+  }
+
+  return bRetval;
+}
+
+float MP3Stream_GetPlayingTimeInSeconds( LP_MP3STREAM lpMP3Stream )
+{
+  if (lpMP3Stream->iTimeQuery_UnpackedLength) // fields initialised?
+    return (float)((((double)lpMP3Stream->iTimeQuery_UnpackedLength / (double)lpMP3Stream->iTimeQuery_SampleRate) / (double)lpMP3Stream->iTimeQuery_Channels) / (double)lpMP3Stream->iTimeQuery_Width);
+
+  return 0.0f;
+}
+
+/*
+float MP3Stream_GetRemainingTimeInSeconds( LP_MP3STREAM lpMP3Stream )
+{
+  if (lpMP3Stream->iTimeQuery_UnpackedLength) // fields initialised?
+    return (float)(((((double)(lpMP3Stream->iTimeQuery_UnpackedLength - (lpMP3Stream->iBytesDecodedTotal * (lpMP3Stream->iTimeQuery_SampleRate / dma.speed)))) / (double)lpMP3Stream->iTimeQuery_SampleRate) / (double)lpMP3Stream->iTimeQuery_Channels) / (double)lpMP3Stream->iTimeQuery_Width);
+
+  return 0.0f;
+}*/
+
+
+
+void setup() {
+
+  Serial.begin(9600);
+  if (MP3_IsValid( "riddle.mp3", riddle, riddle_size, false)) Serial.println("mp3 has valid format.");
+
+  Serial.print( MP3_GetUnpackedSize(  "riddle.mp3", riddle, riddle_size, true, false) );
+
+  //Serial.print( MP3Stream_GetPlayingTimeInSeconds
+
+  Serial.print( MP3_UnpackRawPCM( "riddle.mp3", riddle, riddle_size, raw_buffer, false));
+
+/*   int iUnpackedSize;
+  Serial.print( C_MP3_UnpackRawPCMSector(riddle, riddle_size, &iUnpackedSize, raw_buffer, false));
+
+  Serial.println();
+  Serial.print("Total unpacked size:");
+  Serial.println(iUnpackedSize);
+
+
+
+  /*for (int tmp=0;tmp<sizeof(look_u);tmp++) {
+     Serial.print(look_u[tmp]);
+     if (tmp%64==0) Serial.println();
+  }*/
+
+    for (int tmp=0;tmp<sizeof(raw_buffer);tmp++) {
+     Serial.print(raw_buffer[tmp]);
+     if (tmp%64==0) Serial.println();
+  }
+
+}
+
+
+void loop() {
+
+}


ok in theory we can set the 4361 virutal endstop registers …


Start a blink example

Start a blink example

error: pathspec 'Examples/Blink/Blink.ino' did not match any file(s) known to git

--- Examples/Blink/Blink.ino
+++ Examples/Blink/Blink.ino
@@ -0,0 +1,50 @@
+/*
+  Blink
+  Turns on an LED on for one second, then off for one second, repeatedly.
+
+  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
+  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
+  the correct LED pin independent of which board is used.
+  If you want to know what pin the on-board LED is connected to on your Arduino model, check
+  the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
+
+  This example code is in the public domain.
+
+  modified 8 May 2014
+  by Scott Fitzgerald
+
+  modified 2 Sep 2016
+  by Arturo Guadalupi
+
+  modified 8 Sep 2016
+  by Colby Newman
+*/
+
+//#define LED_BLUE PB7
+#define LED_BLUE PD4
+#define LED_RED PD6
+#define LED_GREEN PD7
+#define LED_LORA PB4
+
+// For Bitvise Operation Simplification Defines
+#define CLR(port,pin)  (PORT ## port &= ~(1<<pin))
+#define SET(port,pin) (PORT ## port |=  (1<<pin))
+#define TOGL(port,pin)  (PORT ## port ^=  (1<<pin))
+#define READ(port,pin)  (PIN  ## port &   (1<<pin))
+#define OUT(port,pin) (DDR  ## port |=  (1<<pin))
+#define IN(port,pin)  (DDR  ## port &= ~(1<<pin))
+#define PUP(port,pin) (DDR  ## port &= ~(1<<pin));(PORT ## port |=  (1<<pin))
+#define BIT(x)      _BV(x)
+
+// the setup function runs once when you press reset or power the board
+void setup() {
+  OUT(B,4);
+}
+
+// the loop function runs over and over again forever
+void loop() {
+  SET(B,4);
+  delay(1000);                       // wait for a second
+  CLR(B,4);
+  delay(1000);                       // wait for a second
+}


Tiny bringup sketch for people with DIY hardware

error: pathspec 'bringup0.ino' did not match any file(s) known to git

--- bringup0.ino
+++ bringup0.ino
@@ -0,0 +1,41 @@
+#include <SPI.h>
+
+int CS = 8;
+
+static void hostcmd(byte a)
+{
+  digitalWrite(CS, LOW);
+  SPI.transfer(a);
+  SPI.transfer(0x00);
+  SPI.transfer(0x00);
+  digitalWrite(CS, HIGH);
+  delay(200);
+}
+
+void setup()
+{
+  Serial.begin(115200);
+  pinMode(CS, OUTPUT);
+  digitalWrite(CS, HIGH);
+  SPI.begin();
+  SPI.setClockDivider(SPI_CLOCK_DIV128);
+
+  Serial.println("SPI INIT DONE");
+
+  hostcmd(0x00);  // wake up
+  hostcmd(0x68);  // reset GPU
+}
+
+void loop()
+{
+  digitalWrite(CS, LOW);
+  Serial.println();
+  Serial.println(SPI.transfer(0x10), HEX);
+  Serial.println(SPI.transfer(0x24), HEX);
+  Serial.println(SPI.transfer(0x00), HEX);
+  Serial.println(SPI.transfer(0xff), HEX);
+  Serial.println(SPI.transfer(0xff), HEX);
+  Serial.println(SPI.transfer(0xff), HEX);
+  digitalWrite(CS, HIGH);
+  delay(1000);
+}


Added "Packeted_433_Coms" to Comms

Added "Packeted_433_Coms" to Comms

Arduino .ino containing functions for utilising 433MHz communications
with the RadioHead library. Also included some example code.

error: pathspec 'Comms' did not match any file(s) known to git
error: pathspec 'Arduino/Packeted_433_Coms.ino' did not match any file(s) known to git


anavi-thermometer.ino: Simple demo

anavi-thermometer.ino: Simple demo

Simple demo application for displaying temperature and humidity
on OLED display without WiFi connectivity.

Signed-off-by: Leon Anavi <be92910ae7bb6f58bb9b7c6f845bc30640119592@anavi.org>

error: pathspec 'anavi-thermometer/anavi-thermometer/anavi-thermometer.ino' did not match any file(s) known to git

--- anavi-thermometer/anavi-thermometer/anavi-thermometer.ino
+++ anavi-thermometer/anavi-thermometer/anavi-thermometer.ino
@@ -0,0 +1,105 @@
+#include <FS.h>                   //this needs to be first, or it all crashes and burns...
+#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
+
+// For DHT22 temperature and humidity sensor
+#include <DHT.h>
+// For OLED display
+#include <U8g2lib.h>
+#include <Wire.h>
+// For DS18B20 (waterproof) temperature sensor
+#include <OneWire.h>
+#include <DallasTemperature.h>
+
+U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
+
+#define DHTPIN  2
+#define DHTTYPE DHT22
+DHT dht(DHTPIN, DHTTYPE);
+
+#define ONE_WIRE_BUS 12
+OneWire oneWire(ONE_WIRE_BUS);
+DallasTemperature sensors(&oneWire);
+
+// Configure pins
+const int pinAlarm = 16;
+const int pinButton = 0;
+
+unsigned long sensorPreviousMillis = 0;
+const long sensorInterval = 3000;
+
+// Set temperature coefficient for calibration depending on an empirical research with
+// comparison to DS18B20 and other temperature sensors. You may need to adjust it for the
+// specfic DHT22 unit on your board
+const float temperatureCoef = 0.9;
+
+float dhtTemperature = 0;
+float dhtHumidity = 0;
+float dsTemperature = 0;
+
+void drawDisplay(const char *line1, const char *line2 = "", const char *line3 = "")
+{
+    // Write on OLED display
+    // Clear the internal memory
+    u8g2.clearBuffer();
+    // Set appropriate font
+    u8g2.setFont(u8g2_font_ncenR14_tr);
+    u8g2.drawStr(0,14, line1);
+    u8g2.drawStr(0,39, line2);
+    u8g2.drawStr(0,64, line3);
+    // Transfer internal memory to the display
+    u8g2.sendBuffer();
+}
+
+void setup()
+{
+    // put your setup code here, to run once:
+    Serial.begin(115200);
+    Serial.println();
+    u8g2.begin();
+    dht.begin();
+    sensors.begin();
+
+    delay(10);
+
+    //LED
+    pinMode(pinAlarm, OUTPUT);
+    //Button
+    pinMode(pinButton, INPUT);
+
+    drawDisplay("ANAVI Thermometer");
+}
+
+void loop()
+{
+    const unsigned long currentMillis = millis();
+    if (sensorInterval <= (currentMillis - sensorPreviousMillis))
+    {
+        sensorPreviousMillis = currentMillis;
+
+        float temp = dht.readTemperature();
+        // Adjust temperature depending on the calibration coefficient
+        temp = temp*temperatureCoef;
+        float humidity = dht.readHumidity();
+
+        if (!isnan(humidity) && !isnan(temp))
+        {
+            dhtTemperature = temp;
+            dhtHumidity = humidity;
+        }
+        String air="Air "+String(dhtTemperature, 1)+"C ";
+        Serial.println(air);
+        String hum="Humidity "+String(dhtHumidity, 0)+"%";
+        Serial.println(hum);
+
+        String water="";
+        if (0 < sensors.getDeviceCount())
+        {
+            sensors.requestTemperatures();
+            float wtemp = sensors.getTempCByIndex(0);
+            dsTemperature = wtemp;
+            water="Water "+String(dsTemperature,1)+"C";
+            Serial.println(water);
+        }
+        drawDisplay(air.c_str(), hum.c_str(), water.c_str());
+    }
+}


Updated configuration to new board design

error: pathspec 'arduino/Test' did not match any file(s) known to git
error: pathspec 'sketches/HandshakeTester/HandshakeTester.ino' did not match any file(s) known to git


Implemented another processing algorithm with reducing coefficient

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/bitbitbitbitbitbitbitbit/LineFollowing.git/'


Added Uncalibrated Humidity

Added Uncalibrated Humidity

Using RCtime examples added an uncalibrated and unscaled humidity
measurement that works with the HCH-1000 humidity sensor.

error: pathspec 'Arduino_Climate_Node/Arduino_Climate_Node.ino' did not match any file(s) known to git

--- Arduino_Climate_Node/Arduino_Climate_Node.ino
+++ Arduino_Climate_Node/Arduino_Climate_Node.ino
@@ -0,0 +1,72 @@
+// Arduino Climate Monitor Node
+// 30Aug2014
+// Adam Green (ndsoccer11122@yahoo.com)
+
+// HCH-1000 Humidity Sensor
+// 10Mohm R1
+// 220ohm R2
+
+int HumSensorPin = 4;
+
+long HumResult = 0;
+unsigned long HumTime1=0;
+unsigned long HumTime2=0;
+
+long HumReadingsPer=30.0;
+long HumReadDelay=200.0;
+
+void setup()                    // run once, when the sketch starts
+{
+
+  Serial.begin(9600);
+  Serial.println("start");      // a personal quirk
+}
+void loop()                     // run over and over again
+{
+  long H=evalHumid(HumReadingsPer, HumSensorPin);
+  Serial.println("_____");
+  Serial.println(H);
+  Serial.println("_____");
+  delay(100);
+
+}
+
+long evalHumid(long samples, int sPin){
+  long avgtime=0;
+  for (int i=0;i<samples;i++){
+    RCtime(sPin);
+    avgtime+= decayTime(3);
+  }
+  avgtime=avgtime/samples;
+  return(avgtime);
+
+}
+
+long RCtime(int sensPin){
+  long result = 0;
+  pinMode(sensPin, OUTPUT);       // make pin OUTPUT
+  digitalWrite(sensPin, HIGH);    // make pin HIGH to discharge capacitor - study the schematic
+  delay(1);                       // wait a  ms to make sure cap is discharged
+
+  pinMode(sensPin, INPUT);  // turn pin into an input and time till pin goes low
+  digitalWrite(sensPin, LOW);// turn pullups off - or it won't work
+  decayTime(1);
+  while(digitalRead(sensPin)){    // wait for pin to go low
+    //result++;
+  }
+  decayTime(2);
+  delay(readDelay);
+  //return result;                   // report results
+}
+
+long decayTime(int input){
+  if (input==1){
+    time1=micros();
+  }
+  if (input==2 ){
+    time2=micros();
+  }
+  if (input==3){
+    return (time2-time1);
+  }
+}


Add storm simulation

Add storm simulation

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/onordbo/mood-cloud.git/'


FNV1a example with implementation in the FNV library

error: pathspec 'src/FNV_v1/FNV_v1.ino' did not match any file(s) known to git

--- src/FNV_v1/FNV_v1.ino
+++ src/FNV_v1/FNV_v1.ino
@@ -0,0 +1,29 @@
+#include "fnv.h"
+
+int id = 0;
+int dlc = 0;
+unsigned char data[8] = {0};
+
+void setup() {
+  // put your setup code here, to run once:
+  Serial.begin(9600);
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  GenerateMessage(id, dlc, &data[0]);
+  uint32_t myHash = FNV::fnv1a(&data[0]);
+  Serial.println(myHash, HEX);
+  Serial.println("----------------------");
+  delay(1000);
+}
+
+void GenerateMessage(int &id, int &dlc, unsigned char *data)
+{
+    id = random(0x800); // id = random int between 0..0x7FF
+    dlc = random(9);  // dlc = random int between 0..8
+    for(int i = 0; i < dlc; i++)
+    {
+      data[i] = random(0x100); // each byte is random char between 0..0xFF
+    }
+}


Delete ESPArto_timer_functions.ino

Delete ESPArto_timer_functions.ino

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/philbowles/esparto.git/'


added blinking diode on port 12

added blinking diode on port 12

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/werar/iothome.git/'


Prox Sensor Init

Prox Sensor Init

Working version

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Blade2021/roots.git/'


Added arduino code

Added arduino code

error: pathspec 'launcher/launcher.ino' did not match any file(s) known to git

--- launcher/launcher.ino
+++ launcher/launcher.ino
@@ -0,0 +1,107 @@
+/* Arduino as USB Keyboard test
+ * A simple helloworld
+ * Aaron Eline
+ * Based on: http://mitchtech.net/arduino-usb-hid-keyboard/
+ */
+
+uint8_t buf[8] = {
+  0 }; 	/* Keyboard report buffer */
+boolean done;
+const int launchButton = 12;
+const int keySwitch = 13;
+boolean active;
+const int keyLED = 11;
+const int rcsSwitch = 10;
+int rcsBit;
+const int sasSwitch = 9;
+int sasBit;
+
+void setup()
+{
+
+  Serial.begin(9600);
+  done = false;
+  delay(200);
+  pinMode(launchButton, INPUT);
+  pinMode(keySwitch, INPUT);
+  pinMode(keyLED, OUTPUT);
+  pinMode(rcsSwitch, INPUT);
+  pinMode(sasSwitch, INPUT);
+  rcsBit = 1;
+  sasBit = 1;
+
+
+
+}
+
+
+void loop()
+{
+  int launchState;
+  launchState = digitalRead(launchButton);
+  int keyState;
+  keyState = digitalRead(keySwitch);
+  int rcsState;
+  rcsState = digitalRead(rcsSwitch);
+  int sasState;
+  sasState = digitalRead(sasSwitch);
+
+
+  if(keyState == LOW){
+    active = true;
+    digitalWrite(keyLED, HIGH);
+  }else{
+    active = false;
+    digitalWrite(keyLED, LOW);
+  }
+  if(active){
+  if(digitalRead(12) == HIGH /*&& !done*/){
+
+    sendKey(44); //Spacebar
+    //done = true;
+  }
+
+  if(rcsState == LOW && rcsBit == 1){
+    sendKey(21); //r
+    rcsBit = 0;
+  }else if (rcsState == HIGH && rcsBit == 0){
+    sendKey(21); //r
+    rcsBit = 1;
+  }
+
+  if(sasState == LOW && sasBit == 1){
+    sendKey(23); //t
+    sasBit = 0;
+  }else if (sasState == HIGH && sasBit == 0){
+    sendKey(23); //t
+    sasBit = 1;
+  }
+
+
+
+
+
+  if(done && launchState == HIGH){
+    done=false;
+  }
+  }
+
+}
+
+
+
+void releaseKey()
+{
+  buf[0] = 0;
+  buf[2] = 0;
+  Serial.write(buf, 8);	// Release key
+}
+
+void sendKey(int keyNum){
+  buf[2] = keyNum;
+  Serial.write(buf, 8);
+  releaseKey();
+}
+
+//
+


Fix include issue

Fix include issue

--- examples/02.IO/SimpleIO/SimpleIO.ino
+++ examples/02.IO/SimpleIO/SimpleIO.ino
@@ -8,5 +8,5 @@
 void loop()
 {
   bool buttonPressed = shield.buttonS1Pressed();
-  shield.setLed(RED_LED, buttonPressed);
+  shield.setLed(ParkingShield::RED_LED, buttonPressed);
 }


update example description

update example description

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/arduino-org/CiaoMCU.git/'