add arduino file

add arduino file

#include <Servo.h>

uint8_t _servoPins[8] = {A8,A10,A12,A14,A9,A11,A13,A15};

Servo servos[8] = {Servo(),Servo(),Servo(),Servo(),Servo(),Servo(),Servo(),Servo()};
String received = "";
int releaseAngle = 62;
int holdAngle = 105;
int actionTime = 250;
int motionTime = 200;
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200);
  delay(100);
  enableServos();
}
void disableServos(){
  for(uint8_t i=0;i<8;i++){
    servos[i].detach();
  }
}
void enableServos(){
  for(uint8_t i=0;i<8;i++){
    servos[i].attach(_servoPins[i]);
    servos[i].write(i<4?90:releaseAngle);
    delay(motionTime-100);
  }
  delay(motionTime);
  servos[0].write(90);
  delay(motionTime);
  servos[1].write(90);
  delay(motionTime);
  servos[2].write(90);
  delay(motionTime);
  servos[3].write(90);
  delay(motionTime);
}
void flipX(int dir){
  releaseY();
  delay(motionTime);
  servos[1].write(0);
  servos[3].write(180);
  delay(motionTime+200);
  holdX();
  delay(motionTime);
  if(dir==1){
    servos[0].write(0);
    servos[2].write(180);
  }else{
    servos[0].write(180);
    servos[2].write(0);
  }
  delay(motionTime+200);
  holdY();
  delay(motionTime);
  releaseX();
  delay(motionTime);
  servos[0].write(90);
  servos[2].write(90);
  delay(motionTime+200);
  holdX();
  delay(motionTime);
  releaseY();
  delay(motionTime);
  servos[1].write(90);
  servos[3].write(90);
  delay(motionTime+200);
  holdY();
  delay(motionTime);
}
void holdX(){
  servos[4].write(holdAngle-4);
  servos[6].write(holdAngle+4);
}
void releaseX(){
  servos[4].write(releaseAngle);
  servos[6].write(releaseAngle);
}

void flipY(int dir){
  releaseX();
  delay(motionTime);
  holdY();
  delay(motionTime);
  if(dir==1){
    servos[1].write(0);
    servos[3].write(180);
  }else{
    servos[1].write(180);
    servos[3].write(0);
  }
  delay(motionTime+200);
  holdX();
  delay(motionTime);
  releaseY();
  delay(motionTime);
  servos[1].write(90);
  servos[3].write(90);
  delay(motionTime+200);
  holdY();
  delay(motionTime);
}
void holdY(){
  servos[5].write(holdAngle-4);
  servos[7].write(holdAngle+4);
}
void releaseY(){
  servos[5].write(releaseAngle);
  servos[7].write(releaseAngle);
}
void rotateX(int dir,int face){
  int count = dir>0?dir:-dir;
  holdX();
  delay(motionTime);
  releaseY();
  delay(motionTime);
  servos[1].write(0);
  servos[3].write(180);
  delay(motionTime+100);
  for(int i=0;i<count;i++){
    holdY();
    delay(motionTime);
    servos[face==1?0:2].write(dir>0?180:0);
    delay(motionTime+300);
    servos[face==1?4:6].write(releaseAngle);
    delay(motionTime+100);
    servos[face==1?0:2].write(90);
    delay(motionTime+100);
    holdX();
    delay(motionTime);
  }
  servos[face==1?0:2].write(dir>0?102:76);
  delay(motionTime);
  servos[face==1?0:2].write(90);
  delay(motionTime);
  releaseY();
  delay(motionTime);
  servos[1].write(90);
  servos[3].write(90);
  delay(motionTime);
  holdY();
  delay(motionTime);
}
void rotateY(int dir,int face){
  int count = dir>0?dir:-dir;
  holdX();
  holdY();
  delay(motionTime);
  for(int i=0;i<count;i++){
    servos[face==1?1:3].write(dir>0?180:0);
    delay(motionTime+300);
    servos[face==1?5:7].write(releaseAngle);
    delay(motionTime+100);
    servos[face==1?1:3].write(90);
    delay(motionTime+300);
    holdY();
    delay(motionTime);
  }
  servos[face==1?1:3].write(dir>0?102:75);
  delay(motionTime);
  servos[face==1?1:3].write(90);
  delay(motionTime);
}
void loop() {
 if(Serial.available()){
    char c = Serial.read();
    if(c=='\n'){
      parseCommand();
      received="";
    }else{
      received+=c;
    }
  }
}
void parseCommand() {
  received.toLowerCase();
  char m_cmd = received.substring(0, 1).charAt(0);
  int s_cmd = received.substring(1,2).toInt();
  int v_cmd = received.substring(4).toInt();

  if(m_cmd=='m'){
    if(s_cmd==1){
      int count = v_cmd>0?v_cmd:-v_cmd;
      for(int i=0;i<count;i++){
        flipX(v_cmd>0?1:-1);
      }
    }else if(s_cmd==2){
      int count = v_cmd>0?v_cmd:-v_cmd;
      for(int i=0;i<count;i++){
        flipY(v_cmd>0?1:-1);
      }
    }else if(s_cmd==3){
      v_cmd==1?holdX():holdY();
    }else if(s_cmd==4){
      v_cmd==1?releaseX():releaseY();
    }else if(s_cmd==5){
      rotateX(v_cmd,1);
    }else if(s_cmd==6){
      rotateX(v_cmd,-1);
    }else if(s_cmd==7){
      rotateY(v_cmd,1);
    }else if(s_cmd==8){
      rotateY(v_cmd,-1);
    }
  }
  Serial.println("ok");
}

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


getting the signing right … not

getting the signing right … not

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


hmm, restoring the register descriptions …


Create Modbus.ino

Create Modbus.ino

/**
 * @file
 * Arduino library for communicating with Modbus devices over RS232/485 (via RTU protocol).
 *
 * @defgroup setup Modbus Object Instantiation/Initialization
 * @defgroup loop Modbus Object Management
 * @defgroup buffer Modbus Buffer Management
 * @defgroup discrete Modbus Function Codes for Discrete Coils/Inputs
 * @defgroup register Modbus Function Codes for Holding/Input Registers
 */

#define  MAX_BUFFER  64

/* _____PROJECT INCLUDES_____________________________________________________ */
// functions to calculate Modbus Application Data Unit CRC
//#include <util/crc16.h>

/* _____GLOBAL VARIABLES_____________________________________________________ */
HardwareSerial port = Serial; ///< Pointer to Serial class object

typedef struct {
  uint8_t u8id;
  uint8_t u8fct;
  uint16_t u16RegAdd;
  uint16_t u16CoilsNo;
  uint16_t *au16reg;
}
modbus_t;

enum {
  RESPONSE_SIZE = 6,
  EXCEPTION_SIZE = 3,
  CHECKSUM_SIZE = 2
};

enum MESSAGE {
  ID                             = 0,
  FUNC,
  ADD_HI,
  ADD_LO,
  NB_HI,
  NB_LO,
  BYTE_CNT };

enum MB_FC {
  MB_FC_NONE                     = 0,
  MB_FC_READ_COILS               = 1,
  MB_FC_READ_DISCRETE_INPUT      = 2,
  MB_FC_READ_REGISTERS           = 3,
  MB_FC_READ_INPUT_REGISTER      = 4,
  MB_FC_WRITE_COIL               = 5,
  MB_FC_WRITE_REGISTER           = 6,
  MB_FC_WRITE_MULTIPLE_COILS     = 15,
  MB_FC_WRITE_MULTIPLE_REGISTERS = 16
};

enum COM_STATES {
  COM_IDLE                     = 0,
  COM_WAITING                  = 1

};

enum ERR_LIST {
  ERR_NOT_MASTER                = -1,
  ERR_POLLING                   = -2,
  ERR_BUFF_OVERFLOW             = -3,
  ERR_BAD_CRC                   = -4,
  ERR_EXCEPTION                 = -5
};

/* exceptions code */
enum {
  NO_REPLY = 255,
  EXC_FUNC_CODE = 1,
  EXC_ADDR_RANGE = 2,
  EXC_REGS_QUANT = 3,
  EXC_EXECUTE = 4
};

/* supported functions. If you implement a new one, put its function code into this array! */
const unsigned char fctsupported[] = {
  MB_FC_READ_COILS,
  MB_FC_READ_DISCRETE_INPUT,
  MB_FC_READ_REGISTERS,
  MB_FC_READ_INPUT_REGISTER,
  MB_FC_WRITE_COIL,
  MB_FC_WRITE_REGISTER,
  MB_FC_WRITE_MULTIPLE_COILS,
  MB_FC_WRITE_MULTIPLE_REGISTERS
};

#define T35  5

/* _____CLASS DEFINITIONS____________________________________________________ */
/**
 * Arduino class library for communicating with Modbus devices over
 * RS232/485 (via RTU protocol).
 */
class Modbus {
private:
  uint8_t u8id; // 0=master, 1..247=slave number
  uint8_t u8serno; // serial port: 0-Serial, 1..3-Serial1..Serial3
  uint8_t u8txenpin; // 0=USB or RS-232 mode, >0=RS-485 mode
  uint8_t u8state;
  uint8_t au8Buffer[MAX_BUFFER];
  uint8_t u8BufferSize;
  uint8_t u8lastRec;
  uint16_t *au16regs;
  uint16_t u16InCnt, u16OutCnt, u16errCnt;
  uint16_t u16timeOut;
  uint32_t u32time, u32timeOut;
  uint8_t u8regsize;

  void init(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin);
  void sendTxBuffer(); // transmit buffer to serial port
  int8_t getRxBuffer(); // get serial buffer contents
  uint16_t calcCRC(uint8_t u8length); // get CRC from au8Buffer until u8length
  uint8_t validateAnswer();
  uint8_t validateRequest(); // validate master request
  void get_FC1(); // *** only master ***
  void get_FC3(); // *** only master ***
  int8_t process_FC1( uint16_t *regs, uint8_t u8size ); // *** only slave ***
  int8_t process_FC3( uint16_t *regs, uint8_t u8size ); // *** only slave ***
  int8_t process_FC5( uint16_t *regs, uint8_t u8size ); // *** only slave ***
  int8_t process_FC6( uint16_t *regs, uint8_t u8size ); // *** only slave ***
  int8_t process_FC15( uint16_t *regs, uint8_t u8size ); // *** only slave ***
  int8_t process_FC16( uint16_t *regs, uint8_t u8size ); // *** only slave ***
  void buildException( uint8_t u8exception ); // build exception message

public:
  Modbus();
  Modbus(uint8_t u8id, uint8_t u8serno);
  Modbus(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin);
  void begin(long u32speed);
  void begin();
  void setTimeOut( uint16_t u16timeout); // only for master
  uint16_t getTimeOut(); // only for master
  int8_t query( modbus_t telegram ); // only for master
  int8_t poll(); // cyclic poll for master
  int8_t poll( uint16_t *regs, uint8_t u8size ); // cyclic poll for slave
  uint16_t getInCnt(); // number of incoming messages
  uint16_t getOutCnt(); // number of outcoming messages
  uint16_t getErrCnt(); // error counter
  uint8_t getID();
  uint8_t getState();
};

