Première version

Première version

// mysensors
#include <SPI.h>
#include <MySensor.h>

// teleinfo
#include <SoftwareSerial.h>
#define TI_RX 4
#define TI_TX 5

// uncomment to enable debuging
#define DEBUG_ENABLED

// longueur max des données qu'on recoi
#define BUFSIZE 15

// durée entre 2 rafraichissements des données
#define SLEEP_TIME (10 * 1000)

// battery voltage calculator
// mmm la téléinfo emet un signal carré entre -25v et 25v a 1200bps, une diode, une capa, le regul du duino et hop non ?
#define BATTERY_VOLTAGE 9.0
#define BATTERY_SENSE_PIN A0
// pont diviseur de tension
#define VDIV_R1 100e3
#define VDIV_R2 10e3
// vdiv est la sensibilité de mon pont diviseur de tension
#define VDIV ( ( VDIV_R1 + VDIV_R2 ) / VDIV_R2 ) * 1.1 / 1023

MySensor gw;

// paramètres des données téléinfo
// - ne pas toucher :)
// pour mieux comprendre, allez plus bas j'ai ajouté les informations de la doc ERDF afin de s'y retrouver
///////////////////////////////////

// infos générales
///////////////////////////////////
#define CHILD_ID_ADCO 0
MyMessage msgADCO( CHILD_ID_ADCO, V_VAR1 );

#define CHILD_ID_OPTARIF 1
MyMessage msgOPTARIF( CHILD_ID_OPTARIF, V_VAR2 );

#define CHILD_ID_ISOUSC 2
MyMessage msgISOUSC( CHILD_ID_ISOUSC, V_CURRENT );

#define CHILD_ID_PTEC 3
MyMessage msgPTEC( CHILD_ID_PTEC, V_VAR3 );

#define CHILD_ID_IINST 4
MyMessage msgIINST( CHILD_ID_IINST, V_CURRENT );

#define CHILD_ID_ADPS 5
MyMessage msgADPS( CHILD_ID_ADPS, V_KWH );

#define CHILD_ID_IMAX 6
MyMessage msgIMAX( CHILD_ID_IMAX, V_CURRENT );

#define CHILD_ID_PAPP 7
MyMessage msgPAPP( CHILD_ID_PAPP, V_WATT );

// infos tarif BASE
///////////////////////////////////
#define CHILD_ID_BASE 10
MyMessage msgBASE( CHILD_ID_BASE, V_KWH );

// infos tarif HC/HP
///////////////////////////////////
#define CHILD_ID_HC_HC 20
MyMessage msgHC_HC( CHILD_ID_HC_HC, V_KWH );

#define CHILD_ID_HC_HP 21
MyMessage msgHC_HP( CHILD_ID_HC_HP, V_KWH) ;

// infos EJP
#define CHILD_ID_EJP_HN 30
MyMessage msgEJP_HN( CHILD_ID_EJP_HN, V_KWH );

#define CHILD_ID_EJP_HPM 31
MyMessage msgEJP_HPM( CHILD_ID_EJP_HPM, V_KWH );

#define CHILD_ID_PEJP 32
MyMessage msgPEJP( CHILD_ID_PEJP, V_KWH );

// infos tarif BBR (tempo)
///////////////////////////////////
#define CHILD_ID_BBR_HC_JB 40
MyMessage msgBBR_HC_JB( CHILD_ID_BBR_HC_JB, V_KWH );

#define CHILD_ID_BBR_HP_JB 41
MyMessage msgBBR_HP_JB( CHILD_ID_BBR_HP_JB, V_KWH );

#define CHILD_ID_BBR_HC_JW 42
MyMessage msgBBR_HC_JW( CHILD_ID_BBR_HC_JW, V_KWH );

#define CHILD_ID_BBR_HP_JW 43
MyMessage msgBBR_HP_JW( CHILD_ID_BBR_HP_JW, V_KWH );

#define CHILD_ID_BBR_HC_JR 44
MyMessage msgBBR_HC_JR( CHILD_ID_BBR_HC_JR, V_KWH );

#define CHILD_ID_BBR_HP_JR 45
MyMessage msgBBR_HP_JR( CHILD_ID_BBR_HP_JR, V_KWH );

#define CHILD_ID_DEMAIN 46
MyMessage msgDEMAIN( CHILD_ID_DEMAIN, V_KWH );

// sert à EJP/BBR
///////////////////////////////////
#define CHILD_ID_HHPHC 50
MyMessage msgHHPHC( CHILD_ID_HHPHC, V_VAR4 );

// connexion série avec le compteur EDF
SoftwareSerial tiSerial( TI_RX, TI_RX );

void setup() {
	// reduce clock speed (reduce power consumption)
	CLKPR = (1<<CLKPCE);
	CLKPR = B00000011; // should put the clock at 1Mhz

#ifdef DEBUG_ENABLED
	Serial.begin( 115200 );
#endif

	tiSerial.begin( 1200 );

	// use the 1.1 V internal reference
	analogReference( INTERNAL );

	gw.begin();
	gw.sendSketchInfo( "Teleinfo Sensor", "0.1" );

	gw.present( CHILD_ID_ADCO, S_POWER );
	gw.present( CHILD_ID_OPTARIF, S_POWER );
	gw.present( CHILD_ID_ISOUSC, S_POWER );
	gw.present( CHILD_ID_PTEC, S_POWER );
	gw.present( CHILD_ID_IINST, S_POWER );
	gw.present( CHILD_ID_ADPS, S_POWER );
	gw.present( CHILD_ID_IMAX, S_POWER );
	gw.present( CHILD_ID_PAPP, S_POWER );

	gw.present( CHILD_ID_BASE, S_POWER );

	gw.present( CHILD_ID_HC_HC, S_POWER );
	gw.present( CHILD_ID_HC_HP, S_POWER );

	gw.present( CHILD_ID_EJP_HN, S_POWER );
	gw.present( CHILD_ID_EJP_HPM, S_POWER );
	gw.present( CHILD_ID_PEJP, S_POWER );

	gw.present( CHILD_ID_BBR_HC_JB, S_POWER );
	gw.present( CHILD_ID_BBR_HP_JB, S_POWER );
	gw.present( CHILD_ID_BBR_HC_JW, S_POWER );
	gw.present( CHILD_ID_BBR_HP_JW, S_POWER );
	gw.present( CHILD_ID_BBR_HC_JR, S_POWER );
	gw.present( CHILD_ID_BBR_HP_JR, S_POWER );
	gw.present( CHILD_ID_DEMAIN, S_POWER );

	gw.present( CHILD_ID_HHPHC, S_POWER );
}

/*
void readBatteryLevel( MySensor &mygw ) {
	static int oldBatteryPcnt = 0;

	// get the battery Voltage
	int sensorValue = analogRead( BATTERY_SENSE_PIN );

#ifdef DEBUG_ENABLED
	Serial.print( F("Sensor Value: ") );
	Serial.println(sensorValue);
#endif

	float batteryV = sensorValue * VDIV;

#ifdef DEBUG_ENABLED
	Serial.print( F("Battery Voltage: ") );
	Serial.print( batteryV );
	Serial.println( F(" V") );
#endif

	int batteryPcnt = batteryV * 100 / BATTERY_VOLTAGE;
	if (batteryPcnt > 100)
		batteryPcnt = 100;

#ifdef DEBUG_ENABLED
	Serial.print( F("Battery percent: ") );
	Serial.print(batteryPcnt);
	Serial.println( F(" %") );
#endif

	if ( oldBatteryPcnt != batteryPcnt ) {
		// Power up radio after sleep
		mygw.sendBatteryLevel( batteryPcnt );
		oldBatteryPcnt = batteryPcnt;
	}
}
*/

typedef struct TeleInfo TeleInfo;
struct TeleInfo {
	// DOC ERDF - http://www.magdiblog.fr/wp-content/uploads/2014/09/ERDF-NOI-CPT_02E.pdf

	char ADCO[12]; //Identifiant du compteur - m'en fous
	char OPTARIF[4]; //Option tarifaire (type d’abonnement) - m'en fous
	//     juste pour memoire, les values
	//     BASE : option base
	//     HC.. : option heure creuse
	//     EJP. : option EJP
	//     BBRx : option tempo, x est un char qui indique kkchose (relooooooou les mecs)
	uint8_t ISOUSC; // : Intensité souscrite 2chars en Ampères - m'en fous
 	uint32_t BASE; // Index si option = base (en Wh)

	uint32_t HC_HC; // Index heures creuses si option = heures creuses (en Wh)
	uint32_t HC_HP; // Index heures pleines si option = heures creuses (en Wh)

	uint32_t EJP_HN; // Index heures normales si option = EJP (en Wh)
	uint32_t EJP_HPM; // Index heures de pointe mobile si option = EJP (en Wh)

	uint32_t BBR_HC_JB; // Index heures creuses jours bleus si option = tempo (en Wh)
	uint32_t BBR_HP_JB; // Index heures pleines jours bleus si option = tempo (en Wh)
	uint32_t BBR_HC_JW; // Index heures creuses jours blancs si option = tempo (en Wh)
	uint32_t BBR_HP_JW; // Index heures pleines jours blancs si option = tempo (en Wh)
	uint32_t BBR_HC_JR; // Index heures creuses jours rouges si option = tempo  (en Wh)
	uint32_t BBR_HP_JR; // Index heures pleines jours rouges si option = tempo (en Wh)

	uint8_t  PEJP; // : Préavis EJP si option = EJP 30mn avant période EJP, en minutes

	char PTEC[4]; // Période tarifaire en cours
	// les valeurs de PTEC :
	// - TH.. => Toutes les Heures.
	// - HC.. => Heures Creuses.
	// - HP.. => Heures Pleines.
	// - HN.. => Heures Normales.
	// - PM.. => Heures de Pointe Mobile.
	// - HCJB => Heures Creuses Jours Bleus.
	// - HCJW => Heures Creuses Jours Blancs (White).
	// - HCJR => Heures Creuses Jours Rouges.
	// - HPJB => Heures Pleines Jours Bleus.
	// - HPJW => Heures Pleines Jours Blancs (White).
	// - HPJR => Heures Pleines Jours Rouges

	char DEMAIN[4]; // Couleur du lendemain si option = tempo
	// valeurs de DEMAIN
	// - ---- : couleur du lendemain non connue
	// - BLEU : le lendemain est jour BLEU.
	// - BLAN : le lendemain est jour BLANC.
	// - ROUG : le lendemain est jour ROUGE.

	uint8_t IINST; // Intensité instantanée (en ampères)
	uint8_t ADPS;  // Avertissement de dépassement de puissance souscrite (en ampères)
	uint8_t IMAX;  // Intensité maximale (en ampères)
	uint32_t PAPP; // Puissance apparente (en Volt.ampères)

	char HHPHC; // Groupe horaire si option = heures creuses ou tempo
	// je comprend pas ce que veulent dire les valeurs de ce truc ... :
	// L'horaire heures pleines/heures creuses (Groupe "HHPHC")
	// est codé par le caractère alphanumérique A, C, D, E ou Y correspondant à la programmation du compteur.
};

// lecture teleinfo
char readTI() {
	while ( !tiSerial.available() );

	return tiSerial.read() & 0x7F;
}