/* _____PUBLIC FUNCTIONS_____________________________________________________ */
/**
 * Constructor
 *
 * @ingroup setup
 */
Modbus::Modbus() {
  init(0, 0, 0);
}

/**
 * Constructor
 *
 * @param u8id   node address 0=master, 1..247=slave
 * @param u8serno  serial port used 0..3
 * @ingroup setup
 */
Modbus::Modbus(uint8_t u8id, uint8_t u8serno) {
  init(u8id, u8serno, 0);
}

/**
 * Constructor
 *
 * @param u8id   node address 0=master, 1..247=slave
 * @param u8serno  serial port used 0..3
 * @param u8txenpin pin for txen RS-485
 * @ingroup setup
 */
Modbus::Modbus(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) {
  init(u8id, u8serno, u8txenpin);
}

/**
 * Initialize class object.
 *
 * Sets up the serial port using specified baud rate.
 * Call once class has been instantiated, typically within setup().
 *
 * @param speed baud rate, in standard increments (300..115200)
 *
 * @param config parity and word length
 * @ingroup setup
 */
void Modbus::begin(long u32speed) {

  switch( u8serno ) {
#if defined(UBRR1H)
  case 1:
    port = Serial1;
    break;
#endif

#if defined(UBRR2H)
  case 2:
    port = Serial2;
    break;
#endif

#if defined(UBRR3H)
  case 3:
    port = Serial3;
    break;
#endif
  case 0:
  default:
    port = Serial;
    break;
  }

  // port.begin(u32speed, u8config);
  port.begin(u32speed);
  if (u8txenpin > 1) { // pin 0 & pin 1 are reserved for RX/TX
    // return RS485 transceiver to transmit mode
    pinMode(u8txenpin, OUTPUT);
    digitalWrite(u8txenpin, LOW);
  }

  port.flush();
  u8lastRec = u8BufferSize = 0;
  u16InCnt = u16OutCnt = u16errCnt = 0;
}

/**
 * Initialize class object.
 *
 * Sets up the serial port using 19200 baud.
 * Call once class has been instantiated, typically within setup().
 *
 * @overload ModbusMaster::begin(uint16_t u16BaudRate)
 * @ingroup setup
 */
void Modbus::begin() {
  begin(19200);
}

/**
 * Initialize time-out parameter
 *
 * Call once class has been instantiated, typically within setup().
 *
 * @param time-out value (ms)
 * @ingroup setup
 */
void Modbus::setTimeOut( uint16_t u16timeOut) {
  this->u16timeOut = u16timeOut;
}

/**
 * Get input messages counter value
 *
 * @returns input messages counter
 * @ingroup buffer
 */
uint16_t Modbus::getInCnt() {
  return u16InCnt;
}

/**
 * Get transmitted messages counter value
 *
 * @returns transmitted messages counter
 * @ingroup buffer
 */
uint16_t Modbus::getOutCnt() {
  return u16OutCnt;
}

/**
 * Get errors counter value
 *
 * @returns errors counter
 * @ingroup buffer
 */
uint16_t Modbus::getErrCnt() {
  return u16errCnt;
}

/**
 * Get modbus master state
 *
 * @returns = 0 IDLE, = 1 WAITING FOR ANSWER
 * @ingroup buffer
 */
uint8_t Modbus::getState() {
  return u8state;
}

/**
 * Only Modbus Master
 * Query to an slave with a modbus telegram structure
 * The Master must be in COM_IDLE mode. After it, its state would be COM_WAITING
 *
 * @param modbus_t  modbus telegram structure (id, fct, ...)
 * @ingroup buffer
 */
int8_t Modbus::query( modbus_t telegram ) {
  uint8_t u8regsno, u8bytesno;
  if (u8id!=0) return -2;
  if (u8state != COM_IDLE) return -1;

  if ((telegram.u8id==0) || (telegram.u8id>247)) return -3;

  au16regs = telegram.au16reg;

  // telegram header
  au8Buffer[ ID ]         = telegram.u8id;
  au8Buffer[ FUNC ]       = telegram.u8fct;
  au8Buffer[ ADD_HI ]     = highByte(telegram.u16RegAdd );
  au8Buffer[ ADD_LO ]     = lowByte( telegram.u16RegAdd );

  switch( telegram.u8fct ) {
  case MB_FC_READ_COILS:
  case MB_FC_READ_DISCRETE_INPUT:
  case MB_FC_READ_REGISTERS:
  case MB_FC_READ_INPUT_REGISTER:
    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );
    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );
    u8BufferSize = 6;
    break;
  case MB_FC_WRITE_COIL:
    au8Buffer[ NB_HI ]      = ((au16regs[0] > 0) ? 0xff : 0);
    au8Buffer[ NB_LO ]      = 0;
    u8BufferSize = 6;
    break;
  case MB_FC_WRITE_REGISTER:
    au8Buffer[ NB_HI ]      = highByte(au16regs[0]);
    au8Buffer[ NB_LO ]      = lowByte(au16regs[0]);
    u8BufferSize = 6;
    break;
  case MB_FC_WRITE_MULTIPLE_COILS:
    u8regsno = telegram.u16CoilsNo / 16;
    u8bytesno = u8regsno * 2;
    if ((telegram.u16CoilsNo % 16) != 0) {
      u8bytesno++;
      u8regsno++;
    }

    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );
    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );
    au8Buffer[ NB_LO+1 ]    = u8bytesno;
    u8BufferSize = 7;

    u8regsno = u8bytesno = 0; // now auxiliary registers
    for (uint16_t i = 0; i < telegram.u16CoilsNo; i++) {

    }
    break;

  case MB_FC_WRITE_MULTIPLE_REGISTERS:
    au8Buffer[ NB_HI ]      = highByte(telegram.u16CoilsNo );
    au8Buffer[ NB_LO ]      = lowByte( telegram.u16CoilsNo );
    au8Buffer[ NB_LO+1 ]    = (uint8_t) ( telegram.u16CoilsNo * 2 );
    u8BufferSize = 7;

    for (uint16_t i=0; i< telegram.u16CoilsNo; i++) {
      au8Buffer[ u8BufferSize ] = highByte( au16regs[ i ] );
      u8BufferSize++;
      au8Buffer[ u8BufferSize ] = lowByte( au16regs[ i ] );
      u8BufferSize++;
    }
    break;
  }

  sendTxBuffer();
  u8state = COM_WAITING;
  return 0;
}

/**
 * *** Only for Modbus Master ***
 * This method checks if there is any incoming answer if pending
 * If there is no answer, it would change Master state to COM_IDLE
 * This method must be called only at loop section
 * Avoid any delay() function
 *
 * @returns errors counter
 * @ingroup buffer
 */
int8_t Modbus::poll() {
  // check if there is any incoming frame
  uint8_t u8current = port.available();

  if (millis() > u32timeOut) {
    u8state = COM_IDLE;
    u16errCnt++;
    return 0;
  }

  if (u8current == 0) return 0;

  // check T35 after frame end or still no frame end
  if (u8current != u8lastRec) {
    u8lastRec = u8current;
    u32time = millis() + T35;
    return 0;
  }
  if (millis() < u32time) return 0;

  // transfer Serial buffer frame to auBuffer
  u8lastRec = 0;
  int8_t i8state = getRxBuffer();
  if (i8state < 7) {
    u8state = COM_IDLE;
    u16errCnt++;
    return i8state;
  }

  // validate message: id, CRC, FCT, exception
  uint8_t u8exception = validateAnswer();
  if (u8exception != 0) {
    u8state = COM_IDLE;
    return u8exception;
  }

  // process answer
  switch( au8Buffer[ FUNC ] ) {
  case MB_FC_READ_COILS:
  case MB_FC_READ_DISCRETE_INPUT:
    get_FC1( );
    break;
  case MB_FC_READ_INPUT_REGISTER:
  case MB_FC_READ_REGISTERS :
    get_FC3( );
    break;
  case MB_FC_WRITE_COIL:
  case MB_FC_WRITE_REGISTER :
  case MB_FC_WRITE_MULTIPLE_COILS:
  case MB_FC_WRITE_MULTIPLE_REGISTERS :
    break;
  default:
    break;
  }
  u8state = COM_IDLE;
  return u8BufferSize;
}

/**
 * Only for Modbus Slave
 * This method checks if there is any incoming query
 * Afterwards, it would shoot a validation routine plus a register query
 * Avoid any delay() function
 *
 * @param *regs  register table for communication exchange
 * @param u8size  size of the register table
 * @returns 0 if no query, 1..4 if communication error, >4 if correct query processed
 * @ingroup buffer
 */
int8_t Modbus::poll( uint16_t *regs, uint8_t u8size ) {

  au16regs = regs;
  u8regsize = u8size;

  // check if there is any incoming frame
  uint8_t u8current = port.available();
  if (u8current == 0) return 0;

  // check T35 after frame end or still no frame end
  if (u8current != u8lastRec) {
    u8lastRec = u8current;
    u32time = millis() + T35;
    return 0;
  }
  if (millis() < u32time) return 0;

  u8lastRec = 0;
  int8_t i8state = getRxBuffer();
  if (i8state < 7) return i8state;

  // check slave id
  if (au8Buffer[ ID ] != u8id) return 0;

  // validate message: CRC, FCT, address and size
  uint8_t u8exception = validateRequest();
  if (u8exception > 0) {
    if (u8exception != NO_REPLY) {
      buildException( u8exception );
      sendTxBuffer();
    }
    return u8exception;
  }

  // process message
  switch( au8Buffer[ FUNC ] ) {
  case MB_FC_READ_COILS:
  case MB_FC_READ_DISCRETE_INPUT:
    return process_FC1( regs, u8size );
    break;
  case MB_FC_READ_INPUT_REGISTER:
  case MB_FC_READ_REGISTERS :
    return process_FC3( regs, u8size );
    break;
  case MB_FC_WRITE_COIL:
    return process_FC5( regs, u8size );
    break;
  case MB_FC_WRITE_REGISTER :
    return process_FC6( regs, u8size );
    break;
  case MB_FC_WRITE_MULTIPLE_COILS:
    return process_FC15( regs, u8size );
    break;
  case MB_FC_WRITE_MULTIPLE_REGISTERS :
    return process_FC16( regs, u8size );
    break;
  default:
    break;
  }
}

/* _____PRIVATE FUNCTIONS_____________________________________________________ */

void Modbus::init(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin) {
  this->u8id = u8id;
  this->u8serno = (u8serno > 3) ? 0 : u8serno;
  this->u8txenpin = u8txenpin;
  this->u16timeOut = 1000;
}

/**
 * This method moves Serial buffer data to the Modbus au8Buffer.
 *
 * @returns buffer size if OK, ERR_BUFF_OVERFLOW if u8BufferSize >= MAX_BUFFER
 * @ingroup buffer
 */
int8_t Modbus::getRxBuffer() {
  boolean bBuffOverflow = false;

  if (u8txenpin > 1) digitalWrite( u8txenpin, LOW );

  u8BufferSize = 0;
  while ( port.available() ) {
    au8Buffer[ u8BufferSize ] = port.read();
    u8BufferSize ++;

    if (u8BufferSize >= MAX_BUFFER) bBuffOverflow = true;
  }
  u16InCnt++;

  if (bBuffOverflow) {
    u16errCnt++;
    return ERR_BUFF_OVERFLOW;
  }
  return u8BufferSize;
}

/**
 * This method transmits au8Buffer to Serial line
 *
 * @ingroup buffer
 */
void Modbus::sendTxBuffer() {
  uint8_t i = 0;

  // append CRC to message
  uint16_t u16crc = calcCRC( u8BufferSize );
  au8Buffer[ u8BufferSize ] = u16crc >> 8;
  u8BufferSize++;
  au8Buffer[ u8BufferSize ] = u16crc & 0x00ff;
  u8BufferSize++;

  // set RS485 transceiver to transmit mode
  if (u8txenpin > 1) {
    switch( u8serno ) {
#if defined(UBRR1H)
    case 1:
      UCSR1A=UCSR1A |(1 << TXC1);
      break;
#endif

#if defined(UBRR2H)
    case 2:
      UCSR2A=UCSR2A |(1 << TXC2);
      break;
#endif

#if defined(UBRR3H)
    case 3:
      UCSR3A=UCSR3A |(1 << TXC3);
      break;
#endif
    case 0:
    default:
      UCSR0A=UCSR0A |(1 << TXC0);
      break;
    }
    digitalWrite( u8txenpin, HIGH );
  }

  // transfer buffer to serial line
  port.write( au8Buffer, u8BufferSize );

  // keep RS485 transceiver in transmit mode as long as sending
  if (u8txenpin > 1) {
    switch( u8serno ) {
#if defined(UBRR1H)
    case 1:
      while (!(UCSR1A & (1 << TXC1)));
      break;
#endif

#if defined(UBRR2H)
    case 2:
      while (!(UCSR2A & (1 << TXC2)));
      break;
#endif

#if defined(UBRR3H)
    case 3:
      while (!(UCSR3A & (1 << TXC3)));
      break;
#endif
    case 0:
    default:
      while (!(UCSR0A & (1 << TXC0)));
      break;
    }

    // return RS485 transceiver to receive mode
    digitalWrite( u8txenpin, LOW );
  }
  port.flush();
  u8BufferSize = 0;

  // set time-out for master
  u32timeOut = millis() + (unsigned long) u16timeOut;

  // increase message counter
  u16OutCnt++;
}

/**
 * This method calculates CRC
 *
 * @return uint16_t calculated CRC value for the message
 * @ingroup buffer
 */
uint16_t Modbus::calcCRC(uint8_t u8length) {
  unsigned int temp, temp2, flag;
  temp = 0xFFFF;
  for (unsigned char i = 0; i < u8length; i++) {
    temp = temp ^ au8Buffer[i];
    for (unsigned char j = 1; j <= 8; j++) {
      flag = temp & 0x0001;
      temp >>=1;
      if (flag)
        temp ^= 0xA001;
    }
  }
  // Reverse byte order.
  temp2 = temp >> 8;
  temp = (temp << 8) | temp2;
  temp &= 0xFFFF;
  // the returned value is already swapped
  // crcLo byte is first & crcHi byte is last
  return temp;
}

/**
 * This method validates slave incoming messages
 *
 * @return 0 if OK, EXCEPTION if anything fails
 * @ingroup buffer
 */
uint8_t Modbus::validateRequest() {
  // check message crc vs calculated crc
  uint16_t u16MsgCRC =
    ((au8Buffer[u8BufferSize - 2] << 8)
    | au8Buffer[u8BufferSize - 1]); // combine the crc Low & High bytes
  if ( calcCRC( u8BufferSize-2 ) != u16MsgCRC ) {
    u16errCnt ++;
    return NO_REPLY;
  }

  // check fct code
  boolean isSupported = false;
  for (uint8_t i = 0; i< sizeof( fctsupported ); i++) {
    if (fctsupported[i] == au8Buffer[FUNC]) {
      isSupported = 1;
      break;
    }
  }
  if (!isSupported) {
    u16errCnt ++;
    return EXC_FUNC_CODE;
  }

  // check start address & nb range
  uint16_t u16regs = 0;
  uint8_t u8regs;
  switch ( au8Buffer[ FUNC ] ) {
  case MB_FC_READ_COILS:
  case MB_FC_READ_DISCRETE_INPUT:
  case MB_FC_WRITE_MULTIPLE_COILS:
    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]) / 16;
    u16regs += word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ]) /16;
    u8regs = (uint8_t) u16regs;
    if (u8regs >= u8regsize) return EXC_ADDR_RANGE;
    break;
  case MB_FC_WRITE_COIL:
    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]) / 16;
    u8regs = (uint8_t) u16regs;
    if (u8regs >= u8regsize) return EXC_ADDR_RANGE;
    break;
  case MB_FC_WRITE_REGISTER :
    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]);
    u8regs = (uint8_t) u16regs;
    if (u8regs >= u8regsize) return EXC_ADDR_RANGE;
    break;
  case MB_FC_READ_REGISTERS :
  case MB_FC_READ_INPUT_REGISTER :
  case MB_FC_WRITE_MULTIPLE_REGISTERS :
    u16regs = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ]);
    u16regs += word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ]);
    u8regs = (uint8_t) u16regs;
    if (u8regs >= u8regsize) return EXC_ADDR_RANGE;
    break;
  }
  return 0; // OK, no exception code thrown
}

/**
 * This method validates master incoming messages
 *
 * @return 0 if OK, EXCEPTION if anything fails
 * @ingroup buffer
 */
uint8_t Modbus::validateAnswer() {
  // check message crc vs calculated crc
  uint16_t u16MsgCRC =
    ((au8Buffer[u8BufferSize - 2] << 8)
    | au8Buffer[u8BufferSize - 1]); // combine the crc Low & High bytes
  if ( calcCRC( u8BufferSize-2 ) != u16MsgCRC ) {
    u16errCnt ++;
    return NO_REPLY;
  }

  // check exception
  if ((au8Buffer[ FUNC ] & 0x80) != 0) {
    u16errCnt ++;
    return ERR_EXCEPTION;
  }

  // check fct code
  boolean isSupported = false;
  for (uint8_t i = 0; i< sizeof( fctsupported ); i++) {
    if (fctsupported[i] == au8Buffer[FUNC]) {
      isSupported = 1;
      break;
    }
  }
  if (!isSupported) {
    u16errCnt ++;
    return EXC_FUNC_CODE;
  }

  return 0; // OK, no exception code thrown
}

/**
 * This method builds an exception message
 *
 * @ingroup buffer
 */
void Modbus::buildException( uint8_t u8exception ) {
  uint8_t u8func = au8Buffer[ FUNC ];  // get the original FUNC code

  au8Buffer[ ID ]      = u8id;
  au8Buffer[ FUNC ]    = u8func + 0x80;
  au8Buffer[ 2 ]       = u8exception;
  u8BufferSize         = EXCEPTION_SIZE;
}

/**
 * This method processes functions 1 & 2 (for master)
 * This method puts the slave answer into master data buffer
 *
 * @ingroup register
 */
void Modbus::get_FC1() {
  uint8_t u8byte, i;
  u8byte = 0;

  //  for (i=0; i< au8Buffer[ 2 ] /2; i++) {
  //    au16regs[ i ] = word(
  //    au8Buffer[ u8byte ],
  //    au8Buffer[ u8byte +1 ]);
  //    u8byte += 2;
  //  }
}

/**
 * This method processes functions 3 & 4 (for master)
 * This method puts the slave answer into master data buffer
 *
 * @ingroup register
 */
void Modbus::get_FC3() {
  uint8_t u8byte, i;
  u8byte = 3;

  for (i=0; i< au8Buffer[ 2 ] /2; i++) {
    au16regs[ i ] = word(
    au8Buffer[ u8byte ],
    au8Buffer[ u8byte +1 ]);
    u8byte += 2;
  }
}

/**
 * This method processes functions 1 & 2
 * This method reads a bit array and transfers it to the master
 *
 * @return u8BufferSize Response to master length
 * @ingroup discrete
 */
int8_t Modbus::process_FC1( uint16_t *regs, uint8_t u8size ) {
  uint8_t u8currentRegister, u8currentBit, u8bytesno, u8bitsno;
  uint16_t u16currentCoil, u16coil;

  // get the first and last coil from the message
  uint16_t u16StartCoil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );
  uint16_t u16Coilno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );

  // put the number of bytes in the outcoming message
  u8bytesno = (uint8_t) (u16Coilno / 8);
  if (u16Coilno % 8 != 0) u8bytesno ++;
  au8Buffer[ ADD_HI ]  = u8bytesno;
  u8BufferSize         = ADD_LO;

  // read each coil from the register map and put its value inside the outcoming message
  u8bitsno = 0;

  for (u16currentCoil = 0; u16currentCoil < u16Coilno; u16currentCoil++) {
    u16coil = u16StartCoil + u16currentCoil;
    u8currentRegister = (uint8_t) (u16coil / 16);
    u8currentBit = (uint8_t) (u16coil % 16);

    bitWrite(
    au8Buffer[ u8BufferSize ],
    u8bitsno,
    bitRead( regs[ u8currentRegister ], u8currentBit ) );
    u8bitsno ++;

    if (u8bitsno > 7) {
      u8bitsno = 0;
      u8BufferSize++;
    }
  }

  // send outcoming message
  if (u16Coilno % 8 != 0) u8BufferSize ++;
  sendTxBuffer();
  return u8BufferSize;
}

/**
 * This method processes functions 3 & 4
 * This method reads a word array and transfers it to the master
 *
 * @return u8BufferSize Response to master length
 * @ingroup register
 */
int8_t Modbus::process_FC3( uint16_t *regs, uint8_t u8size ) {

  uint8_t u8StartAdd = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );
  uint8_t u8regsno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );
  uint8_t i;

  au8Buffer[ 2 ]       = u8regsno*2;
  u8BufferSize         = 3;

  for (i = u8StartAdd; i< u8StartAdd + u8regsno; i++) {
    au8Buffer[ u8BufferSize ] = highByte(regs[i]);
    u8BufferSize++;
    au8Buffer[ u8BufferSize ] = lowByte(regs[i]);
    u8BufferSize++;
  }
  sendTxBuffer();

  return u8BufferSize;
}