bool atolTI( char *label, char *searchLabel, char *value, uint32_t &last, MyMessage &msg ) {
	uint32_t tmp;

	if ( strcmp( label, searchLabel ) != 0 )
		return false;

	tmp = atol( value );
	if ( last == tmp )
		return true;

#ifdef DEBUG_ENABLED
	Serial.print( label );
	Serial.print( F(" changed from ") );
	Serial.print( last );
	Serial.print( F(" to ") );
	Serial.println( tmp );
#endif

	last = tmp;
	gw.send( msg.set( last ) );

	return true;
}
bool atoiTI( char *label, char *searchLabel, char *value, uint8_t &last, MyMessage &msg ) {
	uint8_t tmp;

	if ( strcmp( label, searchLabel ) != 0 )
		return false;

	tmp = atoi( value );
	if ( last == tmp )
		return true;

#ifdef DEBUG_ENABLED
  Serial.print( label );
  Serial.print( F(" changed from ") );
  Serial.print( last );
  Serial.print( F(" to ") );
  Serial.println( tmp );
#endif

	last = tmp;
	gw.send( msg.set( last ) );

	return true;
}
bool charTI( char *label, char *searchLabel, char &value, char &last, MyMessage &msg ) {
	if ( strcmp( label, searchLabel ) != 0 )
		return false;

	if ( last == value )
		return true;

#ifdef DEBUG_ENABLED
  Serial.print( label );
  Serial.print( F(" changed from ") );
  Serial.print( last );
  Serial.print( F(" to ") );
  Serial.println( value );
#endif

	last = value;
	gw.send( msg.set( last ) );

	return true;
}
bool strTI( char *label, char *searchLabel, char *value, char *last, MyMessage &msg ) {
	if ( strcmp( label, searchLabel ) != 0 )
		return false;

	if ( strcmp( last, value ) == 0 )
		return true;

#ifdef DEBUG_ENABLED
  Serial.print( label );
  Serial.print( F(" changed from ") );
  Serial.print( last );
  Serial.print( F(" to ") );
  Serial.println( value );
#endif

	strcpy(last, value);
	gw.send( msg.set( last ) );

	return true;
}

void getTI() {
	static TeleInfo last; // dernière lecture
	char c; // le char qu'on read

	// tout d'abord on cherche une fin de ligne
	while ( readTI() != '\n' );
	// maintenant on cherche le label MOTDETAT (cad fin de trame)
	// TIP: c'est le seul qui commence par un M!
	bool sol = true; // start of line
	while ( true ) {
		c = readTI();
		if ( sol && (c == 'M') )
			break;
		sol = ( c == '\n' ); // fin de ligne trouvée, le prochain char sera en debut de ligne donc!
	}
	// eat the line
	while ( readTI() != '\n' );

	// ca y est, on peu bosser!
	readLine:

	uint8_t i; // un compteur
	uint8_t myCS = 32, cs; // le checksum

	// commencer par detecter le label (search for 0x20)
	i = 0;
	char label[ BUFSIZE ]; // etiquette
	memset( label, 0, BUFSIZE );
	while ( true ) {
		c = readTI();
		myCS += (int)c;

		if ( c == ' ' ) break;

		label[ i++ ] = c;
		if ( i == BUFSIZE ) // prevent overflow, it will break the checksum, so silent exit
			break;
	}

	// la value (search for 0x20)
	i = 0;
	char value[ BUFSIZE ];  // la value la plus longue ligne est ADCO / 15
	memset( value, 0, BUFSIZE );
	while ( true ) {
		c = readTI();
		myCS += (int)c;

		if ( c == ' ' ) break;

		value[ i++ ] = c;
		if ( i == BUFSIZE ) // prevent overflow, it will break the checksum, so silent exit
			break;
	}

	// le checksum
	cs = readTI();

	// drop end of line char
	readTI(); readTI(); // \r\n

#ifdef DEBUG_ENABLED
		Serial.print( F("GOT LABEL=") );
		Serial.print( label );
		Serial.print( F(" VALUE=") );
		Serial.print( value );
		Serial.print( F(" CHECKSUM=") );
		Serial.println( cs, HEX );
#endif

	// now on regarde ce que cette ligne voulait bien nous dire
	// the end ?
	if ( strcmp( label, "MOTDETAT" ) == 0 ) // on verifie pas le checksum de cette ligne
		return;

	// check le checksum
	myCS = (myCS & 0x3F) + 0x20;
	if ( myCS != cs ) { // si c'est pas bon... ben c'est con!
#ifdef DEBUG_ENABLED
		Serial.print( F("CHECKSUM ERROR!!!, MY=") );
		Serial.print( myCS, HEX );
		Serial.print( F(" CHECKSUM=") );
		Serial.println( cs, HEX );
#endif
		goto readLine;
	}

	if ( strTI( label, "ADCO", value, last.ADCO, msgADCO ) )			goto readLine;
	if ( strTI( label, "OPTARIF", value, last.OPTARIF, msgOPTARIF ) )	goto readLine;
	if ( atoiTI( label, "ISOUSC", value, last.ISOUSC, msgISOUSC ) )		goto readLine;
	if ( atolTI( label, "BASE", value, last.BASE, msgBASE ) )			goto readLine;

	if ( atolTI( label, "HCHC", value, last.HC_HC, msgHC_HC ) )			goto readLine;
	if ( atolTI( label, "HCHP", value, last.HC_HP, msgHC_HP ) )			goto readLine;

	if ( atolTI( label, "EJPHN", value, last.EJP_HN, msgEJP_HN ) )		goto readLine;
	if ( atolTI( label, "EJPHPM", value, last.EJP_HPM, msgEJP_HPM ) )	goto readLine;

	if ( atolTI( label, "BBRHCJB", value, last.BBR_HC_JB, msgBBR_HC_JB ) ) goto readLine;
	if ( atolTI( label, "BBRHPJB", value, last.BBR_HP_JB, msgBBR_HP_JB ) ) goto readLine;
	if ( atolTI( label, "BBRHCJW", value, last.BBR_HC_JW, msgBBR_HC_JW ) ) goto readLine;
	if ( atolTI( label, "BBRHPJW", value, last.BBR_HP_JW, msgBBR_HP_JW ) ) goto readLine;
	if ( atolTI( label, "BBRHCJR", value, last.BBR_HC_JR, msgBBR_HC_JR ) ) goto readLine;
	if ( atolTI( label, "BBRHPJR", value, last.BBR_HP_JR, msgBBR_HP_JR ) ) goto readLine;

	if ( atoiTI( label, "PEJP", value, last.PEJP, msgPEJP ) )			goto readLine;
	if ( strTI( label, "PTEC", value, last.PTEC, msgPTEC ) )			goto readLine;

	if ( strTI( label, "DEMAIN", value, last.DEMAIN, msgDEMAIN ) )		goto readLine;

	if ( atoiTI( label, "IINST", value, last.IINST, msgIINST ) )		goto readLine;
	if ( atoiTI( label, "ADPS", value, last.ADPS, msgADPS ) )			goto readLine;
	if ( atoiTI( label, "IMAX", value, last.IMAX, msgIMAX ) )			goto readLine;
	if ( atolTI( label, "PAPP", value, last.PAPP, msgPAPP ) )			goto readLine;

	if ( charTI( label, "HHPHC", value[0], last.HHPHC, msgHHPHC ) )
		goto readLine;

#ifdef DEBUG_ENABLED
	Serial.print( F( "unkown LABEL=" ) );
	Serial.print( label );
	Serial.print( F( " VALUE=" ) );
	Serial.println( value );
#endif

	// pour les cas non gérés
	goto readLine;
}

void loop() {
	//readBatteryLevel( gw );
	getTI();

	// attendre avant prochaine lecture
	gw.sleep( SLEEP_TIME );
}

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


Adding a sketch to demonstrate event driven DS18B20 handling.

/**
 * @file CosaDS18B20periodic.ino
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2015, Mikael Patel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * @section Description
 * Cosa demonstrate event driven, periodic, handling of the DS18B20
 * 1-Wire device driver.
 *
 * @section Circuit
 * @code
 *                           DS18B20/3
 *                       +------------+
 * (GND)---------------1-|GND         |\
 * (D4)------+---------2-|DQ          | |
 *           |       +-3-|VDD         |/
 *          4K7      |   +------------+
 *           |       |
 * (VCC)-----+       +---(VCC/GND)
 *
 * @endcode

 * Connect Arduino to DS18B20 in D7 and GND. May use parasite
 * powering (connect DS18B20 VCC to GND) otherwise to VCC.
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/Event.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/Periodic.hh"
#include "Cosa/OWI/Driver/DS18B20.hh"
#include "Cosa/Trace.hh"
#include "Cosa/IOStream/Driver/UART.hh"

// One-wire pin
OWI owi(Board::D4);

class Sensor : public DS18B20, public Periodic {
public:
  /**
   * Construct sensor on given 1-wire bus. Convert and read
   * temperature with given time period (in milli-seconds).
   * @param[in] pin 1-wire bus.
   * @param[in] ms time period for samples (default 2048 ms).
   */
  Sensor(OWI* pin, uint16_t ms = 2048) :
    DS18B20(pin),
    Periodic(ms / 2),
    m_state(0)
  {}

  /**
   * Return current state.
   */
  uint8_t get_state()
  {
    return (m_state);
  }

  /**
   * @override Sensor
   * Called when a new sample is available.
   */
  virtual void on_sample();

protected:
  /**
   * @override Periodic
   * Request temperature measurement and read back sample as a simple
   * state machine. Two periods are used.
   */
  virtual void run();

  /** Current state (0=convert request, 1=read sample, 2=error). */
  uint8_t m_state;
};

void
Sensor::run()
{
  switch (m_state) {
  case 0:
    m_state = convert_request() ? 1 : 2;
    break;
  case 1:
    m_state = read_scratchpad() ? 0 : 2;
    on_sample();
    break;
  case 2:
    ASSERT(m_state != 2);
    break;
  }
}

void
Sensor::on_sample()
{
  trace << Watchdog::millis() << ':' << *this << PSTR(" C") << endl;
}

Sensor sensor(&owi);

void setup()
{
  // Start trace output stream on the serial port
  uart.begin(9600);
  trace.begin(&uart, PSTR("CosaDS18B20periodic: started"));

  // Start the watchdog ticks counter
  Watchdog::begin(16, Watchdog::push_timeout_events);

  // Connect to the device and start periodic function
  ASSERT(sensor.connect(0));
  sensor.begin();
}

void loop()
{
  // Service events
  Event::service();
}

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


Sketch de configuracion del chip

Sketch de configuracion del chip

// --------------------------------------
// Habilitar la EEPROM
//

#include <Wire.h>

#define GPIO 0x20
#define MEM 0x50

#define SELECT 0x18
#define INTERRUPT 0x19
#define ENABLER 0x2D
#define DIRECTION 0x1C
#define COMMAND 0x30

#define W_GPORT0 0x08
#define W_GPORT1 0x09
#define W_GPORT2 0x0A
#define W_GPORT3 0x0B
#define W_GPORT4 0x0C
#define W_GPORT5 0x0D
#define W_GPORT6 0x0E
#define W_GPORT7 0x0F

#define PASS1 0x43
#define PASS2 0x4D
#define PASS3 0x53

#define VALUE 0x02

#define STORE 0x01

void setup(){

  Wire.begin();

  Serial.begin(9600);
  while (!Serial);

   Serial.print("Iniciando EEPROM...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)ENABLER);
  Wire.write((byte)PASS1);
  Wire.write((byte)PASS2);
  Wire.write((byte)PASS3);
  Wire.write((byte)VALUE);
  int error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

  Serial.print("Configurando GPORT0...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT0);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

   Serial.print("Configurando GPORT1...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)1);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

    Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT1);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

 Serial.print("Configurando GPORT3...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)3);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT3);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

    Serial.print("Configurando GPORT2...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)2);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)1);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

    Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)1);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT2);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)3);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

    Serial.print("Configurando GPORT7...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)7);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

    Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT7);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

    Serial.print("Configurando GPORT5...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)5);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT5);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

    Serial.print("Configurando GPORT6...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)6);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

      Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT6);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1E);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

   Serial.print("Configurando GPORT4...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)SELECT);
  Wire.write((byte)4);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)DIRECTION);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

      Wire.beginTransmission(GPIO);
  Wire.write((byte)INTERRUPT);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)W_GPORT4);
  Wire.write((byte)0);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

  Wire.beginTransmission(GPIO);
  Wire.write((byte)0x1D);
  Wire.write((byte)0XFF);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.println(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.println(error);
  }

  Serial.print("GUARDANDO CONFIGURACION...");

  Wire.beginTransmission(GPIO);
  Wire.write((byte)COMMAND);
  Wire.write((byte)STORE);
  error = Wire.endTransmission();

  if (error == 0) {
    Serial.print(" OK");
  } else {
    Serial.print("COD ERROR: ");
    Serial.print(error);
  }

}

void loop(){

}

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


adding inside display code

adding inside display code

#include <RFM69.h>
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

// For the Adafruit shield, these are the default.
#define TFT_DC 5
#define TFT_CS 2

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

//*********************************************************************************************
// *********** IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
int16_t NETWORKID = 100;  //the same on all nodes that talk to each other
int16_t NODEID = 1;

int nextTime = 0;

//Match frequency to the hardware version of the radio on your Feather
//#define FREQUENCY     RF69_433MHZ
//#define FREQUENCY     RF69_868MHZ
#define FREQUENCY      RF69_915MHZ
#define ENCRYPTKEY     "tacoTacoBurrito!" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HCW    true // set to 'true' if you are using an RFM69HCW module
#define promiscuousMode true
//*********************************************************************************************

#define RFM69_CS      15
#define RFM69_IRQ     4
#define RFM69_IRQN    4 //digitalPinToInterrupt(RFM69_IRQ)
#define RFM69_RST     16

int16_t packetnum = 0;  // packet counter, we increment per xmission

RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);  //initialize radio with potential custom pin outs; otherwise you may use for default: RFM69 radio;

// Data Structure
typedef struct {
  float         soiltempf;
  float         humidity;
  float         inches;
  int           winddir;

  float         windspeedmph;
  int           windgustdir;
  float         windgustmph;
  float         rainin;

  float         dewptF;
  float         windspdmph_avg2m;
  int           winddir_avg2m;
  float         windgustmph_10m;

  int           windgustdir_10m;
  float         dailyrainin;
} Payload;
Payload theData;

void setup()
{

    Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
    Serial.println("RFM69 Based Receiver");

    // Hard Reset the RFM module - Optional
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, HIGH);
  delay(100);
  digitalWrite(RFM69_RST, LOW);
  delay(100);

    // Initialize radio
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
  if (IS_RFM69HCW) {
    radio.setHighPower();    // Only for RFM69HCW & HW!
  }

//  radio.promiscuous(promiscuousMode);

  // To improve distance set a lower bit rate. Most libraries use 55.55 kbps as default
  // See https://lowpowerlab.com/forum/moteino/rfm69hw-bit-rate-settings/msg1979/#msg1979
  // Here we will set it to 9.6 kbps instead
  radio.writeReg(0x03,0x0D); //set bit rate to 9k6
  radio.writeReg(0x04,0x05);

  radio.setPowerLevel(10); // power output ranges from 0 (5dBm) to 31 (20dBm)
                          // Note at 20dBm the radio sources up to 130 mA!
                         // Selecting a power level between 10 and 15 will use ~30-44 mA which is generally more compatible with Photon power sources
                        // As reference, power level of 10 transmits successfully at least 300 feet with 0% packet loss right through a home, sufficient for most use

  radio.encrypt(ENCRYPTKEY);

  Serial.print("\nListening at ");
  Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(" MHz");
  tft.begin();
}

//=========================MAIN LOOP===========================================
void loop() {

if (radio.receiveDone())
  {
    Serial.println();
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    Serial.print(" [RX_RSSI:");Serial.print(radio.readRSSI());Serial.println("]:");

    if (radio.DATALEN != sizeof(Payload))
      Serial.println("Invalid payload received, not matching Payload struct!");
    else
    {
      tft.fillScreen(ILI9341_BLACK);
      theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else

      Serial.print("soiltempf: ");
      Serial.println(theData.soiltempf);

      Serial.print("humidity: ");
      Serial.println(theData.humidity);

      Serial.print("inches: ");
      Serial.println(theData.inches);

      Serial.print("winddir: ");
      Serial.println(theData.winddir);

      Serial.print("windspeedmph: ");
      Serial.println(theData.windspeedmph);

      Serial.print("windgustdir: ");
      Serial.println(theData.windgustdir);

      Serial.print("windgustmph: ");
      Serial.println(theData.windgustmph);

      Serial.print("rainin: ");
      Serial.println(theData.rainin);

      Serial.print("dewptF: ");
      Serial.println(theData.dewptF);

      tft.setCursor(0, 0);
      tft.setTextColor(ILI9341_WHITE);  tft.setTextSize(3);
      tft.print("DewPtF: ");
      tft.println(String(theData.dewptF));

      Serial.print("windspdmph_avg2m: ");
      Serial.println(theData.windspdmph_avg2m);

      Serial.print("winddir_avg2m: ");
      Serial.println(theData.winddir_avg2m);

      Serial.print("windgustmph_10m: ");
      Serial.println(theData.windgustmph_10m);

      Serial.print("windgustdir_10m: ");
      Serial.println(theData.windgustdir_10m);

      Serial.print("dailyrainin: ");
      Serial.println(theData.dailyrainin);

    }
  }

  radio.receiveDone(); //put radio in RX mode

  if (nextTime > millis() && nextTime !=0) {
      return;
  }
  nextTime = millis() + 1000;
  Serial.print("."); //THis gives us a neat visual indication of time between messages received

} //end loop

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


add wifi_compare_test

add wifi_compare_test

void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
  Serial2.begin(115200);
}

void loop() {
  int front, back;
  while(Serial1.available()) Serial1.read();
  while(Serial2.available()) Serial2.read();
  do {
    while(!Serial1.available()) {
      delay(10);
    }
    front = Serial1.read();
  } while(front == 0 || front >= 128);

  do {
    while(!Serial2.available()) {
      delay(10);
    }
    back = Serial2.read();
  } while(back == 0 || back >= 128);

  Serial.print(front, DEC);
  Serial.print(" - ");
  Serial.print(back, DEC);
  Serial.print(" = ");
  Serial.println(front - back);
}

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


using millis() instead of delay() for the pulse module

so it would no longer lag, and be more responsive to input voltage
changes.

error: pathspec 'Modifier' did not match any file(s) known to git
error: pathspec 'Modules/Pulse/PulseATtiny/PulseATtiny.ino' did not match any file(s) known to git


add ECMqtt-client-example/ECMqtt-client-example.ino

#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
// see https://github.com/espressif/arduino-esp32/issues/1960#issuecomment-429546528
#endif
#include <SerialCommand.h>
#include <SpinTimer.h>
#include <AppDebug.h>
#include <DbgCliNode.h>
#include <DbgCliTopic.h>
#include <DbgCliCommand.h>
#include <DbgTracePort.h>
#include <DbgTraceLevel.h>

#include <ECMqttClient.h>   // ERNI Community MQTT client wrapper library
#include <MqttTopic.h>

#define MQTT_SERVER "test.mosquitto.org"

SerialCommand* sCmd = 0;

//-----------------------------------------------------------------------------

void setupBuiltInLed()
{
#if defined(ESP8266)
  digitalWrite(LED_BUILTIN, 1);  // LED state is inverted on ESP8266
#else
  digitalWrite(LED_BUILTIN, 0);
#endif
}

void setBuiltInLed(bool state)
{
#if defined(ESP8266)
  digitalWrite(LED_BUILTIN, !state);  // LED state is inverted on ESP8266
#else
  digitalWrite(LED_BUILTIN, state);
#endif
}

//-----------------------------------------------------------------------------
// WiFi Commands
//-----------------------------------------------------------------------------
class DbgCli_Cmd_WifiMac : public DbgCli_Command
{
public:
  DbgCli_Cmd_WifiMac(DbgCli_Topic* wifiTopic)
  : DbgCli_Command(wifiTopic, "mac", "Print MAC Address.")
  { }

  void execute(unsigned int argc, const char** args, unsigned int idxToFirstArgToHandle)
  {
    Serial.println();
    Serial.print("Wifi MAC: ");
    Serial.println(WiFi.macAddress().c_str());
    Serial.println();
  }
};

class DbgCli_Cmd_WifiNets : public DbgCli_Command
{
public:
  DbgCli_Cmd_WifiNets(DbgCli_Topic* wifiTopic)
  : DbgCli_Command(wifiTopic, "nets", "Print nearby networks.")
  { }

  void execute(unsigned int argc, const char** args, unsigned int idxToFirstArgToHandle)
  {
    bool bailOut = false;

    // scan for nearby networks:
    Serial.println();
    Serial.println("** Scan Networks **");
    int numSsid = WiFi.scanNetworks();
    if (numSsid == -1)
    {
      Serial.println("Couldn't get a wifi connection");
      bailOut = true;
    }

    if (!bailOut)
    {
      // print the list of networks seen:
      Serial.print("number of available networks:");
      Serial.println(numSsid);

      // print the network number and name for each network found:
      for (int thisNet = 0; thisNet < numSsid; thisNet++)
      {
        Serial.print(thisNet);
        Serial.print(") ");
        Serial.print(WiFi.SSID(thisNet));
        Serial.print(" - Signal: ");
        Serial.print(WiFi.RSSI(thisNet));
        Serial.print(" dBm");
        Serial.print(" - Encryption: ");
        printEncryptionType(WiFi.encryptionType(thisNet));
      }
    }
    Serial.println();
  }
private:
  void printEncryptionType(int thisType)
  {
    // read the encryption type and print out the name:
    switch (thisType) {
#if ! defined(ESP32)
// TODO: solve this for ESP32!
      case ENC_TYPE_WEP:
        Serial.println("WEP");
        break;
      case ENC_TYPE_TKIP:
        Serial.println("WPA");
        break;
      case ENC_TYPE_CCMP:
        Serial.println("WPA2");
        break;
      case ENC_TYPE_NONE:
        Serial.println("None");
        break;
      case ENC_TYPE_AUTO:
        Serial.println("Auto");
        break;
#endif
      default:
        Serial.println("Unknown");
        break;
    }
  }
};

class DbgCli_Cmd_WifiStat : public DbgCli_Command
{
public:
  DbgCli_Cmd_WifiStat(DbgCli_Topic* wifiTopic)
  : DbgCli_Command(wifiTopic, "stat", "Show WiFi connection status.")
  { }

  void execute(unsigned int argc, const char** args, unsigned int idxToFirstArgToHandle)
  {
    wl_status_t wlStatus = WiFi.status();
    Serial.println();
    Serial.println(wlStatus == WL_NO_SHIELD       ? "NO_SHIELD      " :
                   wlStatus == WL_IDLE_STATUS     ? "IDLE_STATUS    " :
                   wlStatus == WL_NO_SSID_AVAIL   ? "NO_SSID_AVAIL  " :
                   wlStatus == WL_SCAN_COMPLETED  ? "SCAN_COMPLETED " :
                   wlStatus == WL_CONNECTED       ? "CONNECTED      " :
                   wlStatus == WL_CONNECT_FAILED  ? "CONNECT_FAILED " :
                   wlStatus == WL_CONNECTION_LOST ? "CONNECTION_LOST" :
                   wlStatus == WL_DISCONNECTED    ? "DISCONNECTED   " : "UNKNOWN");
    Serial.println();
    WiFi.printDiag(Serial);
    Serial.println();
  }
};

class DbgCli_Cmd_WifiDis : public DbgCli_Command
{
public:
  DbgCli_Cmd_WifiDis(DbgCli_Topic* wifiTopic)
  : DbgCli_Command(wifiTopic, "dis", "Disconnect WiFi.")
  { }