/**
 * This method processes function 5
 * This method writes a value assigned by the master to a single bit
 *
 * @return u8BufferSize Response to master length
 * @ingroup discrete
 */
int8_t Modbus::process_FC5( uint16_t *regs, uint8_t u8size ) {
  uint8_t u8currentRegister, u8currentBit;
  uint16_t u16coil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );

  // point to the register and its bit
  u8currentRegister = (uint8_t) (u16coil / 16);
  u8currentBit = (uint8_t) (u16coil % 16);

  // write to coil
  bitWrite(
  regs[ u8currentRegister ],
  u8currentBit,
  au8Buffer[ NB_HI ] == 0xff );

  // send answer to master
  u8BufferSize = 6;
  sendTxBuffer();

  return u8BufferSize;
}

/**
 * This method processes function 6
 * This method writes a value assigned by the master to a single word
 *
 * @return u8BufferSize Response to master length
 * @ingroup register
 */
int8_t Modbus::process_FC6( uint16_t *regs, uint8_t u8size ) {

  uint8_t u8add = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );
  uint16_t u16val = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );

  regs[ u8add ] = u16val;

  // keep the same header
  u8BufferSize         = RESPONSE_SIZE;

  sendTxBuffer();
  return u8BufferSize;
}

/**
 * This method processes function 15
 * This method writes a bit array assigned by the master
 *
 * @return u8BufferSize Response to master length
 * @ingroup discrete
 */
int8_t Modbus::process_FC15( uint16_t *regs, uint8_t u8size ) {
  uint8_t u8currentRegister, u8currentBit, u8frameByte, u8bitsno;
  uint16_t u16currentCoil, u16coil;
  boolean bTemp;

  // get the first and last coil from the message
  uint16_t u16StartCoil = word( au8Buffer[ ADD_HI ], au8Buffer[ ADD_LO ] );
  uint16_t u16Coilno = word( au8Buffer[ NB_HI ], au8Buffer[ NB_LO ] );

  // read each coil from the register map and put its value inside the outcoming message
  u8bitsno = 0;
  u8frameByte = 7;
  for (u16currentCoil = 0; u16currentCoil < u16Coilno; u16currentCoil++) {

    u16coil = u16StartCoil + u16currentCoil;
    u8currentRegister = (uint8_t) (u16coil / 16);
    u8currentBit = (uint8_t) (u16coil % 16);

    bTemp = bitRead(
    au8Buffer[ u8frameByte ],
    u8bitsno );

    bitWrite(
    regs[ u8currentRegister ],
    u8currentBit,
    bTemp );

    u8bitsno ++;

    if (u8bitsno > 7) {
      u8bitsno = 0;
      u8frameByte++;
    }
  }

  // send outcoming message
  // it's just a copy of the incomping frame until 6th byte
  u8BufferSize         = 6;

  sendTxBuffer();
  return u8BufferSize;
}

/**
 * This method processes function 16
 * This method writes a word array assigned by the master
 *
 * @return u8BufferSize Response to master length
 * @ingroup register
 */
int8_t Modbus::process_FC16( uint16_t *regs, uint8_t u8size ) {
  uint8_t u8func = au8Buffer[ FUNC ];  // get the original FUNC code
  uint8_t u8StartAdd = au8Buffer[ ADD_HI ] << 8 | au8Buffer[ ADD_LO ];
  uint8_t u8regsno = au8Buffer[ NB_HI ] << 8 | au8Buffer[ NB_LO ];
  uint8_t i;
  uint16_t temp;

  // build header
  au8Buffer[ NB_HI ]   = 0;
  au8Buffer[ NB_LO ]   = u8regsno;
  u8BufferSize         = RESPONSE_SIZE;

  // write registers
  for (i = 0; i < u8regsno; i++) {
    temp = word(
    au8Buffer[ (BYTE_CNT + 1) + i*2 ],
    au8Buffer[ (BYTE_CNT + 2) + i*2 ]);

    regs[ u8StartAdd + i ] = temp;
  }
  sendTxBuffer();
  return u8BufferSize;
}

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


Regado automático cada 24 horas

Regado automático cada 24 horas

Primera prueba con código arduino para regado automático cada 24 horas.

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/oranz/AgroRanz.git/'


First tries to read from i2c device

First tries to read from i2c device

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/tomwagner1999/SmartHome.git/'


arduino code pushed

arduino code pushed

// DH11 tempreture and Humidity sensor
#include <dht.h> // dht.t library

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// I2C Display for I2C bus and LCD Display
#include <LiquidCrystal_I2C.h>

#define dht_apin A0 // Analog Pin sensor is connected to

// import for Power Line
char blueToothVal ;           //value sent over via bluetooth
char lastValue = 48;

// Water Level Sensor
const int sensorPin= 1; //sensor pin connected to analog pin A0
int liquid_level;

int sensorLDR = A2; // select the input pin for ldr
int sensorValue = 0; // variable to store the value coming from the sensor

dht DHT;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup(){

  Serial.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(sensorPin, INPUT);//the liquid level sensor will be an input to the arduino
  delay(6000);//Delay to let system boot

  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on

}//end "setup()"

void loop(){

//LDR Sensor

sensorValue = analogRead(sensorLDR); // read the value from the sensor

Serial.println(sensorValue); //prints the values coming from the sensor on the screen

// water level sensor
  liquid_level= analogRead(sensorPin); //arduino reads the value from the liquid level sensor

  Serial.println(liquid_level);//prints out liquid level sensor reading

  lcd.setCursor(0,1); //Start at character 4 on line 0
  lcd.print("Water :");
  lcd.print((float)liquid_level, 0);

// Water level sensor end

    //Start of Program

    DHT.read11(dht_apin);

    Serial.println(DHT.humidity);

    Serial.println(DHT.temperature);

    lcd.setCursor(0,0); //Start at character 4 on line 0
    lcd.print("Temperaure :");
    lcd.print((float)DHT.temperature, 0);

  //Fastest should be once every two seconds.

Serial.println (lastValue);
    blueToothVal=Serial.read(); //read it

  if (blueToothVal=='n')
  {//if value from bluetooth serial is n
    digitalWrite(13,HIGH);            //switch on LED
    if (lastValue!='n')
      Serial.println(lastValue); //print LED is on
    lastValue=blueToothVal;
  }
  else if (blueToothVal=='f')
  {//if value from bluetooth serial is n
    digitalWrite(13,LOW);             //turn off LED
    if (lastValue!='f')
      Serial.println(lastValue); //print LED is on
    lastValue=blueToothVal;
  }

delay(3000);//Wait 5 seconds before accessing sensor again.

}// end loop()

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


added esp8266 scktch code

added esp8266 scktch code

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


Added todo comment about how to fix the bug.


firmware added

firmware added

#include <RFduinoBLE.h>

#define CHILD_ID_AIQ 0
#define AIQ_SENSOR_ANALOG_PIN 0

#define MQ135_DEFAULTPPM 399 //default ppm of CO2 for calibration
#define MQ135_DEFAULTRO 68550 //default Ro for MQ135_DEFAULTPPM ppm of CO2
#define MQ135_SCALINGFACTOR 116.6020682 //CO2 gas value
#define MQ135_EXPONENT -2.769034857 //CO2 gas value
#define MQ135_MAXRSRO 2.428 //for CO2
#define MQ135_MINRSRO 0.358 //for CO2

unsigned long SLEEP_TIME = 3000; // Sleep time between reads (in seconds)
//VARIABLES
//float Ro = 10000.0;    // this has to be tuned 10K Ohm
float mq135_ro = 10000.0;    // this has to be tuned 10K Ohm
int val = 0;           // variable to store the value coming from the sensor
float valAIQ =0.0;
float lastAIQ =0.0;
//
int sensor = 2;

void setup() {
  //Pin mode to input for reading sensor MQ 135 data
  pinMode(sensor, INPUT_PULLUP);
  // initialize serial:
  Serial.begin(9600);
  RFduinoBLE.advertisementData = "FreshFreedom";
  Serial.println("**Starting FreshFreedom**");
  // start the BLE stack
  RFduinoBLE.begin();
}

/*
 * get the calibrated ro based upon read resistance, and a know ppm
 */
long mq135_getro(long resvalue, double ppm) {
return (long)(resvalue * exp( log(MQ135_SCALINGFACTOR/ppm) / MQ135_EXPONENT ));
}

/*
 * get the ppm concentration
 */
double mq135_getppm(long resvalue, long ro) {
double ret = 0;
double validinterval = 0;
validinterval = resvalue/(double)ro;
if(validinterval<MQ135_MAXRSRO && validinterval>MQ135_MINRSRO) {
ret = (double)MQ135_SCALINGFACTOR * pow( ((double)resvalue/ro), MQ135_EXPONENT);
}
return ret;
}
void loop() {

  uint16_t sensorValue = analogRead(sensor);
  Serial.print("sensorValue:");
  Serial.println(sensorValue);
  uint16_t val =  ((float)47000*(1023-sensorValue)/sensorValue);
  Serial.print("value:");
  Serial.println(val);
  mq135_ro = mq135_getro(val, MQ135_DEFAULTPPM);
  Serial.print("getro:");
  Serial.println(mq135_ro);
  //convert to ppm (using default ro)
  valAIQ = mq135_getppm(val, MQ135_DEFAULTRO);
  // send the sample to the Android
  Serial.print("getppm:");
  Serial.println(valAIQ);
  if (valAIQ != lastAIQ) {
      lastAIQ = ceil(valAIQ);
      if(lastAIQ!=0.0){
        RFduinoBLE.sendInt(lastAIQ);
      }
      Serial.print("valAIQ:");
      Serial.println(lastAIQ);
  }

  delay(SLEEP_TIME);
}

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


Fixing file reading bug.

Fixing file reading bug.


Added HelloBlinky example.

Added HelloBlinky example.

#include <FastSPI_LED2.h>
#include <Animation.h>

#define LED_COUNT 60
struct CRGB leds[LED_COUNT];

#define PIN_BUTTON 10
#define PIN_IO_A   7
#define PIN_IO_B   11
#define PIN_SIGNAL 13
#define PIN_INPUT  10

void setup()
{
  LEDS.addLeds<WS2811, PIN_SIGNAL, GRB>(leds, LED_COUNT);
  LEDS.showColor(CRGB(0, 0, 0));
  LEDS.setBrightness(0); // start out with LEDs off
  LEDS.show();
}

void setcolor(int colorcode) {

  for (int i = 0; i < LED_COUNT; i++) {
    switch(colorcode) {
      case 0: leds[i].r = 128; break;

      case 1: leds[i].g = 128; break;

      case 2: leds[i].b = 128; break;
    }
  }
  LEDS.show();
}