  void execute(unsigned int argc, const char** args, unsigned int idxToFirstArgToHandle)
  {
    Serial.println();
    if (argc - idxToFirstArgToHandle > 0)
    {
      printUsage();
    }
    else
    {
      const bool DO_NOT_SET_wifioff = false;
      WiFi.disconnect(DO_NOT_SET_wifioff);
      Serial.println("WiFi is disconnected now.");
    }
    Serial.println();
  }

  void printUsage()
  {
    Serial.println(getHelpText());
    Serial.println("Usage: dbg wifi dis");
  }
};

//-----------------------------------------------------------------------------

class DbgCli_Cmd_WifiCon : public DbgCli_Command
{
public:
  DbgCli_Cmd_WifiCon(DbgCli_Topic* wifiTopic)
  : DbgCli_Command(wifiTopic, "con", "Connect to WiFi.")
  { }

  void execute(unsigned int argc, const char** args, unsigned int idxToFirstArgToHandle)
  {
    Serial.println();
   if (argc - idxToFirstArgToHandle != 2)
    {
      printUsage();
    }
    else
    {
      const char* ssid = args[idxToFirstArgToHandle];
      const char* pass = args[idxToFirstArgToHandle+1];
      Serial.print("SSID: ");
      Serial.print(ssid);
      Serial.print(", pass: ");
      Serial.println(pass);
      WiFi.begin(ssid, pass);
      Serial.println("WiFi is connecting now.");
    }
   Serial.println();
  }

  void printUsage()
  {
    Serial.println(getHelpText());
    Serial.println("Usage: dbg wifi con <SSID> <passwd>");
  }
};

//-----------------------------------------------------------------------------

class TestLedMqttSubscriber : public MqttTopicSubscriber
{
public:
  TestLedMqttSubscriber()
  : MqttTopicSubscriber("test/led")
  { }

  virtual ~TestLedMqttSubscriber()
  { }

  bool processMessage(MqttRxMsg* rxMsg)
  {
    bool msgHasBeenHandled = false;

    if (0 != rxMsg)
    {
      // this subscriber object takes the responsibility
      bool state = atoi(rxMsg->getRxMsgString());
      setBuiltInLed(state);
      // ... and marks the received message as handled (chain of responsibilities)
      msgHasBeenHandled = true;
    }
    return msgHasBeenHandled;
  }
};

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  setBuiltInLed(false);

  Serial.begin(9600);
  setupDebugEnv();

  //-----------------------------------------------------------------------------
  // WiFi Commands
  //-----------------------------------------------------------------------------
#if defined(ESP8266) || defined(ESP32)
  DbgCli_Topic* wifiTopic = new DbgCli_Topic(DbgCli_Node::RootNode(), "wifi", "WiFi debug commands");
  new DbgCli_Cmd_WifiMac(wifiTopic);
  new DbgCli_Cmd_WifiNets(wifiTopic);
  new DbgCli_Cmd_WifiStat(wifiTopic);
  new DbgCli_Cmd_WifiDis(wifiTopic);
  new DbgCli_Cmd_WifiCon(wifiTopic);
#endif

  //-----------------------------------------------------------------------------
  // ESP8266 / ESP32 WiFi Client
  //-----------------------------------------------------------------------------
  WiFi.mode(WIFI_STA);

  //-----------------------------------------------------------------------------
  // MQTT Client
  //-----------------------------------------------------------------------------
  ECMqttClient.begin(MQTT_SERVER);
  new TestLedMqttSubscriber();
}

void loop()
{
  if (0 != sCmd)
  {
    sCmd->readSerial();           // process serial commands
  }
  ECMqttClient.loop();            // process MQTT Client
  scheduleTimers();               // process Timers
}

error: pathspec 'ECMqtt-client-example/ECMqtt-client-example.ino' did not match any file(s) known to git


fixes?

fixes?

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/'


update ensemble six firmware

update ensemble six firmware

/* PHOBOS - EnsembleFive firmware v.0.2 (27.05.2017)
 *
 * using:
 * Arduino v1.8.0
 * MIDI_Library v.4.3.1 by fortyseveneffects
 * Servo Library v.1.1.2
 * EEPROM Library v.2.0.0
 *
 * plays:
 * A - 2 sevos striking pendulums
 * B - 4 lights controlled by relays
 */

#include <EEPROM.h>
#include <Servo.h>
#include <MIDI.h>
#define MIDICH 6

// PENDULUMS' PINS
#define A1 6
#define A2 7
// LIGHTS' PINS
#define B1 2
#define B2 3
#define B3 4
#define B4 5

/* Addresses on Arduino EEPROM for servo control parameters*/
#define S1MININC 0 // servo1 min increment (cc=120)
#define S1MAXINC 1 // servo1 max increment (cc=121)

#define S2MININC 2 // servo2 min increment (cc=122)
#define S2MAXINC 3 // servo2 max increment (cc=123)

#define S1MINANG 4 // servo1 min angle (cc=124)
#define S1MAXANG 5 // servo1 max angle (cc=125)

#define S2MINANG 6 // servo2 min angle (cc=126)
#define S2MAXANG 7 // servo2 max angle (cc=127)

// servos
Servo servo1, servo2;
bool servoState[2]; // servo state to control servos out of MIDI loop
float servoPos[2]; // servo current position
float servoInc[2]; //servo increment value which relates to movement speed
float servoMinInc[2]; // servo min increment values
float servoMaxInc[2]; // servo min increment values
float servoMinAng[2]; // servo min angle
float servoMaxAng[2]; // servo max angle

// make note to pin array
byte note2pin[16];
byte vel, pitch, val, cc;

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
  MIDI.begin(MIDICH); // Launch MIDI and listen to channel 1
  MIDI.turnThruOn();

  // set output pins
  servo1.attach(A1);
  servo2.attach(A2);

  pinMode(B1, OUTPUT);
  pinMode(B2, OUTPUT);
  pinMode(B3, OUTPUT);
  pinMode(B4, OUTPUT);
  // turn relays off
  digitalWrite(B1, HIGH);
  digitalWrite(B2, HIGH);
  digitalWrite(B3, HIGH);
  digitalWrite(B4, HIGH);

  // set servos to initial position
  servoPos[0] = midi2angle(EEPROM.read(S1MINANG));
  servo1.write(servoPos[0]);

  servoPos[1] = midi2angle(EEPROM.read(S2MINANG));
  servo2.write(servoPos[1]);

  // set servos' min&max increment values
  // NOTE: min/max inc values are between 0 and 127 (after mapped correspond to 0.1 to 10 degrees per millisecond)
  servoMinInc[0] = EEPROM.read(S1MININC);
  servoMaxInc[0] = EEPROM.read(S1MAXINC);

  servoMinInc[1] = EEPROM.read(S2MININC);
  servoMaxInc[1] = EEPROM.read(S2MAXINC);

  // set servos0 min&max angle
  // NOTE: min/max angle values are already converted to angles
  servoMinAng[0] = midi2angle( EEPROM.read(S1MINANG) );
  servoMaxAng[0] = midi2angle( EEPROM.read(S1MAXANG) );

  servoMinAng[1] = midi2angle( EEPROM.read(S2MINANG) );
  servoMaxAng[1] = midi2angle( EEPROM.read(S2MAXANG) );

  // set note2pin array
  note2pin[0] = A1;
  note2pin[1] = A2;

  note2pin[12] = B1;
  note2pin[13] = B2;
  note2pin[14] = B3;
  note2pin[15] = B4;
}

void loop() {
  if(MIDI.read()){
      switch(MIDI.getType()){
        case midi::NoteOn:
          pitch = MIDI.getData1();
          vel = MIDI.getData2();

          if(pitch < 1){ // set servos' values only (activation is done in runServos function)            if(pitch < 27){ //
              servoInc[pitch] = velocity2inc( servoMinInc[pitch], servoMaxInc[pitch], vel);
              servoState[pitch] = true;
          }
          else{ // activate relays
            digitalWrite(note2pin[pitch], LOW);
          }
          break;

        case midi::NoteOff:
          pitch = MIDI.getData1();
          if(pitch < 1){ // deactivate servos
              servoState[pitch] = false;
          }
          else{ // deactivate relays
            digitalWrite(note2pin[pitch], HIGH);
          }
          break;

        // CONTROL CHANGE (SET SERVO PARAMETERS)
        case midi::ControlChange:
          cc = MIDI.getData1();
          val = MIDI.getData2();
          // starting on cc=120
          EEPROM.write(cc-120, val); // store...
          updateServoParams(cc, val);//...and update
      }
  }

  runServos(); // activate servos
  delay(1); // (used only to set servo increments in a millisecond basis)
}

/***************** FUNTCIONS *****************/
byte voltage2byte(float v){
  return v*255/5.f;
}

float midi2angle(byte m){
  return 180/127.f*m;
}

float velocity2inc(byte _min, byte _max, byte v){ // translate velocity values into position increments usign a min/max inc.
  return map(v, 0, 127, _min, _max);
}

void runServos(){
  // servo1 attack
  if( servoState[0]==true && servoPos[0] < servoMaxAng[0] ){
    servo1.write(servoPos[0]);
    servoPos[0] += servoInc[0];
  }
  // servo1 release
  else if (servoState[0] == false){
    servoPos[0] = servoMinAng[0];
    servo1.write( servoPos[0] );
  }

  // servo2 attack
  if( servoState[1]==true && servoPos[1] < servoMaxAng[1] ){
    servo2.write(servoPos[1]);
    servoPos[1] += servoInc[1];
  }
  // servo2 release
  else if (servoState[1] == false){
    servoPos[1] = servoMinAng[1];
    servo2.write( servoPos[1] );
  }
}

void updateServoParams(byte addr, byte val){
  switch(addr){
    case 120:
      servoMinInc[0] = val;
      break;
    case 121:
      servoMaxInc[0] = val;
      break;
    case 122:
      servoMinInc[1] = val;
      break;
    case 123:
      servoMaxInc[1] = val;
      break;
    case 124:
      servoMinAng[0] = midi2angle(val);
      break;
    case 125:
      servoMaxAng[0] = midi2angle(val);
      break;
    case 126:
      servoMinAng[1] = midi2angle(val);
      break;
    case 127:
      servoMaxAng[1] = midi2angle(val);
      break;

    default:
    break;
  }
}

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


Grove rewritten, interrupt only, 4s interval

See worklog in Google Drive for details

error: pathspec 'Individual' did not match any file(s) known to git
error: pathspec 'sensor' did not match any file(s) known to git
error: pathspec 'rewritten/Grove.ino' did not match any file(s) known to git


Initial commit of Serial TH Meter

Initial commit of Serial TH Meter

/*
 * Serial Humidity Temperature Meter
 *
 * Consists of
 * Arduino Nano,
 * DHT11/22 - 1 unit,
 * DS18B20  - 3 units,
 *
 * Communicates using Modbus RTU:
 * Holding Registers (4x) 40001 - 40010
 *
 * (c) 2017, Mikhail Shiryaev
 */

#include <DHT.h>               // https://github.com/adafruit/DHT-sensor-library
#include <OneWire.h>           // http://www.pjrc.com/teensy/td_libs_OneWire.html
#include <DallasTemperature.h> // https://github.com/milesburton/Arduino-Temperature-Control-Library

// All the pins below are digital
#define DHT_PIN       2 // DHT22 data
#define ONE_WIRE_PIN0 5 // the 1st DS18B20 data
#define ONE_WIRE_PIN1 6 // the 2nd DS18B20 data
#define ONE_WIRE_PIN2 7 // the 3rd DS18B20 data

#define DHT_TYPE        DHT11  // DHT11 or DHT22
#define ONE_WIRE_CNT    3      // count of 1-wire connections
#define EMPTY_VAL       -100.0 // empty float value of measurement
#define MODBUS_HDR_LEN  9      // length of Modbus TCP header

#define DEBUG                  // write detailed log to Serial port

#ifdef DEBUG
 #define DEBUG_PRINT(val)       Serial.print(val)
 #define DEBUG_PRINTHEX(val)    Serial.print(val, HEX)
 #define DEBUG_PRINTLN(val)     Serial.println(val)
 #define DEBUG_WRITETIME()      writeTime()
#else
 #define DEBUG_PRINT(val)
 #define DEBUG_PRINTHEX(val)
 #define DEBUG_PRINTLN(val)
 #define DEBUG_WRITETIME()
#endif

// DHT instance
DHT dht(DHT_PIN, DHT_TYPE);
float dhtH = EMPTY_VAL;
float dhtT = EMPTY_VAL;

// 1-wire and DS instances
OneWire oneWire0(ONE_WIRE_PIN0);
OneWire oneWire1(ONE_WIRE_PIN1);
OneWire oneWire2(ONE_WIRE_PIN2);
OneWire oneWires[] = {oneWire0, oneWire1, oneWire2};
DallasTemperature dsSensors[ONE_WIRE_CNT];
float dsT[ONE_WIRE_CNT] = { EMPTY_VAL, EMPTY_VAL, EMPTY_VAL };

// Modbus
const byte modbusHeader[MODBUS_HDR_LEN] = {
  0x00, 0x00, // Transaction identifier
  0x00, 0x00, // Protocol identifier
  0x00, 0x17, // Length
  0x00,       // Unit identifier
  0x03,       // Function code
  0x14        // Byte count (20)
};

// Speed control
#ifdef DEBUG
unsigned long time;
#endif

// Initialize DHT sensor
void initDHT() {
  dht.begin();
  DEBUG_PRINTLN("DHT sensor initialized");
}

// Initialize DS sensors
void initDS() {
  DeviceAddress deviceAddress;
  for (int i = 0; i < ONE_WIRE_CNT; i++) {
    dsSensors[i].setOneWire(&oneWires[i]);
    dsSensors[i].begin();
    if (dsSensors[i].getAddress(deviceAddress, 0))
      dsSensors[i].setResolution(deviceAddress, 12);
  }
  DEBUG_PRINTLN("DS sensors initialized");
}

#ifdef DEBUG
void writeTime() {
  Serial.print("Time elapsed = ");
  Serial.println(millis() - time);
}
#endif

// Read data from DHT sensor
void readDHT() {
  DEBUG_WRITETIME();
  DEBUG_PRINTLN("Reading from DHT sensor");

  dhtH = dht.readHumidity();
  dhtT = dht.readTemperature(); // *C

  DEBUG_WRITETIME();

  if (isnan(dhtH) || isnan(dhtT)) {
    dhtH = EMPTY_VAL;
    dhtT = EMPTY_VAL;
    DEBUG_PRINTLN("Error reading from DHT sensor");
  } else {
    DEBUG_PRINT("h = ");
    DEBUG_PRINTLN(dhtH);
    DEBUG_PRINT("t = ");
    DEBUG_PRINTLN(dhtT);
  }

  DEBUG_WRITETIME();
  DEBUG_PRINTLN();
}

// Read data from DS sensor
void readDS(int index) {
  DEBUG_WRITETIME();
  DEBUG_PRINT("Requesting DS sensor ");
  DEBUG_PRINTLN(index);

  dsSensors[index].requestTemperatures();

  DEBUG_WRITETIME();

  dsT[index] = dsSensors[index].getTempCByIndex(0);

  DEBUG_PRINT("t = ");
  DEBUG_PRINTLN(dsT[index]);
  DEBUG_WRITETIME();
  DEBUG_PRINTLN();
}

// Process Ethernet communication
void communicate() {
  /*
  DEBUG_WRITETIME();

  // manage connection
  unsigned long inactiveSpan = millis() - commTime;

  if (clientConnected) {
    if (inactiveSpan > DISCONN_TIME) {
        DEBUG_PRINTLN("Disconnecting inactive client");
        client.stop();
        clientConnected = false;
    } else if (client.connected()) {
      DEBUG_PRINTLN("Client is still connected");
    } else {
      client.stop();
      clientConnected = false;
      DEBUG_PRINTLN("Client has been disconnected");
    }
  }

  if (!clientConnected) {
    // connection is considered to be established only when data are received
    client = server.available();
    if (client) {
      clientConnected = true;
      DEBUG_PRINTLN("New client is connected");
    } else {
      DEBUG_PRINTLN("Client is not connected");
    }
  }

  // communicating
  if (clientConnected) {
    // wait for the request 00 00 00 00 00 06 01 03 00 00 00 0A
    DEBUG_PRINT("Receiving data: ");
    boolean sendResponse = false;
    while (client.available() > 0) {
      DEBUG_PRINT("_");
      char c = client.read();
      DEBUG_PRINTHEX(c);

      if (c == 0x0A) {
        sendResponse = true;
        commTime = millis();
        inactiveSpan = 0;
        client.flush(); // clear input buffer
        break;
      }
    }
    DEBUG_PRINTLN();

    // send response
    if (sendResponse) {
      DEBUG_PRINTLN("Sending response");
      client.write(modbusHeader, MODBUS_HDR_LEN);
      client.write((byte*)&dhtH, 4);
      client.write((byte*)&dhtT, 4);
      client.write((byte*)&dsT, 12);
    } else {
      DEBUG_PRINTLN("Response not required");
    }
  }

#ifdef USE_WATCHDOG
  // reset Watchdog timer if client is active
  if (inactiveSpan <= REINIT_TIME) {
    wdt_reset();
  }
#else
  // reinit Ethernet if client can't connect
  if (inactiveSpan > REINIT_TIME) {
    initEthernet();
  }
#endif

  DEBUG_WRITETIME();
  DEBUG_PRINTLN();
  */
}

void setup() {
  Serial.begin(9600);
  Serial.println("SERIAL TH meter started");
  initDHT();
  initDS();
  DEBUG_PRINTLN();
}

void loop() {
#ifdef DEBUG
  time = millis();
  delay(500);
#endif

  readDHT(); // around 270 ms
  communicate();
  readDS(0); // around 800 ms
  communicate();
  readDS(1); // around 800 ms
  communicate();
  readDS(2); // around 800 ms
  communicate();
}

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


Add test sketch which simply runs each motor separately, without input from Android

#include "DualVNH5019MotorShield.h"

DualVNH5019MotorShield md;

void stopIfFault()
{
  if (md.getM1Fault())
  {
    Serial.println("M1 fault");
    while(1);
  }
  if (md.getM2Fault())
  {
    Serial.println("M2 fault");
    while(1);
  }
}

void setup()
{
  Serial.begin(19200);
  Serial.println("Dual VNH5019 Motor Shield");
  md.init();
}

void loop()
{
  for (int i = 0; i <= 400; i++)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = 400; i >= -400; i--)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = -400; i <= 0; i++)
  {
    md.setM1Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M1 current: ");
      Serial.println(md.getM1CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = 0; i <= 400; i++)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = 400; i >= -400; i--)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }

  for (int i = -400; i <= 0; i++)
  {
    md.setM2Speed(i);
    stopIfFault();
    if (i%200 == 100)
    {
      Serial.print("M2 current: ");
      Serial.println(md.getM2CurrentMilliamps());
    }
    delay(2);
  }
}

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


Bluetooth Test Code

Bluetooth Test Code

// Test LED
int led = 13;

// Byte (one character) read in from Virtual Serial COMM (Bluetooth)
byte inByte = 0;

// Acknowledgment variable (while-loop sentinel)
byte ack = 0;

// Setup
void setup() {
  // Open up Bluetooth Virtual Serial COMM port
  Serial.begin(9600);

  // Configure digital for OUTPUT
  pinMode(led,OUTPUT);
}

// Main
void loop() {
  while (!ack) {
    ack = getAck();
    delay(3000);
  }
  //byte serialCmd = getSerialCmd();

  //doSerialCmd(serialCmd);

  doSerialCmd(getSerialCmd());

}

byte getAck() {
Serial.write("\r\nPress <c> for command list\r\n");
    Serial.write(">");
    byte inByte = Serial.read();

    if ( inByte == 'c' ) {
      Serial.write(inByte);
      ack = 1;
      printNewLn();
      printCmdList();
      printNewCmdLn();
      return 1;
    }
    return 0;
}

// Performs serial command based on user input
void doSerialCmd( byte cmd ) {
  switch( cmd ) {
    // Turn LED HIGH
    case ('h'):
      ledON();
      printNewCmdLn();
      break;

    // Turn LED LOW
    case ('l'):
      ledOFF();
      printNewCmdLn();
      break;

    // Display CMD List
    case ('c'):
      printCmdList();
      printNewCmdLn();
      break;
  }
}

// Prompts User for input serial command
//    Returns serial command
byte getSerialCmd() {
  byte inByte;
  if (Serial.available()) {
    inByte = Serial.read();
    Serial.write(inByte);
    printNewLn();
    return inByte;
  }
}

// Turns LED ON and writes to Serial
void ledON() {
  digitalWrite(led, HIGH);
  Serial.write("    The LED is ON!");
}

// Turns LED OFF and writes to Serial
void ledOFF() {
  digitalWrite(led, LOW);
  Serial.write("    The LED is OFF!");
}

// Prints the command list
void printCmdList() {
  Serial.write("    Commands:\r\n");
  Serial.write("      <h>    Turn ON LED\r\n");
  Serial.write("      <l>    Turn OFF LED\r\n");
  Serial.write("      <c>    Command List");
}

// Prints a new command line cursor
void printNewCmdLn() {
  printNewLn();
  Serial.write(">");
}

// Prints a modified new line
void printNewLn() {
  Serial.write("\r\n");
}

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


Grove experiment example code initial commit

#include <Servo.h>
#include <SPI.h>
#include <WiFi.h>
#include <TimerOne.h>
#include "rgb_lcd.h"
#include <stdlib.h>
#include <string.h>
#include <TH02_dev.h>

#define CMDSTR_MAX_LEN (128)
#define LOW_TEMP       (10)
#define NOM_TEMP       (25)
#define HIGH_TEMP      (40)

#define SENSOR_COUNT   (6)
#define ACTUATOR_COUNT (4)
#define VAR1_COUNT     (SENSOR_COUNT+1)
#define VAR2_COUNT     (ACTUATOR_COUNT+1)
typedef void (*pActuatorHandler)(int);
typedef int (*pgetSensorValue)(void);

rgb_lcd lcd;
boolean isBackLightOn = true;

char cmdstr[CMDSTR_MAX_LEN];

// char ssid[48] = "EdisonAP";           // your network SSID (name)
// char psw[48] = "12345678";       // your network password
// boolean isSSIDreconfiged = false;
// int keyIndex = 0;                // your network key Index number (needed only for WEP)
// int status = WL_IDLE_STATUS;
// WiFiServer server(88);
// int serverconnected = 0;

unsigned char BLColorRGB[]={0x00, 0x00, 0xFF};  //Backlight color

const int numRows = 2;
const int numCols = 16;

const int MenuCount = 5;
int MenuIndex = 0;

const int MoistureSensorIndex = 0;
const int LightSensorIndex = 1;
const int UVSensorIndex = 2;
const int THSensorIndex = 3;
const int LocalIPIndex = 4;

const int pinSound = A0;
const int pinMoisture = A1;
const int pinLight = A2;
const int pinUV = A3;
const int pinButton =0;
const int pinEncoder1 = 2;
const int pinEncoder2 = 3;
const int pinBuzzer = 4;
const int pinRelay = 5;
const int pinPIR = 7;
const int pinServo = 6;
Servo myservo;