void pulse(int wait_time) {
  // let's fade up by scaling the brightness
  for(int scale = 0; scale < 128; scale++) {
    LEDS.setBrightness(scale);
    LEDS.show();
    delay(wait_time);
  }
  // now let's fade down by scaling the brightness
  for(int scale = 128; scale > 0; scale--) {
    LEDS.setBrightness(scale);
    LEDS.show();
    delay(10);
  }
}

void loop() {
  int color_set = 2; // 0 for red, 1 for green, 2 for blue
  int waiting_time = 40; //time in ms for color scaling

  setcolor(color_set);

  pulse(waiting_time);
}

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


water level infromation in tank using ultrasonic sensors.

#include <NewPing.h>

#define TRIGGER_PIN  12
#define ECHO_PIN     13
#define MAX_DISTANCE 300

float distance;
float tH=86; // Total Height of Tank in cm.
float radius=10;
float sqr_R=sq(radius); // Square Radius of Tank 10cm*10cm;
float litre=1000; //1 litre 1000 ml;
float volume;
float f; // fill height
float Pi=3.14;

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(1000);
  int uS = sonar.ping_median(15); // median filter, error correction
   distance=(uS / US_ROUNDTRIP_CM); // calculate distance
   f=(tH-distance); //  calculate fill height of tank
   volume=(Pi*sqr_R*f/1000); // calculate volume of liquid
  Serial.println(volume);

 }

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


Add temp sensor example sketch

Add temp sensor example sketch

// TimerOne library: https://code.google.com/p/arduino-timerone/
#include <TimerOne.h>
#include <SPI.h>
#include <BLEPeripheral.h>

// define pins (varies per shield/board)
#define BLE_REQ   10
#define BLE_RDY   2
#define BLE_RST   9

BLEPeripheral blePeripheral = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST);

BLEService tempService = BLEService("CCC0");

BLEIntCharacteristic tempCharacteristic = BLEIntCharacteristic("CCC1", BLERead | BLENotify);
BLEDescriptor tempDescriptor = BLEDescriptor("2901", "Celsius");

volatile bool readTemperature = false;

void setup() {
  Serial.begin(115200);
#if defined (__AVR_ATmega32U4__)
  //Wait until the serial port is available (useful only for the Leonardo)
  //As the Leonardo board is not reseted every time you open the Serial Monitor
  while(!Serial) {}
  delay(5000);  //5 seconds delay for enabling to see the start up comments on the serial board
#endif

  blePeripheral.setLocalName("Temperature");
  blePeripheral.setAdvertisedServiceUuid(tempService.uuid());
  blePeripheral.addAttribute(tempService);
  blePeripheral.addAttribute(tempCharacteristic);
  blePeripheral.addAttribute(tempDescriptor);

  blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
  blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);

  blePeripheral.begin();

  Timer1.initialize(1 * 1000000); // in milliseconds
  Timer1.attachInterrupt(timerHandler);
}

void loop() {
  blePeripheral.poll();

  if (readTemperature) {
    setTempCharacteristicValue();
    readTemperature = false;
  }
}

void timerHandler() {
  readTemperature = true;
}

void setTempCharacteristicValue() {
  int temp = readTempC();
  tempCharacteristic.setValue(temp);
  Serial.println(temp);
}

int readTempC() {
  // Stubbing out for demo with random value generator
  // Replace with actual sensor reading code
  return random(100);
}

void blePeripheralConnectHandler(BLECentral& central) {
  Serial.print(F("Connected event, central: "));
  Serial.println(central.address());
}

void blePeripheralDisconnectHandler(BLECentral& central) {
  Serial.print(F("Disconnected event, central: "));
  Serial.println(central.address());
}

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


Added example: RemoteServoControl

Added example: RemoteServoControl

/*
  RemoteServoControl by Meeo

  This example will make use of Meeo. If you haven't already,
  visit Meeo at https://meeo.io and create an account. Then
  check how to get started with the Meeo library through
  https://github.com/meeo/meeo-arduino

  Remotely control a servo motor
  More details of the project here: https://meeo.io/l/1001

  Copyright: Meeo
  Author: Terence Anton Dela Fuente
  License: MIT
*/
#include <Meeo.h>
#include <Servo.h>

#define SERVO_PIN D1
#define MAX_ANGLE 180
#define MIN_ANGLE 0

String nameSpace = "my_namespace";
String accessKey = "my_access_key";
String ssid = "MyWiFi";
String pass = "qwerty123";
String channel = "servo-sweep";

Servo servo;

void setup() {
  Serial.begin(115200);

  servo.attach(SERVO_PIN);
  servo.write(MIN_ANGLE);// Set to starting position

  Meeo.setEventHandler(meeoEventHandler);
  Meeo.setDataReceivedHandler(meeoDataHandler);
  Meeo.begin(nameSpace, accessKey, ssid, pass);

}

void loop() {
  Meeo.run();
}

void meeoDataHandler(String topic, String payload) {
  Serial.print(topic);
  Serial.print(": ");
  Serial.println(payload);

  if (Meeo.isChannelMatched(topic, channel)) {
    servo.write(map(payload.toInt(),0,100, MIN_ANGLE, MAX_ANGLE));
  }
}

void meeoEventHandler(MeeoEventType event) {
  switch (event) {
    case WIFI_DISCONNECTED:
      Serial.println("Not Connected to WiFi");
      break;
    case WIFI_CONNECTING:
      Serial.println("Connecting to WiFi");
      break;
    case WIFI_CONNECTED:
      Serial.println("Connected to WiFi");
      break;
    case MQ_DISCONNECTED:
      Serial.println("Not Connected to MQTT Server");
      break;
    case MQ_CONNECTED:
      Serial.println("Connected to MQTT Server");
      // Once connected, subscribe to the channel
      Meeo.subscribe(channel);
      break;
    case MQ_BAD_CREDENTIALS:
      Serial.println("Bad Credentials");
      break;
    case AP_MODE:
      Serial.println("AP Mode");
      break;
    default:
      break;
  }
}

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


Adds readerKWP example.

Adds readerKWP example.

#include "Arduino.h"
#include "OBD9141.h"

#define RX_PIN 0
#define TX_PIN 1
#define EN_PIN 2

OBD9141 obd;

void setup(){
    Serial.begin(9600);
    delay(2000);

    pinMode(EN_PIN, OUTPUT);
    digitalWrite(EN_PIN, HIGH);

    obd.begin(Serial1, RX_PIN, TX_PIN);

}

void loop(){
    Serial.println("Looping");

    // only change from reader is the init method here.
    bool init_success =  obd.initKWP();
    Serial.print("init_success:");
    Serial.println(init_success);

    //init_success = true;
    // Uncomment this line if you use the simulator to force the init to be
    // interpreted as successful. With an actual ECU; be sure that the init is
    // succesful before trying to request PID's.

    if (init_success){
        bool res;
        while(1){
            res = obd.getCurrentPID(0x11, 1);
            if (res){
                Serial.print("Result 0x11 (throttle): ");
                Serial.println(obd.readUint8());
            }

            res = obd.getCurrentPID(0x0C, 2);
            if (res){
                Serial.print("Result 0x0C (RPM): ");
                Serial.println(obd.readUint16()/4);
            }

            res = obd.getCurrentPID(0x0D, 1);
            if (res){
                Serial.print("Result 0x0D (speed): ");
                Serial.println(obd.readUint8());
            }
            Serial.println();

            delay(200);
        }
    }
    delay(3000);
}

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


Added uController skeleton, taking a break

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

}

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

}

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


Create Beacon.ino

Create Beacon.ino

#include "captouch.h"
#include "FastLED.h"

#define RING_PIN    3
#define RING_LEDS    64
CRGB ringLeds[RING_LEDS];

#define STRIP_PIN    3
#define STRIP_LEDS    64
CRGB stripLeds[STRIP_LEDS];

CRGB red = CHSV( 0, 0, 0);
CRGB green  = CHSV( 85, 0, 0);
CRGB blue  = CHSV( 150, 0, 0);
CRGB beaconColor = CHSV( 0, 0, 0);

uint8_t  colors = 3;
uint32_t currentPalette =  [red,  green,  blue];

CapTouch::Event touchEvent;

uint8_t brightness = 254; //Global brightness assignment

void setup() {
	delay(3000); // 3 second delay for recovery
	Particle.subscribe("LampUpdate", gotColorUpdate, MY_DEVICES);
	Touch.setup();
  	FastLED.addLeds<NEOPIXEL, RING_PIN>(ringLeds, RING_LEDS);
	FastLED.addLeds<NEOPIXEL, STRIP_PIN>(stripLeds, STRIP_LEDS);

  	// set master brightness control
  	FastLED.setBrightness(brightness);
}

void loop()
{
	touchEvent = Touch.getEvent();
  	if (touchEvent == CapTouch::TouchEvent) {
		whileTouching();
	}
	update();
	FastLED.show();
}

void gotColorUpdate(const char *name, const char *data) {

	String str = String(data);
    char strBuffer[40] = "";
    str.toCharArray(strBuffer, 40);
    colorFromID = strtok(strBuffer, "~");
    colorRecieved = atof(strtok(NULL, "~"));

    // DEBUG
    String sColorRecieved = String(colorRecieved);
    Particle.publish("Color_Recieved", System.deviceID() + "~" + sColorRecieved);
}

void whileTouching() {
	uint8_t colorIndex = 0;
	uint8_t satBright = 0;
	CRGB color = red;

    while (touchEvent != CapTouch::ReleaseEvent) {
		satBright += 5;
		color.saturation = satBright;
		color.brightness = satBright;
		if(satBright >= 255){
			satBright = 0;
			colorIndex +=1;
			color = currentPalette[colorIndex % colors];
		}
	}
	uint8_t pixelsLit = map(satBright,0,255,0,STRIP_LEDS+1);
	for int(i = 0; i == pixelsLit || i == STRIP_LEDS;i++){
		stripLeds[i] = color;
	}
	if(pixelsLit > STRIP_LEDS){
		fill_solid(&ringLeds, RING_LEDS, color); //at max capacity, light up the whole beacon
	}
	fastLED.show();
	beaconColor = color;
	String sColor = String(beaconColor);
	Particle.publish("colorUpdate", System.deviceID() + "~" + sColor, 60, PRIVATE);
}

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


Testing ESP module with acm-web

Testing ESP module with acm-web

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


Adaptive internal lighting rev2

Adaptive internal lighting rev2

Added interrupt and override functions

/*
Adaptive Lighting System
======== ======== ======
rev v.1
#test program for adaptive lighting
#controls the brightness of an led according to the amount of light present
#connects the sensor at pin A0 and the LED at pin 9
#the input is read and the voltage value is send serially
#the prograam varies it's PWM according to the input voltage
*/

//al-adaptive lighting