const char* SerialVarList1[] = { "temp", "humi", "light", "uv", "pir", "ms","ssid"};
const char* SerialVarList2[] = { "relay", "buzzer", "servo", "sleep", "psw"};
enum ACTUATOR {RELAY=0,BUZZER,SERVO,SLEEP};
enum SENSOR {TEMPER=0,HUMI,LIGHT,UV,PIR,MS};

pgetSensorValue getSensorValueList[]={
  getTempSensorValue,
  getHumiSensorValue,
  getLightSensorValue,
  getUVSensorValue,
  getPIRSensorValue,
  getMoistureSensorValue
};

int SensorValue[SENSOR_COUNT];

pActuatorHandler ActuatorHandlerList[]={RelayHandle, BuzzerHandle, ServoHandle, SleepHandle};

int SensorConfig[][4] = {       // value, condition, Actuator, action
  {85,  '>', SLEEP,  1},        //Temperature
  {100, '>', SLEEP,  1},        //Humdity
  {200, '<', SERVO,  90},        //Light
  {1023,'>', SLEEP,  1},        //UV
  {2,   '=', BUZZER, 1},        //PIR
  {600, '<', RELAY,  1}         //Moisture
};

void printSettings(void){
  Serial.println("The Sensors Configurations as follow:");
  for(int i=0; i<SENSOR_COUNT;i++){
    Serial.print(SerialVarList1[i]);
    Serial.write((char)SensorConfig[i][1]);
    Serial.print(SensorConfig[i][0]);
    Serial.write(',');
    Serial.print(SerialVarList2[SensorConfig[i][2]]);
    Serial.write('=');
    Serial.println(SensorConfig[i][3]);
  }
  Serial.print('\n');
  // Serial.print("SSID = ");
  // Serial.print(ssid);
  // Serial.print(", PSW = ");
  // Serial.println(psw);

  Serial.println("The Sensors Value as follow:");
  for(int i=0; i<SENSOR_COUNT;i++){
    Serial.print(SerialVarList1[i]);
    Serial.print(" = ");
    Serial.println(getSensorValueList[i]());
  }
}

void SerialRequestHandler(){
  if(cmdstrInput(cmdstr)){
     Serial.println(cmdstr);
     if(!parsecmd(cmdstr)){
       Serial.println("  ---- FAIL!");
       Serial.println("Please enter command: set temp>50,relay=1 etc.");
     }
     else {
       Serial.println("  ---- OK!");
     }
     printSettings();
  }
  int changedVal;
  for(int i=0;i<SENSOR_COUNT;i++){
    if(SensorConfig[i][2]==SERVO) changedVal = 0;
    else changedVal = !SensorConfig[i][0];
    switch (SensorConfig[i][1]){
      case '>':
        if(getSensorValueList[i]() > SensorConfig[i][0])
          ActuatorHandlerList[SensorConfig[i][2]](SensorConfig[i][3]);
        else ActuatorHandlerList[SensorConfig[i][2]](changedVal);
        break;
      case '<':
        if(getSensorValueList[i]() < SensorConfig[i][0])
          ActuatorHandlerList[SensorConfig[i][2]](SensorConfig[i][3]);
        else ActuatorHandlerList[SensorConfig[i][2]](changedVal);
        break;
      case '=':
        if(getSensorValueList[i]() == SensorConfig[i][0])
          ActuatorHandlerList[SensorConfig[i][2]](SensorConfig[i][3]);
        else ActuatorHandlerList[SensorConfig[i][2]](changedVal);
        break;
    }
  }
}

int parsecmd(char *cmd){
  char* cp = cmd;

/*  // use SSID and Passwrod, should not changed to lowcase
  while(*cp != '\0'){
    if(*cp >= 'A' && *cp <= 'Z') *cp += 0x20;     //tolower
    cp++;
  }
*/

  if(!(cmd[0]=='s' && cmd[1]=='e' && cmd[2]=='t' && cmd[3]==' ')) return 0;   //Illegal cmd

  char tmpcmd[CMDSTR_MAX_LEN];
  char *cp1=cmd+4;
  int len=0;
  while(*cp1 != '\0'){
    if(*cp1 != ' ') tmpcmd[len++] = *cp1;   //delete space
    cp1++;
  }
  tmpcmd[len]='\0';
  if(len<7) return 0;   // at least 7 characters,like T>0,R=1

  char *pvar1, *pvar2;
  pvar1 = strtok(tmpcmd,",");
  if(pvar1 == NULL) return 0;          //no setting
  pvar2 = strtok(NULL,",");
  if(pvar2 == NULL) return 0;          //no setting
  if(strtok(NULL,",")!=NULL) return 0; //more setting

  char op1='\0',op2='\0';
  char *pvarvalue1=NULL, *pvarvalue2=NULL;
  int i = 0;
  while(pvar1[i]!='\0'){
    if(pvar1[i]=='>' || pvar1[i]=='<' || pvar1[i]=='='){
      op1 = pvar1[i];
      pvar1[i] = '\0';
      pvarvalue1 = pvar1+i+1;
      break;
    }
    i++;
  }
  i=0;
  while(pvar2[i]!='\0'){
    if(pvar2[i]=='>' || pvar2[i]=='<' || pvar2[i]=='='){
      op2 = pvar2[i];
      pvar2[i] = '\0';
      pvarvalue2 = pvar2+i+1;
      break;
    }
    i++;
  }
  int varindex1,varindex2;
  for(i=0;i<VAR1_COUNT;i++)
    if(strcmp(pvar1,SerialVarList1[i])==0){
      varindex1 = i;
      break;
    }

  if(i==VAR1_COUNT) return 0;  // Illegal sensor name

  for(i=0;i<VAR2_COUNT;i++)
    if(strcmp(pvar2,SerialVarList2[i])==0){
      varindex2 = i;
      break;
    }

  if(i==VAR2_COUNT) return 0; // Illegal actuator name

  if(op1=='\0' || op2=='\0') return 0; // Illegal operator name

  if(varindex1 == VAR1_COUNT-1 && varindex2 == VAR2_COUNT-1){
    strcpy(ssid,pvarvalue1);
    strcpy(psw,pvarvalue2);
    isSSIDreconfiged = true;
  }
  else if(varindex1 != VAR1_COUNT-1 && varindex2 != VAR2_COUNT-1) {
    int value1 = atoi(pvarvalue1), value2 = atoi(pvarvalue2);
    if(value1 < 0 || value1 > 1023) return 0;
    if(value2 < 0 || value2 > 1023) return 0;
    SensorConfig[varindex1][0] = value1;
    SensorConfig[varindex1][1] = op1;
    SensorConfig[varindex1][2] = varindex2;
    SensorConfig[varindex1][3] = value2;
  }

  return 1;
}

//get Grove-Sound Sensor value
int getSoundSensorValue(){
    return analogRead(pinSound);
}
//get Temperature Senso value
int getTempSensorValue(){
  int temper =(int) TH02.ReadTemperature();
  SensorValue[TEMPER] = temper;
  return temper;
}

//get Humidity Senso value
int getHumiSensorValue(){
  int humidity =(int)TH02.ReadHumidity();
  SensorValue[HUMI] = humidity;
  return humidity;
}

//get Grove-Moisture Sensor value
int getMoistureSensorValue(){
  return (SensorValue[MS] = analogRead(pinMoisture));
}

//get Grove-Light Sensor value
int getLightSensorValue(){
  return (SensorValue[LIGHT] = analogRead(pinLight));
}

//get Grove-UV Sensor value
int getUVSensorValue(){
  return (SensorValue[UV] = analogRead(pinUV));
}

//Grove PIR Motion Sensor
int getPIRSensorValue(){
  return (SensorValue[PIR] = digitalRead(pinPIR));
}

//display Temperature&Humidity Senso value on LCD
void displayTHSensorValue(){
  lcd.clear();
  lcd.print(" Temp&Humidity  ");
  lcd.setCursor(0,1);
  lcd.print("<-");
  char number[16];
  sprintf(number,"%d",getTempSensorValue());
  lcd.setCursor(3,1);
  lcd.print(number);
  lcd.print("C");
  sprintf(number,"%d",getHumiSensorValue());
  lcd.setCursor(9,1);
  lcd.print(number);
  lcd.print("%");
  lcd.setCursor(numCols-2,1);
  lcd.print("->");
}

//display Grove-Moisture Sensor value on LCD
void displayMoistureSensorValue(){
  lcd.clear();
  lcd.print("Moisture Sensor ");
  char number[16];
  int len = sprintf(number,"%d",getMoistureSensorValue());
  lcd.setCursor(0,1);
  lcd.print("<-");
  lcd.setCursor((numCols-len)/2,1);
  lcd.print(number);
  lcd.setCursor(numCols-2,1);
  lcd.print("->");
}

//display Grove-Light Sensor value on LCD
void displayLightSensorValue(){
  lcd.clear();
  lcd.print("  Light Sensor  ");
  char number[16];
  int len = sprintf(number,"%d",getLightSensorValue());
  lcd.setCursor(0,1);
  lcd.print("<-");
  lcd.setCursor((numCols-len)/2,1);
  lcd.print(number);
  lcd.setCursor(numCols-2,1);
  lcd.print("->");
}

//display Grove-UV Sensor value on LCD
void displayUVSensorValue(){
  lcd.clear();
  lcd.print("   UV Sensor    ");
  char number[16];
  int len = sprintf(number,"%d",getUVSensorValue());
  lcd.setCursor(0,1);
  lcd.print("<-");
  lcd.setCursor((numCols-len)/2,1);
  lcd.print(number);
  lcd.setCursor(numCols-2,1);
  lcd.print("->");
}

//display local ip
void displayLocalIP(){
  IPAddress ip = WiFi.localIP();
  char local_ip[16];
  sprintf(local_ip,"%d.%d.%d.%d",ip[0],ip[1],ip[2],ip[3]);
  local_ip[15]= '\0';
  lcd.clear();
  lcd.print("    Local IP    ");
  lcd.setCursor(0,1);
  lcd.print(local_ip);
}

//is button pressed
int isButtonPressed(){
  int state = 0;
  if(digitalRead(pinButton)){
    while(digitalRead(pinButton));
    state = 1;
  }
  return state;
}

void RelayHandle(int val){
  if(val==1) {
    digitalWrite(pinRelay,HIGH);
  }
  else if(val==0){
    digitalWrite(pinRelay,LOW);
  }
}
void BuzzerHandle(int val){
  if(!(val==0 || val==1)) return;
  if(val==1)
    digitalWrite(pinBuzzer,HIGH);
  else if(val==0)
    digitalWrite(pinBuzzer,LOW);
}
void ServoHandle(int val){
  static unsigned long curt = millis();
  if(millis()-curt > 1000){
    myservo.write(val);
    curt = millis();
  }
}

void SleepHandle(int val){
  return;
}

void setup()
{
  Serial.begin(9600);
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);

    WiFi_Init();

    pinMode(pinButton,INPUT);
    pinMode(pinRelay,OUTPUT);
    pinMode(pinBuzzer,OUTPUT);
    pinMode(pinEncoder1,INPUT);
    pinMode(pinEncoder2,INPUT);
    myservo.attach(pinServo);
    myservo.write(0);

    printSettings();

    Timer1.initialize(20000); // set a timer of length 2000 microseconds
    Timer1.attachInterrupt(timerIsr); // attach the service routine here
    attachInterrupt(pinEncoder2,EncoderISR,FALLING);
}
void EncoderISR(){
    while(!digitalRead(pinEncoder2));
    if(digitalRead(pinEncoder1)==HIGH){
      MenuIndex++;
      if(MenuIndex >= MenuCount) MenuIndex = 0;
    } else {
      MenuIndex--;
      if(MenuIndex < 0) MenuIndex = MenuCount - 1;
    }
}

//timer interrupt handler
void timerIsr(){
  RequestHandler();
}