#define alinput A0
#define aloutput 9
#define alinterrupt A1
#define aloverride A2

float alsensor,alvoltage;
int albrightness;

void setup()
{
  Serial.begin(9600);
  pinMode(alinterrupt,INPUT);
  pinMode(aloverride,INPUT);
}

void loop()
{ alsensor = analogRead(alinput); //read the sensor value
  albrightness = alsensor / 4; //convert the value from 10-bit resolution to 8-bit res
  alvoltage = alsensor * (5.0 / 1024.0); //convert the value into actual voltage range 0-5V
  Serial.print("The voltage is: ");  //prints the voltage through serial
  Serial.println(alvoltage);
  analogWrite(aloutput,albrightness); //output the PWM to the LED
  while(digitalRead(alinterrupt)) //interrupt function
  { if(digitalRead(aloverride)) //override - ON
     analogWrite(aloutput,255);
    else //override - OFF
     analogWrite(aloutput,0);
  }
  delay(500);
}

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


Small bugfix... again

Small bugfix... again

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/EmanueleGiacomini/icaro-robotics.git/'


First draft

First draft

/*

  Hall-efect sensor based rev counter

  Goals:
    - Use hall-efect sensor
    - detect input changes using interrupts
    - count changes per second ( RPS - revolutions per second )
    - scale up RPS to RPM ( revolutions per minute ) or RPH ( revolutions per hour )
    - do math to derive MPH ( miles per hour ) based on wheel diameter and RPH

  Options:
    - use more than one magnet to provide more accurate readings. this imporves low RPM readings.

*/

int sensor = 0;
int revs = 0;

// Arduino UNO support interrupts only on selected pins
// see: http://arduino.cc/en/Reference/attachInterrupt
#define INT0 0
#define INT1 1
#define INT0_PIN 2
#define INT1_PIN 3

void setup() {

  Serial.begin(9600); // DEBUG
  attachInterrupt(INT0, incRevs, FALLING);

}

void incRevs() {

  int sensorValue = analogRead(INT0_PIN);
  float voltage = sensorValue * (5.0 / 1023.0);

  /*
    Sensor keeps voltage on the edge between LOW and HIGH, this couses erratic readings.
    Folowing is used to reduce the problem:
    Count only if voltage drops below major threshold
  */
  if (voltage < 2.0) {
    revsCounter++;
  }
}

void loop() {

  // disable interrupts and
  // save the revs value.
  // Then reset the counter
  noInterrupts();
  float r = revsCounter;
  revsCounter = 0;
  interrupts();

  // Do the math...
  float rps = r / 1.0;
  float rpm = rps * 60;
  float rph = rpm * 60;

  float diameter = 0.000268308; // 17 inches in miles
  float c = 2 * PI * diameter;
  float mph = rph * c;
  Serial.println(mph);

  delay(1000);

}

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


Adding new DT_CheckerOuter via file upload

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/DavidTangye/sketchbook.git/'


Added Fishduino_Clock sample program to Fishduino library

Instead of starting a separate project as I implied in the previous commit, I added Fishduino_Clock to the Fishduino project as a sample. This is not complete yet, it simply forwards the minute hand once a minute.
There is some unused data in this, which will be used later.
There's also a minor problem with the current code: every once in a while the motor stops too soon because when the switch turns from off->on sometimes there is some bouncing and every once in a while the bouncing is detected as the switch going on, then off again.

/****************************************************************************
Copyright (c) 2015, Jac Goudsmit
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.

* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

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.
****************************************************************************/

/*
  This project runs the FischerTechnik clock
*/

/////////////////////////////////////////////////////////////////////////////
// INCLUDES
/////////////////////////////////////////////////////////////////////////////

#include <FishduinoMotor.h>
#include <FishduinoInPin.h>

/////////////////////////////////////////////////////////////////////////////
// TYPES
/////////////////////////////////////////////////////////////////////////////

// FischerTechnik Clock hardware
FishduinoMgr        fishduino;
FishduinoMotor      motor_min( fishduino, 0, FishduinoMotor::M1);
FishduinoMotor      motor_adj( fishduino, 0, FishduinoMotor::M2);
FishduinoInPin      sensor_m(  fishduino, 0, FishduinoInPin::I1); // Cycles once/minute
FishduinoInPin      sensor_h(  fishduino, 0, FishduinoInPin::I2); // Cycles once/hour
FishduinoInPin      sensor_h12(fishduino, 0, FishduinoInPin::I3); // Cycles once/12 hours

// Actual time (that we're supposed to display)
byte                actual_hour;        // Hours mod 12 (i.e. 0..11)
byte                actual_min;         // Minutes

// Current time on the clock
byte                clock_hour = 255;   // Hours mod 12; unknown=255
byte                clock_min  = 255;   // Minutes; unknown=255

/////////////////////////////////////////////////////////////////////////////
// CODE
/////////////////////////////////////////////////////////////////////////////

void setup()
{
  Serial.begin(115200);
  Serial.println("Hello!");
}

void loop()
{
  fishduino.Update();

  // If the minute sensor turned off, turn the minute motor off
  if (sensor_m.WasOn() && sensor_m.IsOff())
  {
    motor_min.Stop();
  }

  static unsigned long m = millis() - 60001;
  unsigned long c = millis();

  if (c - m > 60000)
  {
    motor_min.Clockwise();

    m = c;
  }
}

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


Added in Andy and Hayden's motor control code.

int MotorA = 3;
int MotorB = 5;
int val = 0;
char motorSelectA = 0;
char motorSelectB = 0;

void setup(){
pinMode(MotorA,OUTPUT);
pinMode(MotorB,OUTPUT);
Serial.begin(9600);
}

void loop(){
  if( Serial.available() >= 4 ) {
    char prefix = Serial.read();
    motorSelectA = (prefix == 'a');
    motorSelectB = (prefix == 'b');

    char dec;
    val = 0;
    for (int i=100; i>=1; i/=10) {
      dec = Serial.read() - '0';
      val += dec * i;
    }

    Serial.write("Got ");Serial.println(val,DEC);
    Serial.flush(); // get rid of excess
  }

  if (motorSelectA) analogWrite(MotorA,val);
  if (motorSelectB) analogWrite(MotorB,val);
  motorSelectA = motorSelectB = 0;
}

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


a steam controller with 30V - 5V relay enabled with dht11 and Arduino

#include <dht.h>

dht DHT;

#define DHT11_PIN 6
int ledPin = 2;

void setup()
{
  Serial.begin(9600);

  pinMode(ledPin, OUTPUT);
}

void loop()
{
  delay(2000);
  int chk = DHT.read11(DHT11_PIN);

  switch (chk)
  {
    case DHTLIB_OK:
      Serial.println("-----------------------------------------");
      Serial.print("Humidity : %");
      Serial.println(DHT.humidity);
      Serial.print("Temp : ");
      Serial.print(DHT.temperature);
      Serial.println("C");
      arrangeHumidity();
      break;
    case DHTLIB_ERROR_CHECKSUM:
      Serial.println("Checksum error");
      break;
    case DHTLIB_ERROR_TIMEOUT:
      Serial.println("Time out error");
      break;
    default:
      Serial.println("Unknown error");
      break;
  }
}

void arrangeHumidity() {
  if (DHT.humidity < 56) {
    Serial.println("Humidity is below %56");
    digitalWrite(ledPin, LOW);
  } else if (DHT.humidity > 56) {
    Serial.println("Humidity is above %56");
    digitalWrite(ledPin, HIGH);
  }
}


trying an ultra-lightweight thread library with the processor

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/nicksutera/railroad.git/'


commit test

commit test

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/davidtjones/quad-gy80.git/'


Added Speaker Example

Added Speaker Example

/*
   Code to detect pulses from the PulseSensor,
   using an interrupt service routine.

   >>>>  THIS EXAMPLE OUTPUTS USES TONE COMMAND <<<<
   >>>>  TO MAKE A SPEAKER BEEP WITH HEARTBEAT! <<<<

   See https://www.pulsesensor.com

   Copyright World Famous Electronics LLC - see LICENSE
   Contributors:
     Joel Murphy, https://pulsesensor.com
     Yury Gitman, https://pulsesensor.com
     Bradford Needham, @bneedhamia, https://bluepapertech.com

   Licensed under the MIT License, a copy of which
   should have been included with this software.

   This software is not intended for medical use.
*/

/*
   Every Sketch that uses the PulseSensor Playground must
   define USE_ARDUINO_INTERRUPTS before including PulseSensorPlayground.h.
   Here, #define USE_ARDUINO_INTERRUPTS true tells the library to use
   interrupts to automatically read and process PulseSensor data.

   See ProcessEverySample.ino for an example of not using interrupts.
*/
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>

/*
   The format of our output.

   Set this to PROCESSING_VISUALIZER if you're going to run
    the Processing Visualizer Sketch.
    See https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer

   Set this to SERIAL_PLOTTER if you're going to run
    the Arduino IDE's Serial Plotter.
*/
const int OUTPUT_TYPE = PROCESSING_VISUALIZER;

/*
   Pinout:
     PIN_INPUT = Analog Input. Connected to the pulse sensor
      purple (signal) wire.
     PIN_BLINK = digital Output. Connected to an LED (and 220 ohm resistor)
      that will flash on each detected pulse.
     PIN_FADE = digital Output. PWM pin onnected to an LED (and resistor)
      that will smoothly fade with each pulse.
      NOTE: PIN_FADE must be a pin that supports PWM. Do not use
      pin 9 or 10, because those pins' PWM interferes with the sample timer.
*/
const int PIN_INPUT = A0;
const int PIN_BLINK = 13;    // Pin 13 is the on-board LED
const int PIN_FADE = 5;

/*
   All the PulseSensor Playground functions.
*/
PulseSensorPlayground pulseSensor;

/*
  Setup the things we need for driving the Speaker
  NOTE: Speaker MUST be AC coupled! Connect PIN_SPEAKER to red speaker wire.
        Then connect black speaker wire to + side of electrolytic capacitor.
        Then connect - side of electrolytic capacitor to GND.
        Capacitor value should be 1uF or higher!
        Follow this tutorial:
        [link]
*/
const int PIN_SPEAKER = 2;    // speaker on pin2 makes a beep with heartbeat

void setup() {
  /*
     Use 115200 baud because that's what the Processing Sketch expects to read,
     and because that speed provides about 11 bytes per millisecond.

     If we used a slower baud rate, we'd likely write bytes faster than
     they can be transmitted, which would mess up the timing
     of readSensor() calls, which would make the pulse measurement
     not work properly.
  */
  Serial.begin(115200);

  // Configure the PulseSensor manager.

  pulseSensor.analogInput(PIN_INPUT);
  pulseSensor.blinkOnPulse(PIN_BLINK);
  pulseSensor.fadeOnPulse(PIN_FADE);

  pulseSensor.setSerial(Serial);
  pulseSensor.setOutputType(OUTPUT_TYPE);

  // Now that everything is ready, start reading the PulseSensor signal.
  if (!pulseSensor.begin()) {
    /*
       PulseSensor initialization failed,
       likely because our particular Arduino platform interrupts
       aren't supported yet.

       If your Sketch hangs here, try ProcessEverySample.ino,
       which doesn't use interrupts.
    */
    for(;;) {
      // Flash the led to show things didn't work.
      digitalWrite(PIN_BLINK, LOW);
      delay(50);
      digitalWrite(PIN_BLINK, HIGH);
      delay(50);
    }
  }
}

void loop() {
  /*
     Wait a bit.
     We don't output every sample, because our baud rate
     won't support that much I/O.
  */
  delay(20);

  // write the latest sample to Serial.
  pulseSensor.outputSample();

  /*
     If a beat has happened since we last checked,
     write the per-beat information to Serial.
     write a frequency to the PIN_SPEAKER
     NOTE: Do not set the optional duration of tone! That is blocking!
   */
  if (pulseSensor.sawStartOfBeat()) {
    pulseSensor.outputBeat();
    tone(PIN_SPEAKER,1047);              // tone(pin,frequency)
  }

  /*
    The Pulse variable is true only for a short time after heartbeat detected
    Use this to time the duration of the beep
  */
  if(pulseSensor.Pulse = false){
    noTone(PIN_SPEAKER);
  }

}

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


Sketch stub

Sketch stub

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/projectfaar/smart-cart.git/'


Bluetooth AT

Bluetooth AT

/* Program to test AT commands on HC-05 module:
   - Sets "Key" pin on HC-05 HIGH to enable command mode
   - The HC-05 LED Blink SLOWLY: 2 seconds ON/OFF
   Connections:  GND to HC-05 GND, Pin 2 to HC-05 TXD,
   Pin 3 to HC-05 RXD, Pin 4 to HC-05 KEY,
   Pin 5V to HC-05 VCC for power control
*/
/* Copyright (C) <2016>  <Chaitanya Baweja> <http://www.gnu.org/licenses/>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
*/

#include <SoftwareSerial.h>
#define ARDUINO_RXD 2
#define ARDUINO_TXD 3
#define KEY        4

SoftwareSerial BTSerial(ARDUINO_RXD, ARDUINO_TXD); // RX | TX

void setup()
{
  pinMode(KEY, OUTPUT);  // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
  digitalWrite(KEY, HIGH);  // Set command mode when powering up
  pinMode(5,OUTPUT);
  Serial.begin(9600);
  delay(2000);
  digitalWrite(5,HIGH);
  Serial.println("Enter AT commands: ");
  BTSerial.begin(38400);  // HC-05 default speed in AT command mode

}

void loop()
{
  // READ from HC-05 and WRITE to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // READ Arduino Serial Monitor and WRITE to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());

}

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


Add KeyboardSerial

Add KeyboardSerial

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/tommykw/TV.git/'


Create Test.ino

Create Test.ino

int x=0;
void setup()
{
  Serial.begin(9600);
}

void loop()
{
    Serial.println(x++);
    delay(10);
}

//we can recover the date later with `date -r unixtime` e.g. `date -r 1390045244`

error: pathspec 'Bash-One-Liner/Test.ino' did not match any file(s) known to git


Create remapping_fix_example.ino

Create remapping_fix_example.ino

//***************************************************************
// Remapping to fix a wacky layout.
// This also will then also allow the use of CRGBSet.
// Marc Miller, Jan 2017
//***************************************************************
//
// Have this layout:       Want to operate on this layout:
//     2  3  4                3  4  5
//   1         5            2         6
//   0         6            1         7
//  11         7            0         8
//    10  9  8               11 10  9
//
//    14 15 16               15 16 17
//  13        17           14        18
//  12        18           13        19
//  23        19           12        20
//    22 21 20               23 22 21
//
//  etc..
//
//
//***************************************************************

#include "FastLED.h"
#define DATA_PIN    11
#define CLK_PIN     13
#define LED_TYPE    LPD8806
#define COLOR_ORDER GRB
#define BRIGHTNESS  255

#define NumberOfDiamonds 3  //3
#define PixelsPerDiamond 12  //12
#define NUM_LEDS (NumberOfDiamonds * PixelsPerDiamond)

/* CRGB leds[NUM_LEDS];  ***Not using this.  Using CRGBArray instead.****/
CRGBArray<NUM_LEDS> leds;    // Operate on this array as if it had the correct layout.
CRGBArray<NUM_LEDS> actual;  // Display this array after mapping "leds" to "actual".

//Since we'll opperate on our nicely arranged "leds" array, we can make a CRGBSet for each diamond.
CRGBSet d0(  leds(PixelsPerDiamond*0,  PixelsPerDiamond-1+(PixelsPerDiamond*0)  ));  //Define pixel range for diamond 0.
CRGBSet d1(  leds(PixelsPerDiamond*1,  PixelsPerDiamond-1+(PixelsPerDiamond*1)  ));  //Define pixel range for diamond 1.
CRGBSet d2(  leds(PixelsPerDiamond*2,  PixelsPerDiamond-1+(PixelsPerDiamond*2)  ));  //Define pixel range for diamond 2.
//etc..

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  delay(3000); // 3 second delay for recovery

  //***NOTE: Putting the CRGBArray "actual" in here, not "leds"***
  FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(actual, NUM_LEDS);

  FastLED.setBrightness(BRIGHTNESS);
}

//---------------------------------------------------------------
void loop() {

  EVERY_N_SECONDS(3){
    static uint8_t hue;
    for (uint8_t n=0; n < NumberOfDiamonds; n++){
      fill_rainbow( &(leds[ (n*PixelsPerDiamond) ]), PixelsPerDiamond, hue+millis(), 8 );
    }
  }

  EVERY_N_SECONDS(12){
    random16_add_entropy( random() );
    uint8_t randomColor = random8();  //pick a random color
    d0 = CHSV(randomColor,170,150);
    d1 = CHSV(randomColor+64,170,150);
    d2 = CHSV(randomColor-64,170,150);
  }

  remap();  //***Always run the remap function just before calling show().***
  FastLED.show();

}//end_main_loop

//---------------------------------------------------------------
// Function to remap "leds" array to "actual" array
void remap() {
  uint8_t mapped;
  uint8_t diamondNumber;
  for (uint8_t i=0; i < NUM_LEDS; i++) {
    if (i % PixelsPerDiamond == 0) {
      diamondNumber = i / PixelsPerDiamond;
      mapped = (diamondNumber * PixelsPerDiamond) + 11;
      actual[i] = leds[mapped];
      //Serial.print("Diamond#: "); Serial.println(diamondNumber);
    } else {
      mapped = i-1;
      actual[i] = leds[mapped];
    }
    //Serial.print("  For leds[i] = "); Serial.print(i); Serial.print("  actual[i] = "); Serial.println(mapped);
  }
}

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


drobne czyszczenie

drobne czyszczenie

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


done?

done?

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/Au1st3in/fall2015-e121-arduino-code.git/'


add om library

add om library

#include <RTOS.h>
#include <OpenManipulator.h>

osThreadId thread_id_loop;
osThreadId thread_id_led;

OMDynamixel<1,1000000> omDynamixel;

static void Thread_Loop(void const *argument)
{
  (void) argument;

  for(;;)
  {
    loop();
  }
}

void setup()
{
  Serial.begin(115200);

  omDynamixel.init();
  omDynamixel.setPositionControlMode(1);
  omDynamixel.setEnable(1);

  // define thread
  osThreadDef(THREAD_NAME_LOOP, Thread_Loop, osPriorityNormal, 0, 1024);
  osThreadDef(THREAD_NAME_LED,  Thread_Led,  osPriorityNormal, 0, 1024);

  // create thread
  thread_id_loop = osThreadCreate(osThread(THREAD_NAME_LOOP), NULL);
  thread_id_led  = osThreadCreate(osThread(THREAD_NAME_LED), NULL);

  // start kernel
  osKernelStart();
}

void loop()
{
  float* angle = omDynamixel.getAngle();
  Serial.print("angle : "); Serial.println(angle[0]);

  omDynamixel.setAngle(1, 1000);
  // static uint32_t cnt = 0;

  // Serial.print("RTOS Cnt : ");
  // Serial.println(cnt++);
  osDelay(100);
}

static void Thread_Led(void const *argument)
{
  (void) argument;

  // pinMode(13, OUTPUT);

  for(;;)
  {
    // digitalWrite(13, !digitalRead(13));
    // osDelay(300);

    // pose  = getPose()
    // state = getState()
  }
}

error: pathspec 'arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/OPM_for_Arduino/rtos_test/rtos_test.ino' did not match any file(s) known to git


add xml parse of twilight tags

add xml parse of twilight tags

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/cwilkens/helioscope-lamp.git/'


added wifi setup

added wifi setup

void setup() {
  // Serial is for communication between computer and board.
  // Serial1 is for communication between board and wifi module.
  Serial.begin(74880); // 74880
  Serial1.begin(115200);
  delay(1000);
  Serial1.print("AT+UART_CUR=74880,8,1,0,0\r\n");
  delay(2000);
  Serial1.begin(74880);
}

void loop() {
  if(Serial1.available() > 0){
    Serial.write(Serial1.read());
  }
  if(Serial.available() > 0){
    Serial1.write(Serial.read());
  }
}

// AT -> OK
// AT+CWMODE=1 -> OK
// AT+CWLAP -> find ssid
// AT+CWJAP="ssid","pwd"
// AT+CIFSR -> ensure valid IP

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


so it is acceleration settings …

so it is acceleration settings …

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


PWM for Claw changed

PWM for Claw changed

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


#1 Added ability to light three leds in a fixed delay.

int trafficLightCount = 3;

// Contains array of traffic led pins. Pin 0 - green, pin 1 - amber, pin 3 - red.
int trafficLights[] = { 0, 1, 2 };

// Pin for controlling traffic
int trafficController = 13;

// Light delay
int delayTime = 1000; //1sec

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

  // Make all traffic light pins output
  for (int thisTrafficLight = 0; thisTrafficLight < trafficLightCount; thisTrafficLight++) {
    pinMode(trafficLights[thisTrafficLight], OUTPUT);
  }

  // Input pins
  pinMode(trafficController, INPUT);
}

void loop() {
    // put your main code here, to run repeatedly:
    for (int thisTrafficLight = 0; thisTrafficLight < trafficLightCount; thisTrafficLight++) {
      digitalWrite(trafficLights[thisTrafficLight], HIGH);
      delay(delayTime);
      digitalWrite(trafficLights[thisTrafficLight], LOW);
      delay(delayTime);
    }
}

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


Working on trying to interface hardware timer

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