// display menu on the LCD screen
void displayMenu(){
  static unsigned long curtime = millis();
  if(millis()-curtime > 1000){
    //noInterrupts();
    switch(MenuIndex){
      case(THSensorIndex):
        displayTHSensorValue();
        break;
      case(MoistureSensorIndex):
        displayMoistureSensorValue();
        break;
      case(UVSensorIndex):
        displayUVSensorValue();
        break;
      case(LightSensorIndex):
        displayLightSensorValue();
        break;
      case(LocalIPIndex):
        displayLocalIP();
        break;
     }
     curtime = millis();
    //interrupts();
  }
}

void TempColorHandle(){
  int temp = getTempSensorValue();
  if(!isBackLightOn){
    lcd.setRGB(0,0,0);
    return;
  }
  if(temp<LOW_TEMP) {
    BLColorRGB[0]=0x00;
    BLColorRGB[1]=0x00;
    BLColorRGB[2]=0xFF;
  }
  else if(temp<NOM_TEMP){
    BLColorRGB[0]=0x00;
    BLColorRGB[1]=map(temp,LOW_TEMP,NOM_TEMP-1,0,255);
    BLColorRGB[2]=map(temp,LOW_TEMP,NOM_TEMP-1,255,0);
  }
  else if(temp<HIGH_TEMP){
    BLColorRGB[0]=map(temp,NOM_TEMP,HIGH_TEMP-1,0,255);
    BLColorRGB[1]=map(temp,NOM_TEMP,HIGH_TEMP-1,255,0);
    BLColorRGB[2]=0x00;
  }
  else {
    BLColorRGB[0]=0xFF;
    BLColorRGB[1]=0x00;
    BLColorRGB[2]=0x00;
  }
  lcd.setRGB(BLColorRGB[0],BLColorRGB[1],BLColorRGB[2]);
}

void loop()
{
  TempColorHandle();

  displayMenu();

  SerialRequestHandler();

  //if button pressed, backlight transforms
  if(isButtonPressed()) isBackLightOn = !isBackLightOn;

  //if reconfig WiFi SSID,reconnect.
  if(isSSIDreconfiged==true) {
    status = WL_IDLE_STATUS;
    isSSIDreconfiged = false;
  }

}

int cmdstrInput(char *str){
  static int index = 0;
  if(Serial.available()){
    char inChar = Serial.read();
    cmdstr[index++]=inChar;
    if(inChar == '\n' || index >= CMDSTR_MAX_LEN){
      cmdstr[index-1]='\0';
      index = 0;
      return 1;
    }
  }
  return 0;
}

//initialize wifi connection
void WiFi_Init(){
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while(true);
  }

  String fv = WiFi.firmwareVersion();
  if( fv != "1.1.0" )
    Serial.println("Please upgrade the firmware");
}

// print the WiFi connection status using serialport
void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

// handl wifi request
void RequestHandler(){
  static unsigned long cur = millis();
  if(status != WL_CONNECTED && *ssid != '\0' && *psw !='\0'){
    if((millis()-cur) > 5000){
      Serial.print("Attempting to connect to SSID: ");
      Serial.println(ssid);
      // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
      status = WiFi.begin(ssid,psw);
      cur = millis();
    }
  } else if(status==WL_CONNECTED) {
    if(!serverconnected){
      server.begin();
      // you're connected now, so print out the status:
      printWifiStatus();
      serverconnected = 1;
    } else {
      sendpage();
    }
  }
}

// send html to client
void sendpage(){
   // listen for incoming clients
  WiFiClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 2");         // refresh the page automatically every 2 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("");
          client.println("<title>Grove Indoor Environment Kit for Edison</title>");
          client.println("");
          client.println("
Grove Indoor Environment Kit for Edison
");
          client.print("
");
          for(int i=0; i < SENSOR_COUNT; i++){
            client.print("
<big>");
            client.print(SerialVarList1[i]);
            client.print(" = ");
            client.print(SensorValue[i]);
            client.println("</big>
");
            //client.print("
");
          }
          client.println("");
           break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);

    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

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


added arduino yun code

added arduino yun code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

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


Light example

Light example

#include <ControlButton.h>
#include <ControlTimedOutput.h>
#include <PreciseDelay.h>

#define PIN_BUTTON D2
#define PIN_LIGHT  D0

ControlButton button(PIN_BUTTON);
ControlTimedOutput light (PIN_LIGHT, 5000);
PreciseDelay loopDelay;

void setup() {
  // put your setup code here, to run once:
  button.init();
  light.init();
}

void loop() {
  // put your main code here, to run repeatedly:
  button.tick();
  light.tick();

  if (button.pressed())
  {
    light.set();
  }

  loopDelay.delay();
}

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


Add new main file

Add new main file

This is the only file used to flash the Teensy driving the lighthouse.
Using Arduino IDE 1.6.9 and Teensyduino 1.29.

#include <FastLED.h>

#define LEDPIN   13
#define REDPIN   6
#define GREENPIN 20
#define BLUEPIN  21
#define WHITEPIN 5

CHSV gColor = {0,255,255};
float gWhite = 0;
float gBreathe = 0;  // low intensity version of gWhite (gWhite wins when it's not zero)

// This version is more robust
void SerialCommand()
{
  int count = 0;
  int num = 0;
  int command = 0;

  while (Serial.available())
  {
    char c = Serial.read();
    if (c == 'h' || c == 'b' || c == 's' || c == 'w')
    {
      num = 0;  // always begin anew when command received
      count = 0;
      command = c;
    }
    else
    {
      if (c >= '0' && c <= '9')
      {
        num = (10 * num) + (c - '0') ; // convert digits to a number
        count++;
      }
    }
  }

  switch (command)
  {
    case 'h':
        gColor.h = num;
        Serial.print("Color: ");
        Serial.println(num);
        break;

    case 'b':
        gColor.v = num;
        Serial.print("Brightness: ");
        Serial.println(num);
        break;

    case 's':
        gColor.s = num;
        Serial.print("Saturation: ");
        Serial.println(num);
        break;

    case 'w':
        gWhite = (float)num/100.0;
        Serial.print("White: ");
        Serial.println(num);
        break;

    default:
        break;
  }
}

void SetLEDs()
{
    const float kBreatheMax = 0.2;

    float white = gWhite;
    if (gWhite == 0)
        white = kBreatheMax * gBreathe;

    const int low = 800;  // lowest raw value where white leds turn off
    const int high = 1700; // highest value we allow for white leds

    int rawOutput = white * (high-low) + low;
    if (white == 0)
        rawOutput = 0;
    analogWrite(WHITEPIN, rawOutput);

    CHSV hsv(gColor);
    if (gBreathe > 0)
    {
        uint8_t byteBreate = 255.0 * gBreathe;
        Serial.println(gBreathe);
        Serial.println(byteBreate);
        hsv.s = min(255-byteBreate, hsv.s);
    }

    CRGB rgb(hsv);
    analogWrite(REDPIN,   (255-rgb.r) * 16);
    analogWrite(GREENPIN, (255-rgb.g) * 16);
    analogWrite(BLUEPIN,  (255-rgb.b) * 16);
}

// Flash the LEDs
void TestPattern()
{
  for (int i = 0; i < 8; i++)
  {
    gWhite = (i == 0) ? 0 : 1.0;
    SetLEDs();
    delay( 20 );
  }
  gWhite = 0;
}

int gFrame = 0;
int gFrameDelay = 1;

void BreatheWhite()
{
    const int kPeriod = 30000; // frames between breaths
    const int kUpFrame = 4000;
    const int kDownFrame = 6000;;
    int localFrame = gFrame % kPeriod;
    static float sFactor = 1.0;

    if (localFrame < kUpFrame)
        gBreathe = (float)localFrame / kUpFrame;
    else if (localFrame < kDownFrame)
        gBreathe = 1.0 - (float)(localFrame - kUpFrame) / (kDownFrame - kUpFrame);
    else if (localFrame < (kUpFrame + kDownFrame))
        gBreathe = (float)(localFrame - kDownFrame) / kUpFrame;
    else if (localFrame < (kDownFrame*2))
        gBreathe = 1.0 - (float)(localFrame - (kDownFrame + kUpFrame)) / (kDownFrame - kUpFrame);
    else
    {
        gBreathe = 0;
        sFactor = (float)random(50, 100)/100.0;
    }

    gBreathe = gBreathe * sFactor;
}

void WoopWoop()
{
    static CHSV beginWoopColor = gColor; // previous color
    static CHSV endWoopColor = gColor; // target color

    static int beginWoopFrame = gFrame; // frame where the fade started
    static int endWoopFrame = gFrame; // intended frame with full fade

    // Time to select next target?
    if (gFrame >= endWoopFrame)
    {
        beginWoopFrame = gFrame;
        endWoopFrame = beginWoopFrame + ( random16( 1000, 2000 ) / gFrameDelay );
        beginWoopColor = endWoopColor;
        endWoopColor.h = 232;
        endWoopColor.s = 255;
        endWoopColor.v = 255;
        if ( beginWoopColor.v == 255 )
        {
            endWoopColor.v = 0;//random8(0, 128);
        }
    }

    gColor = blend( beginWoopColor, endWoopColor, fract8(((gFrame - beginWoopFrame) * 255) / (endWoopFrame - beginWoopFrame)) );
}

void RandomColorFades()
{
    static CHSV beginColor = gColor; // previous color
    static CHSV endColor = gColor; // target color

    static int beginFrame = gFrame; // frame where the fade started
    static int endFrame = gFrame; // intended frame with full fade

    // Time to select next target?
    if (gFrame >= endFrame)
    {
        beginFrame = gFrame;
        endFrame = beginFrame + ( random16( 1000, 5000 ) / gFrameDelay );
        beginColor = endColor;
        endColor.h = random8();
        endColor.s = 255;
        endColor.v = 255;
        if ( beginColor.s == 255 )
        {
            endColor.s = random8(128, 255);
            endColor.v = 0;//random8(0, 128);
        }
    }

    gColor = blend( beginColor, endColor, fract8(((gFrame - beginFrame) * 255) / (endFrame - beginFrame)) );
}

void setup()
{
  Serial.begin(9600);
  randomSeed(analogRead(0));

  pinMode( WHITEPIN, OUTPUT );
  pinMode( REDPIN,   OUTPUT );
  pinMode( GREENPIN, OUTPUT );
  pinMode( BLUEPIN,  OUTPUT );

  //analogWriteFrequency(WHITEPIN, 11718.75);
  analogWriteResolution(12);

  TestPattern();
}

void loop()
{
   gFrame++;

   //SerialCommand();

    const int kPeriod = 100000; // frames between breaths
    int localFrame = gFrame % kPeriod;

    if (localFrame < kPeriod/2)
        RandomColorFades();
    else if (localFrame < kPeriod)
        WoopWoop();

   BreatheWhite();

  SetLEDs();
  delay(gFrameDelay);
}

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


updated for esp32

updated for esp32

/*
 * 2019-08-05 dvb
 * simplest example reading NTP to get time of day.
 */

#include <OmEspHelpers.h>

// These includes arent used in this file, but tells Arduino IDE that this project uses them.
#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>

OmWebServer s; // not serving any pages, put this brings up the wifi.
OmNtp ntp;

void setup()
{
  Serial.begin(115200);
  Serial.printf("\n\n\nWelcome to the Sketch\n\n");

  s.addWifi("omino warp", "0123456789");
  s.setNtp(&ntp);

  ntp.setTimeZone(-8); // CA, when in Pacific Standard Time, winter
                       // (not Pacific Daylight Time, -7, summer)
/*
 *
You can get the correct time zone if you run a short PHP script on
a web server you control, in your time zone. Here is the script:

    <?
    print date("Y-m-d H:i:s");
    print " + ";
    print date("e");
    ?>

And then you add this line here in setup():

    ntp.setTimeUrl("http://myserver.com/time.php");

Because ESP8266 web client library is blocking, we still prefer
the NTP protocol running on asynch UDP for the periodic synchronization,
with apologies and thanks to the time servers.
*
*/
}

int ticks = 0;
void loop()
{
  delay(10);
  s.tick();
  ntp.tick();

  ticks++;
  if(ticks % 877 == 0)
    Serial.printf("tick %4d, time: %s\n", ticks, ntp.getTimeString());
}

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


trust sensor is the same

trust sensor is the same

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


Changed UziFirmware.sendPinValues() to check if the pin is marked to be reported before sending back its value. Previously it was sending the values of all inputs, and since all pins are set as INPUT by default it was generating a lot of unnecesary traffic.

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/RichoM/Uzi.git/'


add arduino test

add arduino test

#include "Arduino.h"

int motorPin1_1 = 4;
int motorPin1_2 = 5;
int motorPin1_speed = 3;

int motorPin2_1 = 7;
int motorPin2_2 = 8;
int motorPin2_speed = 6;

int motorPin3_1 = 10;
int motorPin3_2 = 11;
int motorPin3_speed = 9;

int globalSpeedInit = 255;
int reducedSpeed = globalSpeedInit * 0.09;

int encoderValue_A = 0;
int encoderValue_B = 0;
int encoder_PinA = A2;
int encoder_PinB = A3;

void setup()
{
  Serial.begin(9600);
  while (!Serial)
    ;
  Serial.println("Init");

  pinMode(motorPin1_1, OUTPUT);
  pinMode(motorPin1_2, OUTPUT);
  pinMode(motorPin1_speed, OUTPUT);

  pinMode(motorPin2_1, OUTPUT);
  pinMode(motorPin2_2, OUTPUT);
  pinMode(motorPin2_speed, OUTPUT);

  pinMode(motorPin3_1, OUTPUT);
  pinMode(motorPin3_2, OUTPUT);
  pinMode(motorPin3_speed, OUTPUT);
}

/*
  void countA() {

  encoderValue_A++;
  }

  void countB() {

  encoderValue_B++;
  }
*/

void SetMotor(int pinSpeed, int pin1, int pin2, int speed, bool CW)
{
  analogWrite(pinSpeed, speed);
  if (!CW)
  {
    analogWrite(pin1, 0);
    analogWrite(pin2, 255);
  }
  else
  {
    analogWrite(pin1, 255);
    analogWrite(pin2, 0);
  }

  if (speed == 0)
  {
    analogWrite(pin1, 0);
    analogWrite(pin2, 0);
  }
}

void loop()
{

  SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, globalSpeedInit, true);
  SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, globalSpeedInit, true);
  SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, globalSpeedInit, true);
  delay(2500);
  SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, globalSpeedInit, false);
  SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, globalSpeedInit, false);
  SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, globalSpeedInit, false);
  delay(2500);

  SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, globalSpeedInit, true);
  SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, globalSpeedInit, false);
  SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, 0, true);
  delay(2500);
  SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, globalSpeedInit, false);
  SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, globalSpeedInit, true);
  SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, 0, true);
  delay(2500);

  SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, reducedSpeed, true);
  SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, reducedSpeed, true);
  SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, globalSpeedInit, false);
  delay(2500);
  SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, reducedSpeed, false);
  SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, reducedSpeed, false);
  SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, globalSpeedInit, true);
  delay(2500);

}

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