make it more like the environment sensor

fatal: remote error: upload-pack: not our ref bab9ba031a32c7881e9fda5773312ab9f6aa76b3
fatal: the remote end hung up unexpectedly


Testing a change for script to git pull from SPICE laptops

error: pathspec 'Sounds' did not match any file(s) known to git
error: pathspec 'and' did not match any file(s) known to git
error: pathspec 'Senses/scoreboard/scoreboard.ino' did not match any file(s) known to git


Asservissement: caractérisationVitesseMoteur => garde une vitesse constante

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'Moteur/Software/Asservissement/CaraterisationVitesseMoteur/CaraterisationVitesseMoteur/caraterisationVitesseMoteur.ino' did not match any file(s) known to git


Remove backlight control from badge.

Remove backlight control from badge.

Extend distance at which the panel lights.

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/JulianNicholls/Arduino.git/'


fix tryhard LAN

fix tryhard LAN

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/wiiproSK/arduino.git/'


set BPS to 57600 for 3dr radio serial speed

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/upperman/Wireless-Led-Display.git/'


Create template_custom_setup.ino

Create template_custom_setup.ino

Arduino template for custom sensor setup

#include <SPI.h>
#include <Ethernet.h>
/*
 * Zusätzliche Sensorbibliotheken, -Variablen etc im Folgenden einfügen.
 */

//SenseBox ID

//Sensor IDs

//Ethernet-Parameter
char server[] = "www.opensensemap.org";
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Diese IP Adresse nutzen falls DHCP nicht möglich
IPAddress myIP(192, 168, 0, 42);
EthernetClient client;

//Messparameter
int postInterval = 10000; //Uploadintervall in Millisekunden
long oldTime = 0;

void setup()
{
  Serial.begin(9600);
  Serial.print("Starting network...");
  //Ethernet Verbindung mit DHCP ausführen..
  if (Ethernet.begin(mac) == 0)
  {
    Serial.println("DHCP failed!");
    //Falls DHCP fehltschlägt, mit manueller IP versuchen
    Ethernet.begin(mac, myIP);
  }
  Serial.println("done!");
  delay(1000);
  Serial.println("Starting loop.");
}

void loop()
{
  //Upload der Daten mit konstanter Frequenz
  if (millis() - oldTime >= postInterval)
  {
    oldTime = millis();
    /*
     * Hier Sensoren auslesen und nacheinerander über postFloatValue(...) hochladen. Beispiel:
     *
     * float temperature = sensor.readTemperature();
     * postFloatValue(temperature, 1, temperatureSensorID);
     */
  }
}

void postFloatValue(float measurement, int digits, String sensorId)
{
  //Float zu String konvertieren
  char obs[10];
  dtostrf(measurement, 5, digits, obs);
  //Json erstellen
  String jsonValue = "{\"value\":";
  jsonValue += obs;
  jsonValue += "}";
  //Mit OSeM Server verbinden und POST Operation durchführen
  Serial.println("-------------------------------------");
  Serial.print("Connectingto OSeM Server...");
  if (client.connect(server, 8000))
  {
    Serial.println("connected!");
    Serial.println("-------------------------------------");
    //HTTP Header aufbauen
    client.print("POST /boxes/");client.print(SENSEBOX_ID);client.print("/");client.print(sensorId);client.println(" HTTP/1.1");
    client.println("Host: www.opensensemap.org");
    client.println("Content-Type: application/json");
    client.println("Connection: close");
    client.print("Content-Length: ");client.println(jsonValue.length());
    client.println();
    //Daten senden
    client.println(jsonValue);
  }else
  {
    Serial.println("failed!");
    Serial.println("-------------------------------------");
  }
  //Antwort von Server im seriellen Monitor anzeigen
  waitForServerResponse();
}

void waitForServerResponse()
{
  //Ankommende Bytes ausgeben
  boolean repeat = true;
  do{
    if (client.available())
    {
      char c = client.read();
      Serial.print(c);
    }
    //Verbindung beenden
    if (!client.connected())
    {
      Serial.println();
      Serial.println("--------------");
      Serial.println("Disconnecting.");
      Serial.println("--------------");
      client.stop();
      repeat = false;
    }
  }while (repeat);
}

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


Réctification test driver 02

Réctification test driver 02

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'moteur/Software/Asservissement/TestDriver/TestDriver_02/TestDriver_02.ino' did not match any file(s) known to git


M5StackFire microphone oscilloscope example added

/************************************************************************

  M5StackFire Discovery simple oscilloscope example

  The oscilloscope has a auto trigger function to achive a stable
  visual impression when a repeating signal like a sine wave is applied.

  original version
  STM32F429 Discovery June 2018, ChrisMicro
  this version reworked for
  M5StackFire         September 2018, ChrisMicro

************************************************************************/
#include <M5Stack.h>

#define M5STACKFIRE_MICROPHONE_PIN 34

#define HORIZONTAL_RESOLUTION 320
#define VERTICAL_RESOLUTION   240
#define POSITION_OFFSET_Y      30
#define SIGNAL_LENGTH HORIZONTAL_RESOLUTION

uint16_t oldSignal[SIGNAL_LENGTH];
uint16_t adcBuffer[SIGNAL_LENGTH];

#define SAMPLING_TIME_US           25
#define ANALOG_SIGNAL_INPUT        M5STACKFIRE_MICROPHONE_PIN

void setup()
{
  M5.Lcd.begin();
  M5.Lcd.fillScreen( BLACK );
  M5.Lcd.fillRect(10, 1, 150, 160, BLACK);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.setTextColor(GREEN);  //M5.Lcd.setTextSize(3);
  M5.Lcd.setTextSize(1);

  M5.Lcd.println("analog input MIC");
  M5.Lcd.print("sampling frequency: "); M5.Lcd.print(1000000 / SAMPLING_TIME_US); M5.Lcd.println(" Hz");
}

void waitForAutoTrigger()
{
  uint32_t triggerLevel = 512;
  uint32_t hysteresis   =  10;
  uint32_t timeOut_ms   = 100;

  uint32_t timeOutLimit = millis() + timeOut_ms;
  uint32_t timeOutFlag = false;

  uint32_t adcValue = 0;

  adcValue = analogRead( ANALOG_SIGNAL_INPUT );

  // wait for low level
  while ( ( adcValue > triggerLevel - hysteresis ) && !timeOutFlag )
  {
    adcValue = analogRead( ANALOG_SIGNAL_INPUT );

    if ( millis() > timeOutLimit ) timeOutFlag = 1 ;
  }

  if ( !timeOutFlag )
  {
    // wait for high level
    while ( ( adcValue < triggerLevel + hysteresis ) && ( millis() < timeOutLimit ) )
    {
      adcValue = analogRead(ANALOG_SIGNAL_INPUT);
    }
  }

}

void showSignal()
{
  int n;

  int oldx;
  int oldy;
  int y;

  for (n = 1; n < SIGNAL_LENGTH; n++)
  {
    y = VERTICAL_RESOLUTION - adcBuffer[n] * ( VERTICAL_RESOLUTION - POSITION_OFFSET_Y) / 4096 - POSITION_OFFSET_Y / 2  ;

    if (n == 1)
    {
      oldx = n;
      oldy = y;
    }

    if (n < SIGNAL_LENGTH - 1)
    {
      // delete old line element
      M5.Lcd.drawLine(n - 1 , oldSignal[n - 1], n, oldSignal[n], BLACK );

      // draw new line element
      M5.Lcd.drawLine(oldx,               oldy, n,            y, GREEN );
    }

    oldSignal[n - 1] = oldy;
    oldx = n;
    oldy = y;
  }
}

void loop(void)
{
  int n;
  uint32_t nextTime = 0;

  waitForAutoTrigger();

  // record signal
  for (n = 1; n < SIGNAL_LENGTH; n++)
  {
    adcBuffer[n] = analogRead( ANALOG_SIGNAL_INPUT );

    // wait for next sample
    while (micros() < nextTime);
    nextTime = micros() + SAMPLING_TIME_US;
  }

  showSignal();
}

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


Create robot.ino

Create robot.ino

int mAvant = 3;
int mArrier = 4;
int angle = 5;
int data = 0;

void setup(){
  Serial.begin(9600);
  analogWrite(angle);
  digitalWrite(mAvant, LOW);
  digitalWrite(mArrier, LOW);
}

void loop(){
  if (Serial.available() > 0) {
    data = Serial.read();
    switch(data){
      case 0:
        digitalWrite(mAvant, LOW);
        digitalWrite(mArrier, LOW);
        break;
      case 1:
        digitalWrite(mAvant, HIGH);
        digitalWrite(mArrier, LOW);
        break;
      case 2:
        digitalWrite(mAvant, LOW);
        digitalWrite(mArrier, HIGH);
        break;
      case 3:
        while(Serial.available() <= 0)
          delay(1);
        data = Serial.read();
        analogWrite(angle, data);
        break;
      default:break;
    }
    analogWrite(angle);
  }
}

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


Sound Buzzer Update

Sound Buzzer Update

error: pathspec 'Action' did not match any file(s) known to git
error: pathspec 'Modules/Piano' did not match any file(s) known to git
error: pathspec 'Synthesizer/PianoSynthesizerATtiny/PianoSynthesizerATtiny.ino' did not match any file(s) known to git


simple speaker dac sine added

simple speaker dac sine added

/*
  I2S sine wave
  This example produces a digital sine wave on the build in DAC1
  which is connected to the speaker

  Hardware:
   microcontroller board: M5StackFire
   amplifier:             Speaker connected to DAC pin 25

  September 2018 ChrisMicro
*/

#define DACPIN 25 // speaker DAC, only 8 Bit

#define SAMPLINGFREQUENCY 44100
#define NUMBEROFSAMPLES   SAMPLINGFREQUENCY * 1 // paly 1 seconds

#define DAC_MAX_AMPLITUDE 127/4 // max value is 127, but it is too loud

#define AUDIOBUFFERLENGTH NUMBEROFSAMPLES

uint8_t AudioBuffer[AUDIOBUFFERLENGTH];

void setup()
{
  const float   frequency = 440;
  const float   amplitude = DAC_MAX_AMPLITUDE;

  // store sine wave in buffer
  for (int n = 0; n < NUMBEROFSAMPLES; n++)
  {
    int16_t sineWaveSignal = ( sin( 2 * PI * frequency / SAMPLINGFREQUENCY * n )) * amplitude;
    AudioBuffer[n] = sineWaveSignal+128;
  }
}

void loop()
{

  uint32_t start = micros();

  for (int n = 0; n < NUMBEROFSAMPLES; n++)
  {
    // wait for next sample
    while (start + ( 1000000UL / SAMPLINGFREQUENCY) > micros() );
    start = micros();

    dacWrite(DACPIN, AudioBuffer[n]);

  }

  delay(3000);

}

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