Create Tracker_exp.ino

Create Tracker_exp.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/Garuda-1/RealityGateway.git/'


got it working with 74HC273 D-Type Flip-Flop and cleaned up the comments that I put in when I was experimenting with git

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/mule-ear/shiny-spice.git/'


update function

update function

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/stevelacy/LEDFade.git/'


Modified to monitor small laser

Modified to monitor small laser

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


New example

New example

#include <Wire.h>
#include <TEA5767N.h>

TEA5767N radio = TEA5767N();

void setup() {

  radio.selectFrequency(89.1);

}

void loop() {

}

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


added Arduino showing how to read from the i2c port.

/*
Copyright (c) 2014, Pure Engineering LLC
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* 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 <SPI.h>

byte x = 0;
#define ADDRESS  (0x2A)

#define AGC (0x01)
#define SYS (0x02)
#define VID (0x03)
#define OEM (0x08)

#define GET (0x00)
#define SET (0x01)
#define RUN (0x02)

#define VOSPI_FRAME_SIZE (164)

void setup()
{
  //pinMode(pin, INPUT);           // set pin to input
  //digitalWrite(pin, HIGH);

  Wire.begin();
  Serial.begin(115200);

  pinMode(10, OUTPUT);
  SPI.setDataMode(SPI_MODE3);
  SPI.setClockDivider(0);

  SPI.begin();

  Serial.println("setup complete");
}

int spi_read_word(int data)
{
  int read_data;
  // take the SS pin low to select the chip:
  digitalWrite(10, LOW);
  //  send in the address and value via SPI:
  read_data = SPI.transfer(data >> 8) << 8;
  read_data |= SPI.transfer(data);
  // take the SS pin high to de-select the chip:
  digitalWrite(10, HIGH);
  return read_data;
}

byte lepton_frame_packet[VOSPI_FRAME_SIZE];

#define IMAGE_SIZE (800)
byte image[IMAGE_SIZE];
int image_index;
void read_lepton_frame(void)
{
  int i;
  for (i = 0; i < (VOSPI_FRAME_SIZE / 2); i++)
  {
    //digitalWrite(10, LOW);
    PORTB &= ~(1 << 2);
    //  send in the address and value via SPI:
    lepton_frame_packet[2 * i] = SPI.transfer(0x00);
    lepton_frame_packet[2 * i + 1] = SPI.transfer(0x00);

    // take the SS pin high to de-select the chip:
    //digitalWrite(10, HIGH);
    PORTB |= 1 << 2;
  }
}

void lepton_sync(void)
{
  int i;
  int data = 0x0f;

  PORTB |= 1 << 2;
  delay(185);
  while (data & 0x0f == 0x0f)
{
  PORTB &= ~(1 << 2);
    data = SPI.transfer(0x00) << 8;
    data |= SPI.transfer(0x00);
    PORTB |= 1 << 2;

    for (i = 0; i < ((VOSPI_FRAME_SIZE - 2) / 2); i++)
    {

      PORTB &= ~(1 << 2);

      SPI.transfer(0x00);
      SPI.transfer(0x00);

      PORTB |= 1 << 2;
    }
  }

}

void print_lepton_frame(void)
{
  int i;
  for (i = 0; i < (VOSPI_FRAME_SIZE); i++)
  {
    Serial.print(lepton_frame_packet[i], HEX);
    Serial.print(",");

  }
  Serial.println(" ");
}

void print_image(void)
{
  int i;
  for (i = 0; i < (IMAGE_SIZE); i++)
  {
    Serial.print(image[i], HEX);
    Serial.print(",");

  }
  Serial.println(" ");
}

void lepton_command(unsigned int moduleID, unsigned int commandID, unsigned int command)
{
  byte error;
  Wire.beginTransmission(ADDRESS);

  // Command Register is a 16-bit register located at Register Address 0x0004
  Wire.write(0x00);
  Wire.write(0x04);

  if (moduleID == 0x08) //OEM module ID
  {
    Wire.write(0x48);
  }
  else
  {
    Wire.write(moduleID & 0x0f);
  }
  Wire.write( ((commandID << 2 ) & 0xfc) | (command & 0x3));

  error = Wire.endTransmission();    // stop transmitting
  if (error != 0)
  {
    Serial.print("error=");
    Serial.println(error);
  }
}

void agc_enable()
{
  byte error;
  Wire.beginTransmission(ADDRESS); // transmit to device #4
  Wire.write(0x01);
  Wire.write(0x05);
  Wire.write(0x00);
  Wire.write(0x01);

  error = Wire.endTransmission();    // stop transmitting
  if (error != 0)
  {
    Serial.print("error=");
    Serial.println(error);
  }
}

void set_reg(unsigned int reg)
{
  byte error;
  Wire.beginTransmission(ADDRESS); // transmit to device #4
  Wire.write(reg >> 8 & 0xff);
  Wire.write(reg & 0xff);            // sends one byte

  error = Wire.endTransmission();    // stop transmitting
  if (error != 0)
  {
    Serial.print("error=");
    Serial.println(error);
  }
}

//Status reg 15:8 Error Code  7:3 Reserved 2:Boot Status 1:Boot Mode 0:busy

int read_reg(unsigned int reg)
{
  int reading = 0;
  set_reg(reg);

  Wire.requestFrom(ADDRESS, 2);

  reading = Wire.read();  // receive high byte (overwrites previous reading)
  //Serial.println(reading);
  reading = reading << 8;    // shift high byte to be high 8 bits

  reading |= Wire.read(); // receive low byte as lower 8 bits
  Serial.print("reg:");
  Serial.print(reg);
  Serial.print("==0x");
  Serial.print(reading, HEX);
  Serial.print(" binary:");
  Serial.println(reading, BIN);
  return reading;
}

int read_data()
{
  int i;
  int data;
  int payload_length;

  while (read_reg(0x2) & 0x01)
  {
    Serial.println("busy");
  }

  payload_length = read_reg(0x6);
  Serial.print("payload_length=");
  Serial.println(payload_length);

  Wire.requestFrom(ADDRESS, payload_length);
  //set_reg(0x08);
  for (i = 0; i < (payload_length / 2); i++)
  {
    data = Wire.read() << 8;
    data |= Wire.read();
    Serial.println(data, HEX);
  }

}

void loop()
{
  int i;
  int reading = 0;
  String debugString;
  Serial.println("beginTransmission");

  //set_reg(0);

  //read_reg(0x0);

  read_reg(0x2);

  Serial.println("SYS Camera Customer Serial Number");
  lepton_command(SYS, 0x28 >> 2 , GET);
  read_data();

  Serial.println("SYS Flir Serial Number");
  lepton_command(SYS, 0x2 , GET);
  read_data();

  Serial.println("SYS Camera Uptime");
  lepton_command(SYS, 0x0C >> 2 , GET);
  read_data();

  Serial.println("SYS Fpa Temperature Kelvin");
  lepton_command(SYS, 0x14 >> 2 , GET);
  read_data();

  Serial.println("SYS Aux Temperature Kelvin");
  lepton_command(SYS, 0x10 >> 2 , GET);
  read_data();

  Serial.println("OEM Chip Mask Revision");
  lepton_command(OEM, 0x14 >> 2 , GET);
  read_data();

  //Serial.println("OEM Part Number");
  //lepton_command(OEM, 0x1C >> 2 , GET);
  //read_data();

  Serial.println("OEM Camera Software Revision");
  lepton_command(OEM, 0x20 >> 2 , GET);
  read_data();

  Serial.println("AGC Enable");
  //lepton_command(AGC, 0x01  , SET);
  agc_enable();
  read_data();

  Serial.println("AGC READ");
  lepton_command(AGC, 0x00  , GET);
  read_data();

  // Serial.println("SYS Telemetry Enable State");
  //lepton_command(SYS, 0x19>>2 ,GET);
  // read_data();

  while (1)
  {
    //lepton_sync();
    read_lepton_frame();
    //if(lepton_frame_packet[i]&0x0f != 0x0f )
    {
      //print_lepton_frame();
    }

  }

  x++;
  delay(10000);
}

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


Cerveau: AI - ajout test funny action

Cerveau: AI - ajout test funny action

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'Cerveau/Artificial' did not match any file(s) known to git
error: pathspec 'Intelligence/ai/ai/ai.ino' did not match any file(s) known to git


Added rudimentary analogue controls for 3 motors.

These controls include up, down, along with translational motion horizontally.

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/ocean-x/erikson-1.git/'


修复了转向提前停止的问题

修复了转向提前停止的问题

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/qsheeeeen/shopping-robot.git/'