Added files via upload

Added files via upload

// Wemos D1 mini 160Mhz, Serial, 115200, 4M(3M SPIFFS), COMx
// Build with MySensors lib 1.5.4
// Build with ESP core lib 1.6.5-947-g39819f0

/**
 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 *
 * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik EKblad
 * Contribution by a-lurker and Anticimex,
 * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
 * Contribution by Ivo Pullens (ESP8266 support)
 *
 * DESCRIPTION
 * The EthernetGateway sends data received from sensors to the WiFi link.
 * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
 *
 * VERA CONFIGURATION:
 * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
 * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
 *
 * LED purposes:
 * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
 * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
 * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
 * - ERR (red) - fast blink on error during transmission error or recieve crc error
 *
 * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
 * The ESP8266 however requires different wiring:
 * nRF24L01+  ESP8266
 * VCC        VCC
 * CE         GPIO4
 * CSN/CS     GPIO15
 * SCK        GPIO14
 * MISO       GPIO12
 * MOSI       GPIO13
 *
 * Not all ESP8266 modules have all pins available on their external interface.
 * This code has been tested on an ESP-12 module.
 * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
 * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
 * - Connect GPIO15 via 10K pulldown resistor to GND
 * - Connect CH_PD via 10K resistor to VCC
 * - Connect GPIO2 via 10K resistor to VCC
 * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
 *
  * Inclusion mode button:
 * - Connect GPIO5 via switch to GND ('inclusion switch')
 *
 * Hardware SHA204 signing is currently not supported!
 *
 * Make sure to fill in your ssid and WiFi password below for ssid & pass.
 */
#define NO_PORTB_PINCHANGES

#include <SPI.h>

#include <MySigningNone.h>
#include <MySigningAtsha204Soft.h>
#include <MyTransportNRF24.h>
#include <MyTransportRFM69.h>
#include <EEPROM.h>
#include <MyHwESP8266.h>
#include <ESP8266WiFi.h>

#include <MyParserSerial.h>
#include <MySensor.h>
#include <stdarg.h>
#include "GatewayUtil.h"

//Adapt to your network
const char *ssid =  "mySSID";    // cannot be longer than 32 characters!
const char *pass =  "myPWD"; //

#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN  5 // Digital pin used for inclusion mode button -> HSU D1 pin

#define RADIO_CE_PIN        4   // radio chip enable ->hsu number refer to gpio pin number ie D2 pin
#define RADIO_SPI_SS_PIN    15  // radio SPI serial select -> HSU D8 pin

#ifdef WITH_LEDS_BLINKING
#define RADIO_ERROR_LED_PIN BUILTIN_LED  // Error led pin
#define RADIO_RX_LED_PIN    BUILTIN_LED  // Receive led pin
#define RADIO_TX_LED_PIN    BUILTIN_LED  // the PCB, on board LED
#endif

// NRFRF24L01 radio driver (set low transmit power by default)
MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);
//MyTransportRFM69 transport;

// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
#ifdef MY_SIGNING_FEATURE
MySigningNone signer;
//MySigningAtsha204Soft signer;
#endif

// Hardware profile
MyHwESP8266 hw;

// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
// To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
MySensor gw(transport, hw
#ifdef MY_SIGNING_FEATURE
    , signer
#endif
#ifdef WITH_LEDS_BLINKING
  , RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN
#endif
  );

#define IP_PORT 5003         // The port you want to open
#define MAX_SRV_CLIENTS 3    // how many clients should be able to telnet to this ESP8266 - ie 2 JEEDOM + 1 Telnet

// a R/W server on the port
static WiFiServer server(IP_PORT);
static WiFiClient clients[MAX_SRV_CLIENTS];
static bool clientsConnected[MAX_SRV_CLIENTS];
static inputBuffer inputString[MAX_SRV_CLIENTS];

#define ARRAY_SIZE(x)  (sizeof(x)/sizeof(x[0]))

void output(const char *fmt, ... ) {
	char serialBuffer[MAX_SEND_LENGTH];
	va_list args;
	va_start (args, fmt );
	vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
	va_end (args);
	Serial.print(serialBuffer);
	for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
		if (clients[i] && clients[i].connected()) {
//			Serial.print("Client "); Serial.print(i); Serial.println(" write");
			clients[i].write((uint8_t*)serialBuffer, strlen(serialBuffer));
		}
	}
}

// HSU To display MAC Address
uint8_t MAC_array[6];
char MAC_char[18];

void setup() {
	// Setup console
	hw_init();
	Serial.begin(115200);
	Serial.println(); Serial.println();
	Serial.println("ESP8266 MySensors Gateway");
	Serial.print("Connecting to "); Serial.println(ssid);

	(void)WiFi.begin(ssid, pass);
	// HSU Addition to disable AP and display MAC address
	WiFi.mode(WIFI_STA);
	WiFi.macAddress(MAC_array);
	Serial.print("MAC Address = ");
	for (int i = 0; i < sizeof(MAC_array); ++i){
		sprintf(MAC_char,"%s%02x:",MAC_char,MAC_array[i]);
	}
	Serial.println(MAC_char); //- See more at: http://www.esp8266.com/viewtopic.php?f=29&t=3587
	// End HSU

	while (WiFi.status() != WL_CONNECTED) {
		delay(500);
		Serial.print(".");
	}
	Serial.println("Connected!");
	Serial.print("IP: "); Serial.println(WiFi.localIP());
	Serial.println(); Serial.println(); //HSU
	Serial.flush();

	setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);

	// Initialize gateway at maximum PA level, channel 70 and callback for write operations
	gw.begin(incomingMessage, 0, true, 0);

	// start listening for clients
	server.begin();
	server.write("0;0;3;0;2;");server.write(LIBRARY_VERSION);  //HSU needed for Jeedom plugin
	server.setNoDelay(true);
}

void loop() {
	gw.process();

	checkButtonTriggeredInclusion();
	checkInclusionFinished();

	// Go over list of clients and stop any that are no longer connected.
	// If the server has a new client connection it will be assigned to a free slot.
	bool allSlotsOccupied = true;
	for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++){
		if (!clients[i].connected()) {
			if (clientsConnected[i]) {
				Serial.print("Client "); Serial.print(i); Serial.println(" disconnected");
				clients[i].stop();
			}
			//check if there are any new clients
			if (server.hasClient()) {
				clients[i] = server.available();
				inputString[i].idx = 0;
				Serial.print("Client "); Serial.print(i); Serial.println(" connected");
				output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
			}
		}
		bool connected = clients[i].connected();
		clientsConnected[i] = connected;
		allSlotsOccupied &= connected;
	}
	if (allSlotsOccupied && server.hasClient()){
		//no free/disconnected spot so reject
		Serial.println("No free slot available");
		WiFiClient c = server.available();
		c.stop();
	}

	// Loop over clients connect and read available data
	for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++){
		while(clients[i].connected() && clients[i].available()){
			char inChar = clients[i].read();
			if ( inputString[i].idx < MAX_RECEIVE_LENGTH - 1 ){
				// if newline then command is complete
				if (inChar == '\n'){
					// a command was issued by the client
					// we will now try to send it to the actuator
					inputString[i].string[inputString[i].idx] = 0;

					// echo the string to the serial port
					Serial.print("Client "); Serial.print(i); Serial.print(": "); Serial.println(inputString[i].string);

					parseAndSend(gw, inputString[i].string);

					// clear the string:
					inputString[i].idx = 0;
					// Finished with this client's message. Next loop() we'll see if there's more to read.
					break;
				}
				else {
					// add it to the inputString:
					inputString[i].string[inputString[i].idx++] = inChar;
				}
			}
			else {
				// Incoming message too long. Throw away
				Serial.print("Client "); Serial.print(i); Serial.println(": Message too long");
				inputString[i].idx = 0;
				// Finished with this client's message. Next loop() we'll see if there's more to read.
				break;
			}
		}
	}
}

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


Added firmware for testing robot

Added firmware for testing robot

#include <SoftwareSerial.h>

SoftwareSerial mySerial(52, 53);

#include <AFMotor.h>

AF_DCMotor m_left(4);
AF_DCMotor m_right(1);

int MAX_LEFT = 250;
int MAX_RIGHT = 250;

int ledpin = 13;
String cmd;
boolean stringComplete = false;

void setup() {
  pinMode(ledpin, OUTPUT);

  set_speed(50);
  stop_motors();

  Serial.begin(9600);
  Serial.println("start");

  mySerial.begin(9600);
  mySerial.println("i'm ready");
}

void loop(){
  if(mySerial.available()) {
    cmd = "";
    while(mySerial.available() > 0) {
      char inChar = (char)mySerial.read();
      if (inChar == '\n' || inChar == '\r' || inChar == '|') {
        stringComplete = true;
        cmd += "\0";
      } else {
        cmd += inChar;
      }
    }
    Serial.println(cmd);
    if(cmd.startsWith("led_on")) {
      Serial.println("Led on");
      digitalWrite(ledpin, HIGH);
    } else if(cmd.startsWith("led_off")) {
      Serial.println("Led off");
      digitalWrite(ledpin, LOW);
    } else if(cmd.startsWith("drive_fwd")) {
      int fst_colon = cmd.indexOf(":");
      int sec_colon = cmd.indexOf(":", fst_colon+1);
      if(fst_colon != -1 && sec_colon != -1) {
        int time = (cmd.substring(fst_colon+1, sec_colon)).toInt();
        int pwr = (cmd.substring(sec_colon+1)).toInt();
        Serial.print("Driving fwd for ");
        Serial.print(time);
        Serial.print("ms with ");
        Serial.print(pwr);
        Serial.println(" power");

        set_speed(pwr);
        drive_fwd();
        delay(time);
        stop_motors();
      }
    } else if(cmd.startsWith("drive_bwd")) {
      int fst_colon = cmd.indexOf(":");
      int sec_colon = cmd.indexOf(":", fst_colon+1);
      if(fst_colon != -1 && sec_colon != -1) {
        int time = (cmd.substring(fst_colon+1, sec_colon)).toInt();
        int pwr = (cmd.substring(sec_colon+1)).toInt();
        Serial.print("Driving bwd for ");
        Serial.print(time);
        Serial.print("ms with ");
        Serial.print(pwr);
        Serial.println(" power");

        set_speed(pwr);
        drive_bwd();
        delay(time);
        stop_motors();
      }
    } else if(cmd.startsWith("turn_right")) {
      int fst_colon = cmd.indexOf(":");
      int sec_colon = cmd.indexOf(":", fst_colon+1);
      if(fst_colon != -1 && sec_colon != -1) {
        int time = (cmd.substring(fst_colon+1, sec_colon)).toInt();
        int pwr = (cmd.substring(sec_colon+1)).toInt();
        Serial.print("Turn right for ");
        Serial.print(time);
        Serial.print("ms with ");
        Serial.print(pwr);
        Serial.println(" power");

        set_speed(pwr);
        turn_right();
        delay(time);
        stop_motors();
      }
    } else if(cmd.startsWith("turn_left")) {
      int fst_colon = cmd.indexOf(":");
      int sec_colon = cmd.indexOf(":", fst_colon+1);
      if(fst_colon != -1 && sec_colon != -1) {
        int time = (cmd.substring(fst_colon+1, sec_colon)).toInt();
        int pwr = (cmd.substring(sec_colon+1)).toInt();
        Serial.print("Turn left for ");
        Serial.print(time);
        Serial.print("ms with ");
        Serial.print(pwr);
        Serial.println(" power");

        set_speed(pwr);
        turn_left();
        delay(time);
        stop_motors();
      }
    }
  }
}

void drive_fwd() {
  m_left.run(FORWARD);
  m_right.run(FORWARD);
}

void drive_bwd() {
  m_left.run(BACKWARD);
  m_right.run(BACKWARD);
}

void stop_motors() {
  m_left.run(RELEASE);
  m_right.run(RELEASE);
}

void turn_left() {
  m_left.run(BACKWARD);
  m_right.run(FORWARD);
}

void turn_right() {
  m_left.run(FORWARD);
  m_right.run(BACKWARD);
}

void set_speed(int s) {
  int left = map(s, 0, 100, 0, MAX_LEFT);
  int right = map(s, 0, 100, 0, MAX_RIGHT);

  Serial.print("Setting left motor speed to ");
  Serial.println(left);
  Serial.print("Setting right motor speed to ");
  Serial.println(right);
  m_left.setSpeed(left);
  m_right.setSpeed(right);
}

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


init GPS / GSM position monitoring

init GPS / GSM position monitoring

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


Add file to allow saving arduino output from serial

/* Header file that allows for writing of data from arduino to pi */

#ifndef serial-print_h
#define serial-print_h

#include "Arduino.h"

import processing.serial.*;
Serial mySerial;
PrintWriter output;
void setup() {
   mySerial = new Serial( this, Serial.list()[0], 9600 );
   output = createWriter( "data.txt" );
}
void draw() {
    if (mySerial.available() > 0 ) {
         String value = mySerial.readString();
         if ( value != null ) {
              output.println( value );
         }
    }
}

void keyPressed() {
    output.flush();  // Writes the remaining data to the file
    output.close();  // Finishes the file
    exit();  // Stops the program
}

#endif

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


add arduino

add arduino

#include "MeMegaPi.h"
#include <SoftwareSerial.h>
bool spd = true;
int moveSpeed = 100;
int minSpeed = 20;
int maxSpeed = 200;
int servoX = 90;
int servoY = 90;
String _buffer = "";
String _commands[6];

MePS2 joystick(PORT_16);

MeMegaPiDCMotor motorLeft(PORT1A);
MeMegaPiDCMotor motorRight(PORT1B);
MeMegaPiDCMotor armLeft(PORT2A);
MeMegaPiDCMotor armRight(PORT2B);
MePort port6(PORT_6);
MePort port7(PORT_7);
Servo svx;
Servo svy;
void setup() {
  Serial2.begin(115200);
  joystick.begin(115200);
  svx.attach(port7.pin1());
  svy.attach(port6.pin1());
  svx.write(90);
  svy.write(70);
}

void loop() {
  if(Serial2.available()){
    char c = Serial2.read();
    if(c!='\n'){
      _buffer+=c;
    }else{
      parseBuffer();
    }
  }
  joystickUpdate();
}
void parseBuffer(){
  int startIndex = 0,endIndex = 0,index = 0,len = _buffer.length(),maxCmdLen = 0;
  while(1){
    endIndex = _buffer.indexOf(",",startIndex);
    if(endIndex>0){
      _commands[index] = _buffer.substring(startIndex,endIndex);
      index++;
      startIndex = endIndex+1;
    }
    if(index>5||endIndex==-1){
      if(startIndex<len){
        _commands[index] = _buffer.substring(startIndex,len);
        index++;
      }
      break;
    }
  }
  maxCmdLen = index-1;
  if(_commands[0].equals("face")){
    float faceX = _commands[1].toFloat();
    float faceY = _commands[2].toFloat();
    float faceW = _commands[3].toFloat();
    float faceH = _commands[4].toFloat();
    moveServo(faceX,faceY);
  }else if(_commands[0].equals("reset")){
    svx.write(90);
    svy.write(70);
  }
  _buffer = "";
}
void joystickUpdate(){
  joystick.loop();
  if (joystick.ButtonPressed(MeJOYSTICK_UP))
  {
        forward();
  }else if (joystick.ButtonPressed(MeJOYSTICK_DOWN))
  {
        backward();
  }else if (joystick.ButtonPressed(MeJOYSTICK_LEFT))
  {
        turnLeft();
  }else if (joystick.ButtonPressed(MeJOYSTICK_RIGHT))
  {
        turnRight();
  }else if (joystick.ButtonPressed(MeJOYSTICK_R1))
  {
    if(spd){
      spd = false;
      moveSpeed+=5;
      moveSpeed = min(maxSpeed,moveSpeed);
    }
  }else if (joystick.ButtonPressed(MeJOYSTICK_R2))
  {
    if(spd){
      spd = false;
      moveSpeed-=5;
      moveSpeed = max(minSpeed,moveSpeed);
    }
  }else{
    spd = true;
    float joystickX = joystick.MeAnalog(MeJOYSTICK_LX)/5.0;
    float joystickY = joystick.MeAnalog(MeJOYSTICK_LY)/5.0;
    float angle = fmod(atan2(joystickY,joystickX)/2.0+PI*2.0,PI*2.0);
    float dist = sqrt(joystickX*joystickX+joystickY*joystickY)*moveSpeed/(minSpeed+40);
    if(angle<PI/2.0){
      move(-dist*cos(angle),dist*sin(angle));
    }else{
      move(dist*cos(angle),dist*sin(angle));
    }
  }
}

void forward(void)
{
  motorLeft.run(-moveSpeed);
  motorRight.run(moveSpeed);
}

void backward(void)
{
  motorLeft.run(moveSpeed);
  motorRight.run(-moveSpeed);
}

void turnRight(void)
{
  motorLeft.run(-moveSpeed);
  motorRight.run(-moveSpeed);
}

void turnLeft(void)
{
  motorLeft.run(moveSpeed);
  motorRight.run(moveSpeed);
}

void stop(void)
{
  motorLeft.stop();
  motorRight.stop();
}

void move(int left,int right)
{
  motorLeft.run(left);
  motorRight.run(right);
}
float prevX = 0.0;
float prevY = 0.0;
float ppX = 0.0;
float ppY = 0.0;
void moveServo(float x,float y)
{
  x = max(min(x+5,45),-45);
  y = max(min(y-5,45),-45);
  float cx = servoX-90;
  float cy = servoY-90;
  float dX = x*(cx*x<0?60:(60-abs(cx)))/45.0/20.0;
  float dY = y*(cy*y<0?60:(60-abs(cy)))/45.0/20.0;
//  for(int i=1;i<10;i++){
//    svx.write(round(servoX+dX*i/10));
//    svy.write(round(servoY+dY*i/10));
//    delay(10);
//  }
  float scale = min(10,4*(abs(prevX-dX)+1));
  servoX += scale*dX-prevX*2.2;//+ppX*0.1;
  servoY += scale*dY-prevY*2.2;//+ppY*0.1;
  ppX = prevX;
  ppY = prevY;
  prevX = dX;
  prevY = dY;
  servoX = max(min(servoX,135),45);
  servoY = max(min(servoY,135),45);
  svx.write(round(servoX));
  svy.write(round(servoY));
  Serial2.println("ok");
}

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


Create rs485_smodbus_slave.ino

Create rs485_smodbus_slave.ino

#include <SimpleModbusSlave.h>

#define  LED 4

//////////////// registers of your slave ///////////////////
enum
{
  ADC_VAL,
  PWM_VAL,
  HOLDING_REGS_SIZE
};

unsigned int holdingRegs[HOLDING_REGS_SIZE]; // function 3 and 16 register array
////////////////////////////////////////////////////////////

void setup()
{
  modbus_configure(&Serial, 19200, SERIAL_8N1, 1, 2, HOLDING_REGS_SIZE, holdingRegs);
  modbus_update_comms(19200, SERIAL_8N1, 229); //id del esclavo

  pinMode(LED, OUTPUT);
}

void loop()
{

  modbus_update();
 // holdingRegs[ADC_VAL] = analogRead(A0);

 digitalWrite(LED, HIGH);
 delay(holdingRegs[PWM_VAL]);
 digitalWrite(LED, LOW);
 delay(holdingRegs[PWM_VAL]);

}

error: pathspec 'protocol/modbus/lab/rs485_smodbus_slave.ino' did not match any file(s) known to git


Added multi-receiver for two way communciation between one queen and two scouts

// An example demonstrating the multiceiver capability of the NRF24L01+
// in a star network with one PRX hub and up to six PTX nodes

//This sketch is a modification from a video on the ForceTronics YouTube Channel,
//which code was leveraged from http://maniacbug.github.io/RF24/starping_8pde-example.html
//This sketch is free to the public to use and modify at your own risk

#include <SPI.h> //Call SPI library so you can communicate with the nRF24L01+
#include <nRF24L01.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/
#include <RF24.h> //nRF2401 libarary found at https://github.com/tmrh20/RF24/

const int pinCE = 7; //This pin is used to set the nRF24 to standby (0) or active mode (1)
const int pinCSN = 8; //This pin is used to tell the nRF24 whether the SPI communication is a command or message to send out
RF24 radio(pinCE, pinCSN); // Declare object from nRF24 library (Create your wireless SPI)

//Create up to 6 pipe addresses P0 - P5;  the "LL" is for LongLong type
const uint64_t rAddress[] = {0x7878787878LL, 0xB3B4B5B6F1LL, 0xB3B4B5B6CDLL, 0xB3B4B5B6A3LL, 0xB3B4B5B60FLL, 0xB3B4B5B605LL };

byte daNumber = 0; //The number that the transmitters are trying to guess

void setup()
{
  randomSeed(analogRead(0)); //create unique seed value for random number generation
  daNumber = (byte)random(11); //Create random number that transmitters have to guess
  Serial.begin(115200);  //start serial to communication
  Serial.print("The number they are trying to guess is: ");
  Serial.println(daNumber); //print the number that they have to guess
  Serial.println();
  radio.begin();  //Start the nRF24 module

  radio.setPALevel(RF24_PA_MAX);  // "short range setting" - increase if you want more range AND have a good power supply
  radio.setChannel(108);          // the higher channels tend to be more "open"

  // Open up to six pipes for PRX to receive data
  radio.openReadingPipe(0,rAddress[0]);
  radio.openReadingPipe(1,rAddress[1]);
  radio.openReadingPipe(2,rAddress[2]);
  radio.openReadingPipe(3,rAddress[3]);
  radio.openReadingPipe(4,rAddress[4]);
  radio.openReadingPipe(5,rAddress[5]);

  radio.startListening();                 // Start listening for messages
}

void loop()
{
    byte pipeNum = 0; //variable to hold which reading pipe sent data
    byte gotByte = 0; //used to store payload from transmit module

    while(radio.available(&pipeNum)){ //Check if received data
     radio.read( &gotByte, 1 ); //read one byte of data and store it in gotByte variable
     Serial.print("Received guess from transmitter: ");
     Serial.println(pipeNum + 1); //print which pipe or transmitter this is from
     Serial.print("They guess number: ");
     Serial.println(gotByte); //print payload or the number the transmitter guessed
     if(gotByte != daNumber) { //if true they guessed wrong
      Serial.println("Fail!! Try again.");
     }
     else { //if this is true they guessed right
      if(sendCorrectNumber(pipeNum)) Serial.println("Correct! You're done."); //if true we successfully responded
      else Serial.println("Write failed"); //if true we failed responding
     }
     Serial.println();
    }

   delay(200);
}

 //This function turns the receiver into a transmitter briefly to tell one of the nRF24s
//in the network that it guessed the right number. Returns true if write to module was
//successful
bool sendCorrectNumber(byte xMitter) {
    bool worked; //variable to track if write was successful
    radio.stopListening(); //Stop listening, start receiving data.
    radio.openWritingPipe(rAddress[xMitter]); //Open writing pipe to the nRF24 that guessed the right number
      // note that this is the same pipe address that was just used for receiving
    if(!radio.write(&daNumber, 1))  worked = false; //write the correct number to the nRF24 module, and check that it was received
    else worked = true; //it was received
    radio.startListening(); //Switch back to a receiver
    return worked;  //return whether write was successful
}

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


Create dedicated MegaPi Firmware sketch for Dovlo. Add service server to enable/disable motors. Reduce speed to 57600 bds

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


Add example demonstrating time syncronization with the network

/*******************************************************************************
 * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
 * Copyright (c) 2018 Terry Moore, MCCI
 *
 * Permission is hereby granted, free of charge, to anyone
 * obtaining a copy of this document and accompanying files,
 * to do whatever they want with them without any restriction,
 * including, but not limited to, copying, modification and redistribution.
 * NO WARRANTY OF ANY KIND IS PROVIDED.
 *
 * This example sends a valid LoRaWAN packet with payload "Hello,
 * world!", using frequency and encryption settings matching those of
 * the The Things Network.
 *
 * This uses OTAA (Over-the-air activation), where where a DevEUI and
 * application key is configured, which are used in an over-the-air
 * activation procedure where a DevAddr and session keys are
 * assigned/generated for use with all further communication.
 *
 * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in
 * g1, 0.1% in g2), but not the TTN fair usage policy (which is probably
 * violated by this sketch when left running for longer)!

 * To use this sketch, first register your application and device with
 * the things network, to set or generate an AppEUI, DevEUI and AppKey.
 * Multiple devices can use the same AppEUI, but each device has its own
 * DevEUI and AppKey.
 *
 * Do not forget to define the radio type correctly in config.h.
 *
 *******************************************************************************/

#include <Time.h>
#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

//
// For normal use, we require that you edit the sketch to replace FILLMEIN
// with values assigned by the TTN console. However, for regression tests,
// we want to be able to compile these scripts. The regression tests define
// COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non-
// working but innocuous value.
//
#ifdef COMPILE_REGRESSION_TEST
# define FILLMEIN 0
#else
# warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!"
# define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN)
#endif

// This EUI must be in little-endian format, so least-significant-byte
// first. When copying an EUI from ttnctl output, this means to reverse
// the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
// 0x70.
static const u1_t PROGMEM APPEUI[8]={ FILLMEIN };
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}

// This should also be in little endian format, see above.
static const u1_t PROGMEM DEVEUI[8]={ FILLMEIN };
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}

// This key should be in big endian format (or, since it is not really a
// number but a block of memory, endianness does not really apply). In
// practice, a key taken from ttnctl can be copied as-is.
static const u1_t PROGMEM APPKEY[16] = { FILLMEIN };
void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY, 16);}

static uint8_t mydata[] = "Hello, world!";
static osjob_t sendjob;

// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 60;

// Pin mapping
const lmic_pinmap lmic_pins = {
    .nss = 6,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 5,
    .dio = {2, 3, 4},
};

void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println(F("EV_SCAN_TIMEOUT"));
            break;
        case EV_BEACON_FOUND:
            Serial.println(F("EV_BEACON_FOUND"));
            break;
        case EV_BEACON_MISSED:
            Serial.println(F("EV_BEACON_MISSED"));
            break;
        case EV_BEACON_TRACKED:
            Serial.println(F("EV_BEACON_TRACKED"));
            break;
        case EV_JOINING:
            Serial.println(F("EV_JOINING"));
            break;
        case EV_JOINED:
            Serial.println(F("EV_JOINED"));
            {
              u4_t netid = 0;
              devaddr_t devaddr = 0;
              u1_t nwkKey[16];
              u1_t artKey[16];
              LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey);
              Serial.print("netid: ");
              Serial.println(netid, DEC);
              Serial.print("devaddr: ");
              Serial.println(devaddr, HEX);
              Serial.print("artKey: ");
              for (int i=0; i<sizeof(artKey); ++i) {
                Serial.print(artKey[i], HEX);
              }
              Serial.println("");
              Serial.print("nwkKey: ");
              for (int i=0; i<sizeof(nwkKey); ++i) {
                Serial.print(nwkKey[i], HEX);
              }
              Serial.println("");
            }
            // Disable link check validation (automatically enabled
            // during join, but because slow data rates change max TX
	    // size, we don't use it in this example.
            LMIC_setLinkCheckMode(0);
            break;
        /*
        || This event is defined but not used in the code. No
        || point in wasting codespace on it.
        ||
        || case EV_RFU1:
        ||     Serial.println(F("EV_RFU1"));
        ||     break;
        */
        case EV_JOIN_FAILED:
            Serial.println(F("EV_JOIN_FAILED"));
            break;
        case EV_REJOIN_FAILED:
            Serial.println(F("EV_REJOIN_FAILED"));
            break;
        case EV_TXCOMPLETE:
            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
            if (LMIC.txrxFlags & TXRX_ACK)
              Serial.println(F("Received ack"));
            if (LMIC.dataLen) {
              Serial.print(F("Received "));
              Serial.print(LMIC.dataLen);
              Serial.println(F(" bytes of payload"));
            }
            // Schedule next transmission
            os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
            break;
        case EV_LOST_TSYNC:
            Serial.println(F("EV_LOST_TSYNC"));
            break;
        case EV_RESET:
            Serial.println(F("EV_RESET"));
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println(F("EV_RXCOMPLETE"));
            break;
        case EV_LINK_DEAD:
            Serial.println(F("EV_LINK_DEAD"));
            break;
        case EV_LINK_ALIVE:
            Serial.println(F("EV_LINK_ALIVE"));
            break;
        /*
        || This event is defined but not used in the code. No
        || point in wasting codespace on it.
        ||
        || case EV_SCAN_FOUND:
        ||    Serial.println(F("EV_SCAN_FOUND"));
        ||    break;
        */
        case EV_TXSTART:
            Serial.println(F("EV_TXSTART"));
            break;
        default:
            Serial.print(F("Unknown event: "));
            Serial.println((unsigned) ev);
            break;
    }
}

uint32_t userUTCTime; // Seconds since the UTC epoch

// Utility function for digital clock display: prints preceding colon and
// leading 0
void printDigits(int digits) {

    Serial.print(':');
    if (digits < 10) Serial.print('0');
    Serial.print(digits);
}

void user_request_network_time_callback(uint32_t *pUserUTCTime, int flagSuccess) {

    // A struct that will be populated by LMIC_getNetworkTimeReference.
    // It contains the following fields:
    //  - tLocal: the value returned by os_GetTime() when the time
    //            request was sent to the gateway, and
    //  - tNetwork: the seconds between the GPS epoch and the time
    //              the gateway received the time request
    lmic_time_reference_t lmicTimeReference;

    if (flagSuccess != 1) {
        Serial.println(F("USER CALLBACK: Not a success"));
        return;
    }

    // Populate "lmic_time_reference"
    flagSuccess = LMIC_getNetworkTimeReference(&lmicTimeReference);
    if (flagSuccess != 1) {
        Serial.println(F("USER CALLBACK: LMIC_getNetworkTimeReference didn't succeed"));
        return;
    }

    // Update userUTCTime, considering the difference between the GPS and UTC
    // epoch, and the leap seconds
    *pUserUTCTime = lmicTimeReference.tNetwork + 315964800;

    // Add the delay between the instant the time was transmitted and
    // the current time

    // Current time, in ticks
    ostime_t ticksNow = os_getTime();
    // Time when the request was sent, in ticks
    ostime_t ticksRequestSent = lmicTimeReference.tLocal;
    uint32_t requestDelaySec = osticks2ms(ticksNow - ticksRequestSent) / 1000;
    *pUserUTCTime += requestDelaySec;

    // Update the system time with the time read from the network
    setTime(*pUserUTCTime);

    Serial.print(F("The current UTC time is: "));
    Serial.print(hour());
    printDigits(minute());
    printDigits(second());
    Serial.print(' ');
    Serial.print(day());
    Serial.print('/');
    Serial.print(month());
    Serial.print('/');
    Serial.print(year());
    Serial.println();
}

void do_send(osjob_t* j) {
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println(F("OP_TXRXPEND, not sending"));
    } else {
        // Schedule a network time request at the next possible time
        LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime);

        // Prepare upstream data transmission at the next possible time.
        LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
        Serial.println(F("Packet queued"));
    }
    // Next TX is scheduled after TX_COMPLETE event.
}

void setup() {
    Serial.begin(9600);
    Serial.println(F("Starting"));

    #ifdef VCC_ENABLE
    // For Pinoccio Scout boards
    pinMode(VCC_ENABLE, OUTPUT);
    digitalWrite(VCC_ENABLE, HIGH);
    delay(1000);
    #endif

    // LMIC init
    os_init();
    // Reset the MAC state. Session and pending data transfers will be discarded.
    LMIC_reset();

    // Start job (sending automatically starts OTAA too)
    do_send(&sendjob);
}

void loop() {
    os_runloop_once();
}

error: pathspec 'examples/ttn-otaa-network-time/ttn-otaa-network-time.ino' did not match any file(s) known to git


Added new faster code for the Arduino server

#include <stdio.h>
#include <uVector.h>
#include <XbeeS6.h>
#include <string.h>
#include <Time.h>

//#include "XbeeS6.h"
#define BAUD_RATE 57600

Tx64Packet tx_packet;

uVector myvector;
static uint8_t * tx_buffer1;

HardwareSerial Uart = HardwareSerial();
unsigned long baud = 57600;
const int reset_pin = 4;
const int led_pin = 11;  // 11=Teensy 2.0, 6=Teensy 1.0, 16=Benito
const int led_on = HIGH;
const int led_off = LOW;

volatile time_t start_time;
time_t current_time;
long previousMillis = 0;
long interval = 500;

void setup()
{
  //start_time = now();

  pinMode(led_pin, OUTPUT);
  digitalWrite(led_pin, led_off);
  digitalWrite(reset_pin, HIGH);
  pinMode(reset_pin, OUTPUT);
  Serial.begin(BAUD_RATE);
  Serial.println("Starting the Receiver!");
  second(start_time);
  Serial.print("Starting time: ");
  Serial.println(start_time);

  tx_packet.set_Address(0x00000000C0A80165);

  tx_buffer1 = get_buffer();

  Uart.begin(BAUD_RATE);

  Serial.println("=======================");
  Serial.println("?: for Receive mode HEX");
  Serial.println("#: for Receive mode BYTE (for Config)");
  Serial.println("$: for TX Mode");
  Serial.println("=======================");
  Uart.flush();

}
int j = 0;
int k = 0;
volatile int enable;
long led_on_time=0;
void loop()
{
  //static int enable;
  unsigned char c, dtr;
  static unsigned char prev_dtr = 0;
  unsigned long currentMillis = millis();
  if (Serial.available()) {
    c = Serial.read();
    if(c == '?') {
      enable = 3;
      return;
    }

    if(c == '$' ) {
      enable  =1;
      return;
    }
    if(c == '#' ) {
      enable = 2;
      return;
    }
    if(c == '^') {
      Uart.flush();
      return;
    }
    Uart.write(c);
    digitalWrite(led_pin, led_on);
    led_on_time = millis();
    return;
  }
  /* Determine Server Configuration*/
  if(currentMillis-previousMillis > interval)
  {
    if(enable == 1)
    {

      uint16_t length = tx_packet.prepare2send();
      uint16_t i;

      for(i = 0; i < length; i++)
      {
        Uart.write(tx_buffer1[i]);
      }
      for(i = 0; i < length; i++)
      {
        Serial.print(tx_buffer1[i], HEX);
        Serial.print(" ");
      }
      Serial.println(' ');
      j++;
      tx_packet.clear_payload();
      tx_packet.push_back( (uint8_t) j);
      Uart.flush();
      Serial.println("response");
      while(Uart.available())
      {

        Serial.print(Uart.read(),HEX);
        Serial.print(" ");
      }
      Serial.println("EOR");

    }
    //else
    if(enable == 2) //For command mode use write for repsponse use print
    {
      if (Uart.available())
      {
        c = Uart.read();
        Serial.write(c);
        digitalWrite(led_pin, led_on);
        led_on_time = millis();
        return;
      }
    }
    //else
    if(enable == 3) //For command mode use write for response use print
    {
      if (Uart.available())
      {
        c = Uart.read();
        //		Serial.write(c);
        current_time = now();
        //Serial.print("current time: ");
        //Serial.println(current_time);
        if(c == 0x7E) Serial.println();
        Serial.print(c, HEX);
        Serial.print(" ");
        digitalWrite(led_pin, led_on);
        led_on_time = millis();
        return;
      }
    }
    previousMillis = currentMillis;
  }

  /* Control Bootloader*/
  dtr = Serial.dtr();
  if (dtr && !prev_dtr) {
    digitalWrite(reset_pin, LOW);
    delayMicroseconds(250);
    digitalWrite(reset_pin, HIGH);
  }
  prev_dtr = dtr;
  if (millis() - led_on_time > 3) {
    digitalWrite(led_pin, led_off);
  }
  if (Serial.baud() != baud) {
    baud = Serial.baud();
    if (baud == 57600) {
      // This ugly hack is necessary for talking
      // to the arduino bootloader, which actually
      // communicates at 58824 baud (+2.1% error).
      // Teensyduino will configure the UART for
      // the closest baud rate, which is 57143
      // baud (-0.8% error).  Serial communication
      // can tolerate about 2.5% error, so the
      // combined error is too large.  Simply
      // setting the baud rate to the same as
      // arduino's actual baud rate works.
      Uart.begin(58824);
    }
    else {
      Uart.begin(baud);
    }
  }

}

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


Plant to plant SpikerShield code for Leonardo added

error: pathspec 'Plant/Arduino' did not match any file(s) known to git
error: pathspec 'Code/PPILeonardo_V1-0/PPILeonardo_V1-0.ino' did not match any file(s) known to git


Arduino code to read from the parallel lines and print to Arduino serial port.

int parallel_read_pins[] = {2, 3, 4, 5, 6, 7, 8, 9};

void setup() {

  for(int i=0; i<8; i++)
  {
    pinMode(parallel_read_pins[i], INPUT);
  }

  Serial.begin(9600);
  while( !Serial ) ; // wait for serial terminal to be opened.
}

void loop() {
  // put your main code here, to run repeatedly:
  for(int i=0; i<8; i++)
  {
    Serial.print(digitalRead(parallel_read_pins[i]));
  }
  Serial.println("");
}

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


Added updated T16 Drive Sketch

Added updated T16 Drive Sketch

Added max throttle control and removed differential calculations to library

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


for g3 sensor

for g3 sensor

Arduino with cc3000wifi based/G3_module/PPG3_099b0229.ino

error: pathspec 'Arduino' did not match any file(s) known to git
error: pathspec 'with' did not match any file(s) known to git
error: pathspec 'cc3000wifi' did not match any file(s) known to git
error: pathspec 'based/G3_module/PPG3_099b0229.ino' did not match any file(s) known to git


V2.0

V2.0

Cleaner layout of code, new flashing function
( http://008.ddns.net:8080/leds?COULEUR=%23FFFFFF&DELAIS=500&FOIS=10 or a form post)

#include <WiFi.h>
#include <DNSServer.h>
#include <WebServer.h>
#include <WiFiManager.h>
#include <WiFiMulti.h>
#include <HTTPClient.h>

// sensors stuff
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>
#include <ESPmDNS.h>
#define ONE_WIRE_BUS 15
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// end of sensors

// Settings you should check/change
String resetpass = "YOURresetPASSWORD"; // password to reset wifimanager when allready connected
const String thingkey = "YourThingSpeakApiWriteKey"; //your thingspeak API key
const String thingchanel = "000000"; //your thingspeak Chanel #
// other settings you might like to change
const long interval = 60000; // interval in ms for sending temperature data to thingspeak
const String liens = "Acceuil - Température - Version - Reset - Temp stats\n"; // html/links shown at bottom of pages
String dernadd = "Fraichement booté"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
// led pins
uint8_t pinRouge = 12;
uint8_t pinVerte = 14; // internally pulled up
uint8_t pinBleu = 13;
// end of settings you should check/change

// internally used vars
WebServer server(80);
String derncoul = "#000000";
long r = 0;
long g = 0;
long b = 0;
int rouge = 0;
int vert = 0;
int bleu = 0;
unsigned long previousMillis = 0;
unsigned long previousMillisr = 0;
unsigned long previousMillisg = 0;
unsigned long previousMillisb = 0;
unsigned long previousMillisf = 0;
int attendR = 70;
int attendG = 70;
int attendB = 70;
int attendF = 700;
unsigned long flashfois = 0;
unsigned long flashrendu = 0;
int roulepastusuite = 0;
int flashoufade = 0;
// end of internally used vars

// stylesheet for web pages
const String css = "\n";
// end of stylesheet for web pages

// functions used internally

// used to flash leds
void flashfunk() {
  if (flashrendu <= flashfois) {
    flashrendu++;
    if (rouge == r) {
      ledcWrite(1, 0);
      rouge = 0;
    } else {
      ledcWrite(1, r);
      rouge = r;
    }
    if (vert == g) {
      ledcWrite(2, 0);
      vert = 0;
    } else {
      ledcWrite(2, g);
      vert = g;
    }
    if (bleu == b) {
      ledcWrite(3, 0);
      bleu = 0;
    } else {
      ledcWrite(3, b);
      bleu = b;
    }
  } else {
    r = rouge;
    b = bleu;
    g = vert;
    flashoufade = 0;
    flashrendu = 0;
    Serial.println("Flash fini");
  }
}

// used to fade red
void fadeR() {
  if (rouge < r) {
    rouge++;
    ledcWrite(1, rouge);
  } else if (rouge > r) {
    rouge--;
    ledcWrite(1, rouge);
  }
}

// used to fade green
void fadeG() {
  if (vert < g) {
    vert++;
    ledcWrite(2, vert);
  } else if (vert > g) {
    vert--;
    ledcWrite(2, vert);
  }
}

// used to fade blue
void fadeB() {
  if (bleu  b) {
    bleu--;
    ledcWrite(3, bleu);
  }
}

// web page to handle flashing of leds (color/delay/number of flashes)
void handleFlash() {
  String addy = server.client().remoteIP().toString();
  Serial.println("");
  Serial.println(addy);
  Serial.println("Flash");
  String testteu = server.arg("COULEUR");
  String attend = server.arg("DELAIS");
  attendF = attend.toInt();
  String flashnombre = server.arg("FOIS");
  flashfois = flashnombre.toInt();
  flashfois = flashfois * 2;
  Serial.println(testteu);
  Serial.print("Delais - ");
  Serial.println(attendF);
  Serial.print("Fois - ");
  Serial.println(flashfois / 2);
  if (testteu != 0) {
    if ( (flashfois % 2) == 0) {
      derncoul = testteu;
    } else {
      derncoul = "#000000";
    }
    long number = strtol( &testteu[1], NULL, 16);
    r = number >> 16;
    g = number >> 8 & 0xFF;
    b = number & 0xFF;
    Serial.print("Rouge = ");
    Serial.println(r);
    Serial.print("Vert = ");
    Serial.println(g);
    Serial.print("Bleu = ");
    Serial.println(b);
    dernadd = addy;
    flashoufade = 1;
    ledcWrite(1, 0);
    ledcWrite(2, 0);
    ledcWrite(3, 0);
    rouge = 0;
    bleu = 0;
    vert = 0;
  }
  String contenu = "<!DOCTYPE html>\n\n\n";
  contenu += "<meta http-equiv=\"refresh\" content=\"0;url=/\" />\n";
  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
  contenu += css;
  contenu += "\n\n"
             "Merci\n";
  server.send(200, "text/html", contenu);
}

// web page to handle leds fading
void handleLeds() {
  String addy = server.client().remoteIP().toString();
  Serial.println("");
  Serial.println(addy);
  String testteu = server.arg("COULEUR");
  Serial.println(testteu);
  if (testteu != 0) {
    derncoul = testteu;
    long number = strtol( &testteu[1], NULL, 16);
    r = number >> 16;
    g = number >> 8 & 0xFF;
    b = number & 0xFF;
    if (r != rouge) {
      Serial.print("Rouge = ");
      Serial.println(r);
      dernadd = addy;
      flashoufade = 0;
    }
    if (g != vert) {
      Serial.print("Vert = ");
      Serial.println(g);
      dernadd = addy;
      flashoufade = 0;
    }
    if (b != bleu) {
      Serial.print("Bleu = ");
      Serial.println(b);
      dernadd = addy;
      flashoufade = 0;
    }
  }
  String contenu = "<!DOCTYPE html>\n\n\n";
  contenu += "<meta http-equiv=\"refresh\" content=\"0;url=/\" />\n";
  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
  contenu += css;
  contenu += "\n\n"
             "Merci\n";
  server.send(200, "text/html", contenu);
}

// index page
void handleRoot() {
  String addy = server.client().remoteIP().toString();
  Serial.println("");
  Serial.println(addy);
  Serial.println("Page acceuil");
  String contenu = "<!DOCTYPE html>\n\n\n";
  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
  contenu += css;
  contenu += "\n";
  contenu += "\n\n"
             "
\n"
             "<form id=\"laforme\" action=\"/leds\" method=\"post\">\n"
             "
Change la couleur de mon bureau:
"
             "<input id=\"colorpad\" type=\"color\" name=\"COULEUR\" class=\"color\" value=\"" + derncoul + "\">
\n"
             "<input type=\"submit\" class=\"button1\" value=\"Changer\">\n"
             "</form>\n"
             "<button onclick=\"disco()\">Hazard</button>
\n"
             "<button onclick=\"startDisco()\">Auto Disco</button>
\n"
             "Dernier IP à avoir changé la couleur : ";
  contenu += dernadd;
  contenu += "
\n";
  contenu += liens;
  contenu += "\n"
             "
\n";
  server.send(200, "text/html", contenu);
}

//reset page
void handleReset() {
  int ouireset = 0;
  String addy = server.client().remoteIP().toString();
  Serial.println("");
  Serial.println(addy);
  Serial.println("!!! RESET PAGE !!!");
  String testteu = server.arg("RESET");
  String passme = server.arg("PASSME");
  if (testteu == "OUI") {
    if (passme == resetpass) {
      ouireset = 1;
    } else {
      ouireset = 2;
    }
  }
  String contenu = "<!DOCTYPE html>\n\n\n";
  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere se RESET</title>\n"
             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
  contenu += css;
  contenu += "\n\n"
             "
\n";
  if (!ouireset) {
    contenu += "<form action=\"/reset\" method=\"post\">\n"
               "
Tu veux resetter le wifi network pour reconfigurer ?
"
               "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
               "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
               "</form>\n";
  } else if (ouireset != 1) {
    contenu += "<form action=\"/reset\" method=\"post\">\n"
               "
Tu veux resetter le wifi network pour reconfigurer ?
"
               "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
               "
!!! MAUVAIS PASSWORD !!!

\n"
               "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
               "</form>\n";
    Serial.print("BAD PASSWORD : ");
    Serial.println(passme);
  } else if (ouireset == 1) {
    contenu += "
Reset Dans 10 Secondes
\n";
  }
  contenu += "
Dernier IP à avoir changé la couleur :";
  contenu += dernadd;
  contenu += "\n
";
  contenu += liens;
  contenu += "\n

\n";
  server.send(200, "text/html", contenu);
  if (ouireset == 1) {
    Serial.println("Reset dans 10 secondes");
    delay(10000);
    WiFiManager wifiManager;
    wifiManager.resetSettings();
    ESP.restart();
  }
}

// 404 not found page
void handleNotFound() {
  String addy = server.client().remoteIP().toString();
  Serial.println("");
  Serial.println(addy);
  String htmlmessage = "<!DOCTYPE html>\n\n\n";
  htmlmessage += "<meta charset=\"UTF-8\" />\n<title>404 Not found</title>\n"
                 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
  htmlmessage += css;
  htmlmessage += "\n\n"
                 "
\n";
  htmlmessage += "
404 File Not Found

\n";
  htmlmessage += "URI: ";
  htmlmessage += server.uri();
  htmlmessage += "
\nMethod: ";
  htmlmessage += (server.method() == HTTP_GET) ? "GET" : "POST";
  htmlmessage += "
\nArguments: ";
  htmlmessage += server.args();
  htmlmessage += "
\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    htmlmessage += " " + server.argName(i) + ": " + server.arg(i) + "
\n";
  }
  htmlmessage += "
\n";
  htmlmessage += liens;
  htmlmessage += "
\n
\n";
  server.send(404, "text/html", htmlmessage);
  String message = "404 File Not Found\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  Serial.print(message);
}

// function executed in main loop every minute to update sensors data to thingspeak.com
void latemp() {
  sensors.requestTemperatures();
  float thetemp = sensors.getTempCByIndex(0);
  char buffer[10];
  String tempC = dtostrf(thetemp, 5, 2, buffer);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (tempC != "-127.00") {
    if (tempC != "85.00") {
      Serial.print("Envoi de temperature et humidite: ");
      Serial.print(tempC);
      Serial.print(" - ");
      HTTPClient http;
      String webadd = "http://api.thingspeak.com/update?key=";
      webadd += thingkey;
      webadd += "&field1=";
      webadd += tempC;
      if (h == h) { // to prevent NaN
        webadd += "&field2=";
        webadd += h;
        Serial.print(h);
        webadd += "&field3=";
        webadd += t;
      }
      Serial.println("");
      http.begin(webadd);
      int httpCode = http.GET();//Send the request
      http.end();   //Close connection
    }
  }
}

// web page for showing sensors data
void handleTemp() {
  sensors.requestTemperatures();
  float latemp = sensors.getTempCByIndex(0);
  float h = dht.readHumidity();
  while (latemp == -127.00) {
    sensors.requestTemperatures();
    latemp = sensors.getTempCByIndex(0);
  }
  String addy = server.client().remoteIP().toString();
  Serial.println("");
  Serial.println(addy);
  Serial.print("Temperature : ");
  Serial.println(latemp);
  String contenu = "<!DOCTYPE html>\n\n\n";
  contenu += "<meta charset=\"UTF-8\" />\n<title>Quel chaleur</title>\n"
             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
  contenu += css;
  contenu += "\n\n"
             "
\n";
  contenu += "<form action=\"/\" method=\"get\">\n"
             "
Voici la temperature
"
             "
";
  contenu += latemp;
  contenu += "°C Humidité : ";
  contenu += h;
  contenu += "

\n"
             ""
             ""
             "<input type=\"submit\" class=\"button1\" value=\"Acceuil\">\n"
             "</form>\n"
             "
Dernier IP à avoir changé la couleur :";
  contenu += dernadd;
  contenu += "\n
";
  contenu += liens;
  contenu += "\n

\n";
  server.send(200, "text/html", contenu);
}

void setup() {
  Serial.begin(115200);
  dht.begin();
  ledcAttachPin(pinRouge, 1); // assign RGB led pins to channels
  ledcAttachPin(pinVerte, 2);
  ledcAttachPin(pinBleu, 3);
  pinMode(pinRouge, OUTPUT);
  pinMode(pinVerte, OUTPUT);
  pinMode(pinBleu, OUTPUT);
  digitalWrite(pinRouge, LOW);
  digitalWrite(pinBleu, LOW);
  digitalWrite(pinVerte, LOW);
  ledcSetup(1, 12000, 8); // 12 kHz PWM, 8-bit resolution
  ledcSetup(2, 12000, 8);
  ledcSetup(3, 12000, 8);
  WiFiManager wifiManager;
  wifiManager.autoConnect();
  MDNS.begin("lumiere");
  server.on("/", handleRoot);
  server.on("/leds", handleLeds);
  server.on("/flash", handleFlash);
  server.on("/reset", handleReset);
  server.on("/temp", handleTemp);
  server.on("/version", []() {
    String addy = server.client().remoteIP().toString();
    Serial.println("");
    Serial.println(addy);
    Serial.println("Version request");
    server.send(200, "text/html", "V2.0, Steve Olmstead sansillusion@gmail.com\n\n

"
                "Added fader function\nRemoved connection watchdog (better have good signal)\n
"
                "Removed mDns (did not work anyway)\n\n

"
                "Added smoother fading\n\n

"
                "Added AutoConect WifiManager !\n\n

"
                "Added basic last IP logging\n
"
                "Added /reset page to reset wifiManager connection settings\n\n

"
                "Added /temp (temperature sensor read of ky-001)\n\n

"
                "Added thingspeak support to send temperature each minute
\n\n
"
                "Major rewrite for RGB led trip usin mosfet
\n"
                "Removed serial to free resources for software pwm (still flikers but less than before)
\n\n
"
                "Seperated LEDs handling page from index\n
"
                "Added jQuery to load settings without reloading page\n
"
                "Added random color selection button\n\n

"
                "Added disco mode script and buttons\n\n

"
                "Removed mDNS (does not work with esp32)\n
"
                "        (Re-aded mDNS in 2.0 for esp32 but does not seem to work yet)\n
"
                "Rewrite of code (removed Ticker and changed a few libraries) for esp32 !!!\n\n

"
                "Changed fader functions for smoother fade\n
"
                "Cleaned code\n\n

"
                "Added Flashing function and page for smart widget usage\n
"
                "Added var to show your thingspeak channel in /temp iframes\n\n

" + liens);
  });
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");
  delay(100);
  MDNS.addService("http", "tcp", 80);
  sensors.begin();
}

void loop() {
  server.handleClient();
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    latemp();
  }
  if (flashoufade == 1) {
    currentMillis = millis();
    if (currentMillis - previousMillisf >= attendF) {
      previousMillisf = currentMillis;
      flashfunk();
    }
  } else {
    if (r != rouge) {
      currentMillis = millis();
      if (currentMillis - previousMillisr >= attendR) {
        fadeR();
        previousMillisr = currentMillis;
        if (rouge > 0)
          attendR = 70;
        if (rouge > 40)
          attendR = 60;
        if (rouge > 80)
          attendR = 50;
        if (rouge > 100)
          attendR = 40;
        if (rouge > 120)
          attendR = 30;
        if (rouge > 140)
          attendR = 20;
        if (rouge > 180)
          attendR = 10;
      }
    }
    if (g != vert) {
      currentMillis = millis();
      if (currentMillis - previousMillisg >= attendG) {
        fadeG();
        previousMillisg = currentMillis;
        if (vert > 0)
          attendG = 70;
        if (vert > 40)
          attendG = 60;
        if (vert > 80)
          attendG = 50;
        if (vert > 100)
          attendG = 40;
        if (vert > 120)
          attendG = 30;
        if (vert > 140)
          attendG = 20;
        if (vert > 180)
          attendG = 10;
      }
    }
    if (b != bleu) {
      currentMillis = millis();
      if (currentMillis - previousMillisb >= attendB) {
        fadeB();
        previousMillisb = currentMillis;
        if (bleu > 0)
          attendB = 70;
        if (bleu > 40)
          attendB = 60;
        if (bleu > 80)
          attendB = 50;
        if (bleu > 100)
          attendB = 40;
        if (bleu > 120)
          attendB = 30;
        if (bleu > 140)
          attendB = 20;
        if (bleu > 180)
          attendB = 10;
      }
    }
  }
}

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


avoid restarting when json attributes are null


Firmware for TENS board for Leonardo

Firmware for TENS board for Leonardo

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


Study RF433 AGC behavior; RSSI implementation.

/**
 * @file CosaRF433.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
 * Study RF433 AGC behavior.
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/RTC.hh"
#include "Cosa/Trace.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/OutputPin.hh"
#include "Cosa/IOStream/Driver/UART.hh"

OutputPin rf(Board::D6);

void setup()
{
  uart.begin(9600);
  trace.begin(&uart, PSTR("CosaRF433: started"));
  Watchdog::begin();
  RTC::begin();
}

void loop()
{
  const uint16_t P = 1000;
  const uint16_t D[] = { 1000, 500, 200, 100, 50 };
  rf.set();
  delay(10);
  rf.clear();
  for (uint8_t j = 0; j < membersof(D); j++) {
    uint16_t T = D[j];
    for (uint8_t i = 0; i < 8; i++) {
      DELAY(T);
      rf.set();
      DELAY(T);
      rf.clear();
    }
  }
  sleep(2);
}

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


atwinc demo

atwinc demo

/***************************************************
  Adafruit MQTT Library WINC1500 Example

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/
#include <SPI.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include <Adafruit_WINC1500.h>

/************************* WiFI Setup *****************************/
#define WINC_CS   8
#define WINC_IRQ  7
#define WINC_RST  4

Adafruit_WINC1500 WiFi(WINC_CS, WINC_IRQ, WINC_RST);

char ssid[] = "yournetwork";     //  your network SSID (name)
char pass[] = "yourpassword";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

/************************* Adafruit.io Setup *********************************/

#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883
#define AIO_USERNAME    "adafruit2"
#define AIO_KEY         "3e148db54389a8b7c3efa9ddd2cd388317bcbf58"

/************ Global State (you don't need to change this!) ******************/

//Set up the wifi client
Adafruit_WINC1500Client client;

// Store the MQTT server, client ID, username, and password in flash memory.
// This is required for using the Adafruit MQTT library.
const char MQTT_SERVER[] PROGMEM    = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
const char MQTT_CLIENTID[] PROGMEM  = __TIME__ AIO_USERNAME;
const char MQTT_USERNAME[] PROGMEM  = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM  = AIO_KEY;

Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);

// You don't need to change anything below this line!
#define halt(s) { Serial.println(F( s )); while(1);  }

/****************************** Feeds ***************************************/

// Setup a feed called 'photocell' for publishing.
// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
const char PHOTOCELL_FEED[] PROGMEM = AIO_USERNAME "/feeds/photocell";
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, PHOTOCELL_FEED);

// Setup a feed called 'onoff' for subscribing to changes.
const char ONOFF_FEED[] PROGMEM = AIO_USERNAME "/feeds/onoff";
Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, ONOFF_FEED);

/*************************** Sketch Code ************************************/

#define LEDPIN 13

void setup() {
  pinMode(WINC_EN, OUTPUT);
  digitalWrite(WINC_EN, HIGH);

  //while (!Serial);
  Serial.begin(115200);

  Serial.println(F("Adafruit MQTT demo for WINC1500"));

  // Initialise the Client
  Serial.print(F("\nInit the WiFi module..."));
  // check for the presence of the breakout
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WINC1500 not present");
    // don't continue:
    while (true);
  }
  Serial.println("ATWINC OK!");

  pinMode(LEDPIN, OUTPUT);
  mqtt.subscribe(&onoffbutton);
}

uint32_t x=0;

void loop() {
  // Ensure the connection to the MQTT server is alive (this will make the first
  // connection and automatically reconnect when disconnected).  See the MQTT_connect
  // function definition further below.
  MQTT_connect();

  // this is our 'wait for incoming subscription packets' busy subloop
  Adafruit_MQTT_Subscribe *subscription;
  while ((subscription = mqtt.readSubscription(5000))) {
    if (subscription == &onoffbutton) {
      Serial.print(F("Got: "));
      Serial.println((char *)onoffbutton.lastread);

      if (0 == strcmp((char *)onoffbutton.lastread, "OFF")) {
        digitalWrite(LEDPIN, LOW);
      }
      if (0 == strcmp((char *)onoffbutton.lastread, "ON")) {
        digitalWrite(LEDPIN, HIGH);
      }
    }
  }

  // Now we can publish stuff!
  Serial.print(F("\nSending photocell val "));
  Serial.print(x);
  Serial.print("...");
  if (! photocell.publish(x++)) {
    Serial.println(F("Failed"));
  } else {
    Serial.println(F("OK!"));
  }

}

// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {
  int8_t ret;

  // attempt to connect to Wifi network:
  while (WiFi.status() != WL_CONNECTED) {
    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, pass);

    // wait 10 seconds for connection:
    uint8_t timeout = 10;
    while (timeout && (WiFi.status() != WL_CONNECTED)) {
      timeout--;
      delay(1000);
    }
  }

  // Stop if already connected.
  if (mqtt.connected()) {
    return;
  }

  Serial.print("Connecting to MQTT... ");

  while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
       Serial.println(mqtt.connectErrorString(ret));
       Serial.println("Retrying MQTT connection in 5 seconds...");
       mqtt.disconnect();
       delay(5000);  // wait 5 seconds
  }
  Serial.println("MQTT Connected!");
}

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


Moved the INO to its own folder so Arduino IDE can read it.

/***************************************************
  On/ Off control 1 thermocouples
 ****************************************************/

#include "Adafruit_MAX31855.h"

// Pins connection
int thermoDO      = 3;
int thermoCLK     = 4;
int thermoCS1     = 5;
int thermoCS2     = 6;
int thermoCS3     = 7;
int thermoCS4     = 8;
int thermoCS5     = 9;
int thermoCS6     = 10;
int heaterPins1   = 11;
int heaterPins2   = 12;
int swStart       = A0;
int swMode1       = A1;
int swMode2       = A2;
int swMode3       = A3;

// Indicate status variables: 0 off; 1: on
int mode1      =  0;
int mode2      =  0;
int mode3      =  0;
int start      =  0;
int stopnow    =  0;

// constant
double tempSet         =  350;        // farenheit
double tempInc         =  3 ;         // Temperature increament per minutes
double tempErrRange    =  0;
double tempThreshold   =  3;          // Temperature limit to turn on both heaters
int ADCThreshold       =  900;
int timeDelay          =  5000;
float timeMax          =  12780;      // (sec) timeMax=time_ramping+time_at_350; (set at 2 hours), initial temp: 70*F

// calibration

double sensor1  =  0;
double sensor2  =  -4;
double sensor3  =  0;
double sensor4  =  0;
double sensor5  =  0;
double sensor6  =  0;

// variables
double tempErr;
double tempSensor1;
double tempSensor2;
double tempSensor3;
double tempSensor4;
double tempSensor5;
double tempSensor6;
double tempAverage;
double tempInitial;         // room temp

double currTempSet;
double tempSetLow;
double tempSetHigh;

double startTime;
double currTime;

// Thermocouples
Adafruit_MAX31855 thermocouple1(thermoCLK, thermoCS1, thermoDO);
Adafruit_MAX31855 thermocouple2(thermoCLK, thermoCS2, thermoDO);
Adafruit_MAX31855 thermocouple3(thermoCLK, thermoCS3, thermoDO);
Adafruit_MAX31855 thermocouple4(thermoCLK, thermoCS4, thermoDO);
Adafruit_MAX31855 thermocouple5(thermoCLK, thermoCS5, thermoDO);
Adafruit_MAX31855 thermocouple6(thermoCLK, thermoCS6, thermoDO);

void all_heaters_off()
{
  digitalWrite(heaterPins1, LOW);  // turn off the heaters
  delay(100);
  digitalWrite(heaterPins2, LOW);  // turn off the heaters
  Serial.println("  OFF");
}

void one_heater_off()
{
  digitalWrite(heaterPins1, LOW);  // turn off the heaters
  delay(100);
  Serial.println("  1 OFF");
}

void all_heaters_on()
{
  digitalWrite(heaterPins1, HIGH);  // turn on the heaters
  delay(100);
  digitalWrite(heaterPins2, HIGH);  // turn on the heaters
  delay(100);
  Serial.println("  ON");
}

void one_heater_on()
{
  digitalWrite(heaterPins1, HIGH);  // turn on the heaters
  delay(100);
  Serial.println("  1 ON");
}

void setup() {
  Serial.begin(9600);
  pinMode(heaterPins1, OUTPUT);
  pinMode(heaterPins2, OUTPUT);
  // wait for MAX chip to stabilize
  delay(1000);
  all_heaters_off();
  Serial.println("MAX31855 test");
  startTime= millis();
}

int scan_button(int swButton)
{
  int ADCreading = analogRead(swButton);
//  Serial.println(ADCreading);
  if (ADCreading < ADCThreshold)
         return (1);
  else   return (0);
}

void tempPrint()
{
  Serial.print("Current temperature F = ");
 // Serial.println(tempSensor1,"\t", tempSensor2,"\t",tempSensor3,"\t",tempSensor4,"\t",tempSensor5,"\t",tempSensor6);
  Serial.print(tempSensor1);
  Serial.print(" ");
  Serial.print(tempSensor2);
  Serial.print(" ");
  Serial.print(tempSensor3);
  Serial.print(" ");
  Serial.print(tempSensor4);
  Serial.print(" ");
  Serial.print(tempSensor5);
  Serial.print(" ");
  Serial.println(tempSensor6);
  Serial.print("Average temperature F = ");
  Serial.println(tempAverage);
}

void sensors_reading()
{
    // scanning all of the sensors and switches
  mode1 = scan_button(swMode1);
  mode2 = scan_button(swMode2);
  start = scan_button(swStart);
  float tempSum=0;
  int count=0;
  tempSensor1 = thermocouple1.readFarenheit()+sensor1;
  if (tempSensor1>32) // eliminate the SPI disconection
    {
      count=count+1;
      tempSum=tempSum+tempSensor1;
    }
  delay(10);
  tempSensor2 = thermocouple2.readFarenheit()+sensor2;
    if (tempSensor2>32) // eliminate the SPI disconection
    {
      count=count+1;
      tempSum=tempSum+tempSensor2;
    }
  delay(10);
  tempSensor3 = thermocouple3.readFarenheit()+sensor3;
    if (tempSensor3>32) // eliminate the SPI disconection
    {
      count=count+1;
      tempSum=tempSum+tempSensor3;
    }
  delay(10);
  tempSensor4 = thermocouple4.readFarenheit()+sensor4;
    if (tempSensor4>32) // eliminate the SPI disconection
    /*{
      count=count+1;
      tempSum=tempSum+tempSensor4;
    }*/
  //delay(10);
  tempSensor5 = thermocouple5.readFarenheit()+sensor5;
    /*if (tempSensor5>32) // eliminate the SPI disconection
    {
      count=count+1;
      tempSum=tempSum+tempSensor5;
    }*/
  //delay(10);
  tempSensor6 = thermocouple6.readFarenheit()+sensor6;
    /*if (tempSensor6>32) // eliminate the SPI disconection
    {
      count=count+1;
      tempSum=tempSum+tempSensor6;
    }*/
  tempAverage = tempSum/count;
  tempPrint();
}

void loop() {
  all_heaters_off();
  sensors_reading();
  tempInitial = tempAverage;         // initial start temp
  startTime=millis();
  // compared and controled
  while (start&(!stopnow))
  {
    currTime=millis()-startTime;
    currTempSet=min (350, currTime/1000/60*tempInc+tempInitial);
    Serial.print("Set temperature     F = ");
    Serial.println(currTempSet);
    tempSetLow= currTempSet-tempErrRange;
    tempSetHigh= currTempSet+tempErrRange;

    if ((tempAverage<tempSetLow)&&(tempAverage>32) )
    {
      if (tempAverage<tempSetLow-tempThreshold) all_heaters_on();
      else one_heater_on();
    }
    else
    {
      if (tempAverage>tempSetHigh+tempThreshold)
      {
        all_heaters_off();
      }
      else one_heater_off();
    }
    if ((currTime/1000)>=timeMax)
      {
        stopnow=1;
      }
    delay(timeDelay);
    sensors_reading();
   }
  if (stopnow)
  {
    Serial.println("Mission complete, please wait until the oven cold down");
    while(1);  // stay here until turn off the controller.
  }
  delay(timeDelay);
}

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


Barograph Update

Barograph Update

Now matches v3 PCBs

error: pathspec 'Action' did not match any file(s) known to git
error: pathspec 'Modules/Bar' did not match any file(s) known to git
error: pathspec 'Graph/BarGraphATtiny/BarGraphATtiny.ino' did not match any file(s) known to git


Last Update in the arduino code

Last Update in the arduino code

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


ave.stddev test

ave.stddev test

#include <Wire.h>
#include <Average.h>

// Reserve space for 10 entries in the average bucket.
// Change the type between < and > to change the entire way the library works.
Average<float> ave(10);
int x;
int r = LOW;
int o_r = LOW;

void setup() {
  Serial.begin(38400);
  Wire.begin(7);
  Wire.onReceive(receiveEvent);
}

void loop() {

  if ( r != o_r) {

    // Add a new random value to the bucket
    ave.push(x);

    Serial.print(x);
    Serial.print(" -> ");
    // Display the current data set
    for (int i = 0; i < 10; i++) {
      Serial.print(ave.get(i), 0);
      Serial.print(" ");
    }

    // And show some interesting results.
    Serial.print("\t\tMean:   "); Serial.print(ave.mean(), 0);
    Serial.print("  Max:    "); Serial.print(ave.maximum(), 0);
    Serial.print("  Min:    "); Serial.print(ave.minimum(), 0);
    Serial.print("  Max - Min:     "); Serial.print((ave.maximum() - ave.minimum()), 0);
    Serial.print("  StdDev: "); Serial.println(ave.stddev(), 0);

    o_r = r ;
  }

}

void receiveEvent(int howMany)
{
  byte a, b;

  a = Wire.read();
  b = Wire.read();

  x = a;
  x = x << 8 | b;

  r = !r ;
}

error: pathspec '_03-hx711-scale-v2-battery-external-Interrupt-02/stddev_test/Average_test.ino' did not match any file(s) known to git


Funny action : code final, en attente de test

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'Funny' did not match any file(s) known to git
error: pathspec 'Action/Software/Funny_action/Funny_action.ino' did not match any file(s) known to git


Adding the IR Sender, with few basic supported commands (very few...)

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


New program to gather throttle/speed data

/*
 Elcano Contol Module C2 Data.

 Gather data for use in simulation and better understand vehicle behavior. TCF Sept 1, 2014.

 Outputs are
 1) Analog 0-4 V signal for traction motor speed
 2) Pulse wave Modulated (PWM) signal for brakes.
 3) PWM signal for steering.

 */

// Input/Output (IO) pin names for the MegaShieldDB printed circuit board (PCB)
#include "IOPCB.h"

// When setting up the project, select
//   Sketch  |  Import Library ... |  SPI
// include the Serial Periferal Interface (SPI) library:
#include <SPI.h>
// The MegaShieldDB has a four channel Digital to Analog Converter (DAC).
// Basic Arduino cannot write a true analog signal, but only PWM.
// Many servos take PWM.
// An electric bicycle (E-bike) throttle expects an analog signal.
// We have found that feeding a pwm signal to an e-bike controller makes the motor chug at low speed.

#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#ifndef NaN
#define NaN 0xFFFFFFFF
#endif

#define LOOP_TIME_MS 100
#define WHEEL_DIAMETER_MM 397
#define BUFFER_SIZE 80
#define ERROR_HISTORY 20

// Values to send over DAC
const int FullThrottle =  227;   // 3.63 V
const int MinimumThrottle = 50; // was 70;  // Throttle has no effect until 1.2 V
const int TestThrottle = MinimumThrottle + (FullThrottle - MinimumThrottle)/2;
// Values to send on PWM to get response of actuators
const int FullBrake = 167;  // start with a conservative value; could go as high as 255;
const int NoBrake = 207; // start with a conservative value; could go as low as 127;
// Steering
const int HardLeft = 250; //  could go as high as 255;
const int Straight = 187;
const int HardRight = 126;

// globals
long sensor_speed_mmPs = 0;
long drive_speed_mmPs = 0;
char IncomingMessage[BUFFER_SIZE];
int  InIndex=0;
int  throttle_control = MinimumThrottle;
int  brake_control = FullBrake;
int  steer_control = Straight;
long speed_errors[ERROR_HISTORY];
long start_time;
long SpeedCyclometer_mmPs = 0;

/*  Elcano #1 Servo range is 50 mm for brake, 100 mm for steering.

    Elcano servo has a hardware controller that moves to a
    particular position based on an input PWM signal from Arduino.
    The Arduino PWM signal is a square wave at a base frequency of 490 Hz or 2.04 ms.
    PWM changes the duty cycle to encode
    0 is always off; 255 always on. One step is 7.92 us.

    Elcano servo is fully retracted on a pulse width of 2 ms;
    fully extended at 1 ms and centered at 1.5 ms.
    There is a deadband of 8 us.
    At 12v, servo operating speed is 56mm/s with no load or
    35 mm/s at maximum load.

    Output from hardware servo controller to either servo has five wires, with observed bahavior of:
    White: 0V
    Yellow: 5V
    Blue: 0-5V depending on position of servo.
    Black: 12V while servo extends; 0V at rest or retracting.
    Red:   12V while retracting; 0V at rest or extending.
    The reading on the Blue line has hysteresis when Elcano sends a PWM signal;
    there appear to be different (PWM, position) pairs when retracting or extending.
    Motor speed is probably controlled by the current on the red or black line.
*/
/*---------------------------------------------------------------------------------------*/
void initialize()
{
  for (int i = 0; i < ERROR_HISTORY; i++)
  {
      speed_errors[i] = 0;
  }

}
/*---------------------------------------------------------------------------------------*/
void setup()
{
    //Set up pin modes and interrupts, call serial.begin and call initialize.
    Serial.begin(115200); // monitor
    Serial3.begin(115200); // C3 to C2;  C2 to C6
	/* A typical message is 20 ASCII characters of 20 bits each
	   (2 8-bit bytes / character + start bit + stop bit)
	   At 115,200 bits/s, a typical message takes 3.5 ms.
	   Thus there is about a 10 ms delay (best case) in passing
	   information from C6 to C2.
	*/

    // SPI: set the slaveSelectPin as an output:
    pinMode (SelectAB, OUTPUT);
    pinMode (SelectCD, OUTPUT);
    pinMode (10, OUTPUT);
    SPI.setDataMode( SPI_MODE0);
    SPI.setBitOrder( MSBFIRST);
    // initialize SPI:
    SPI.begin();
    for (int channel = 0; channel < 4; channel++)
        DAC_Write (channel, 0);   // reset did not clear previous states

    pinMode(Throttle, OUTPUT);
    pinMode(DiskBrake, OUTPUT);
    pinMode(Steer, OUTPUT);
    pinMode(AccelerateJoystick, INPUT);
    pinMode(SteerJoystick, INPUT);
    pinMode(JoystickCenter, INPUT);

    Serial.println("Start initialization");
    initialize();
    setupWheelRev();

    moveBrake(NoBrake);   // release brake
    start_time = millis() + 1000;  // wait 1 sec to start.
    Serial.println("Initialized");

}
/*---------------------------------------------------------------------------------------*/
char * GetWord(char * major, char * str)
{
	char * CSp1;

	CSp1 = strstr(str, major);
	if (CSp1!=NULL)
	CSp1 += strlen(major);
	return CSp1;
}
float GetNumber(char *minor, char*Args)
{
  float data = NaN;
  if (Args == NULL) return data;
  // SENSOR, so grab the new sensor_speed.
  char * Number = GetWord(minor, Args);
  if (Number==NULL) return data;
   // change } to 0
   char* end = strchr(Number, '}');
   if (end == NULL) return NaN;
   *end = '\0';
   data = atof(Number);
   // change back to }
   *end = '}';
   // convert speed from km/h to mm/s
//   sensor_speed_mmPs = (long)(data * 1000000.0 / 3600.0);
   return data;
}
/*---------------------------------------------------------------------------------------*/
#define MSG_NONE 0
#define MSG_SENSOR 1
#define MSG_DRIVE 2
int ProcessMessage ()
{
    int kind = MSG_NONE;
    float data;
	// Determine if message is "SENSOR {Speed xxx.xx}"
	char * Args = GetWord ("SENSOR", IncomingMessage);
	if (Args != NULL)
	{
            data = GetNumber("Speed", Args);
    	    // convert speed from km/h to mm/s
    	    if (data != NaN)
            {
                sensor_speed_mmPs = (long)(data * 1000000.0 / 3600.0);
                kind = MSG_SENSOR;
            }
	}

    return kind;
}
/*---------------------------------------------------------------------------------------*/
void SetDriveSpeed(unsigned long time)
{
#define RAMP_UP_TIME 4000
#define STEADY_TIME  5000
#define COAST_TIME  15000
   if (time < start_time)
     throttle_control = MinimumThrottle;
   else if (time < start_time + RAMP_UP_TIME)
   {
     long int control = MinimumThrottle + (TestThrottle - MinimumThrottle) *
       (time - start_time) / RAMP_UP_TIME;
     throttle_control = control;
   }
   else if (time < start_time  + RAMP_UP_TIME + STEADY_TIME)
   {
     throttle_control = TestThrottle;
   }
   else
   {
    throttle_control = MinimumThrottle;
    brake_control = FullBrake;
   }

}
/*---------------------------------------------------------------------------------------*/
void LogData(unsigned long time)
{  // Comma separated values to transfer to spread-sheet
  if (time < start_time + RAMP_UP_TIME + STEADY_TIME + COAST_TIME)
  {
    Serial.print(time); Serial.print(',');
    Serial.print(SpeedCyclometer_mmPs); Serial.print(',');
    Serial.print(throttle_control); Serial.print(',');
    Serial.println(brake_control);
  }

}
/*---------------------------------------------------------------------------------------*/
void loop()
{
    int incomingByte = 0;   // for incoming serial data
    unsigned long time, endTime;
    time = millis();
    endTime = time + LOOP_TIME_MS ;
    while (time < endTime)
    {
	if ( Serial3.available() > 0)
	{
	    // read the incoming byte from C4:
	    incomingByte =  Serial3.read();
	    {
		IncomingMessage[InIndex] = (char)(incomingByte);
		if (IncomingMessage[InIndex] == '\0'
		 || InIndex >= BUFFER_SIZE-1)
		{
		    int kind = ProcessMessage();  // see what we got
                    // ProcessMessage may set sensor_speed_mmPs
		    InIndex = 0;
                    if (kind != MSG_SENSOR)  // Sensor messages originate from C6
		        Serial3.print(IncomingMessage); // pass msg on to C6
                    Serial.println(IncomingMessage);  // for monitor
		}
		else
		{
		    ++InIndex;
		}
	    }
	}
	time = millis();
    }
  SetDriveSpeed(time);
  show_speed();  // set cyclometer speed
  moveVehicle(throttle_control);
  moveBrake(brake_control);
  LogData(time);

 // apply steering
  steer_control =  Straight;
  moveSteer(steer_control);

}
/*---------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------*/
void moveBrake(int i)
{
     analogWrite(DiskBrake, i);
}
/*---------------------------------------------------------------------------------------*/
void moveSteer(int i)
{
     analogWrite(Steer, i);
}
/*---------------------------------------------------------------------------------------*/
void moveVehicle(int counts)
{
    /* Observed behavior on ElCano #1 E-bike no load (May 10, 2013, TCF)
      0.831 V at rest       52 counts
      1.20 V: nothing       75
      1.27 V: just starting 79
      1.40 V: slow, steady  87
      1.50 V: brisker       94
      3.63 V: max          227 counts
      255 counts = 4.08 V
      */
   DAC_Write(0, counts);
}
/*---------------------------------------------------------------------------------------*/
/* DAC_Write applies value to address, producing an analog voltage.
// address: 0 for chan A; 1 for chan B; 2 for chan C; 3 for chan D
// value: digital value converted to analog voltage
// Output goes to mcp 4802 Digital-Analog Converter Chip via SPI
// There is no input back from the chip.
*/
void DAC_Write(int address, int value)

/*
REGISTER 5-3: WRITE COMMAND REGISTER FOR MCP4802 (8-BIT DAC)
A/B  —  GA  SHDN  D7 D6 D5 D4 D3 D2 D1 D0 x x x x
bit 15                                       bit 0

bit 15   A/B: DACA or DACB Selection bit
         1 = Write to DACB
         0 = Write to DACA
bit 14   — Don’t Care
bit 13   GA: Output Gain Selection bit
         1 = 1x (VOUT = VREF * D/4096)
         0 = 2x (VOUT = 2 * VREF * D/4096), where internal VREF = 2.048V.
bit 12   SHDN: Output Shutdown Control bit
         1 = Active mode operation. VOUT is available.
         0 = Shutdown the selected DAC channel. Analog output is not available at the channel that was shut down.
         VOUT pin is connected to 500 k (typical)
bit 11-0 D11:D0: DAC Input Data bits. Bit x is ignored.

With 4.95 V on Vcc, observed output for 255 is 4.08V.
This is as documented; with gain of 2, maximum output is 2 * Vref

*/

{
  int byte1 = ((value & 0xF0)>>4) | 0x10; // acitve mode, bits D7-D4
  int byte2 = (value & 0x0F)<<4;           // D3-D0
  if (address < 2)
  {
      // take the SS pin low to select the chip:
      digitalWrite(SelectAB,LOW);
      if (address >= 0)
      {
        if (address == 1)
          byte1 |= 0x80;  // second channnel
        SPI.transfer(byte1);
        SPI.transfer(byte2);
       }
      // take the SS pin high to de-select the chip:
      digitalWrite(SelectAB,HIGH);
  }
  else
  {
      // take the SS pin low to select the chip:
      digitalWrite(SelectCD,LOW);
      if (address <= 3)
      {
        if (address == 3)
          byte1 |= 0x80;  // second channnel
        SPI.transfer(byte1);
        SPI.transfer(byte2);
      }
       // take the SS pin high to de-select the chip:
      digitalWrite(SelectCD,HIGH);
  }
}
/*---------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------*/
/*=======================================================================================*/

/* Wheel Revolution Interrupt routine
   Ben Spencer 10/21/13
   Modified by Tyler Folsom 3/16/14

   A cyclometer gives a click once per revolution.
   This routine computes the speed.
*/
// CLICK_IN defined: use interrupt; not defined: simulate with timer
#define SerialMonitor Serial
#define CLICK_IN 1
#define LOOP_TIME_MS 1000
#define CLICK_TIME_MS 1000

#define WHEEL_DIAMETER_MM 397
#define MEG 1000000
#define MAX_SPEED_KPH 50
#define MAX_SPEED_mmPs   ((MAX_SPEED_KPH * MEG) / 3600)
// MAX_SPEED_mmPs = 13,888 mm/s = 13.888 m/s
unsigned long MinTickTime_ms;
// ((WHEEL_DIAMETER_MM * 3142) / MAX_SPEED_mmPs)
// MinTickTime_ms = 89 ms
#define MIN_SPEED_mPh 500
// A speed of less than 0.5 KPH is zero.
unsigned long MaxTickTime_ms;
// ((WHEEL_DIAMETER_MM * 3142) / MIN_SPEED_mmPs)
// MinTickTime_ms = 9239 ms = 9 sec

float Odometer_m = 0;
// Speed in revolutions per second is independent of wheel size.
float SpeedCyclometer_revPs = 0.0;//revolutions per sec
volatile unsigned long TickTime = 0;
long WheelRev_ms = 0;
volatile unsigned long OldTick = 0;
// volatile unsigned long InterruptCount =0;
#define IRQ_NONE 0
#define IRQ_FIRST 1
#define IRQ_RUNNING 2
volatile int InterruptState = IRQ_NONE;
unsigned long ShowTime_ms;
/*-------------------------------------------------------------------------------*/
// WheelRev is called by an interrupt.
void WheelRev()
{
    static int flip = 0;
    unsigned long tick;
    noInterrupts();
    tick = millis();
    if (InterruptState != IRQ_RUNNING)
    // Need to process 1st two interrupts before results are meaningful.
        InterruptState++;

    if (tick - TickTime > MinTickTime_ms)
    {
        OldTick = TickTime;
        TickTime = tick;
    }
    if (flip)
        digitalWrite(13, LOW);
    else
        digitalWrite(13, HIGH);
    flip =!flip;

    interrupts();
}
/*---------------------------------------------------------------------------------------*/

void setupWheelRev()
{

    pinMode(13, OUTPUT); //led
    digitalWrite(13, LOW);//turn LED off

    pinMode(2, INPUT);//pulls input HIGH
    float MinTick = WHEEL_DIAMETER_MM * PI;
//    SerialMonitor.print (" MinTick = ");
//    SerialMonitor.println (MinTick);
    MinTick *= 1000.0;
    MinTick /= MAX_SPEED_mmPs;
//    SerialMonitor.print (MinTick);
    MinTickTime_ms = MinTick;
    SerialMonitor.print (" MinTickTime_ms = ");
    SerialMonitor.println (MinTickTime_ms);

//    SerialMonitor.print (" MIN_SPEED_mPh = ");
//    SerialMonitor.print (MIN_SPEED_mPh);
    float MIN_SPEED_mmPs =  ((MIN_SPEED_mPh * 1000.0) / 3600.0);
    // MIN_SPEED_mmPs = 135 mm/s
//    SerialMonitor.print (" MIN_SPEED_mmPs = ");
//    SerialMonitor.print (MIN_SPEED_mmPs);
    float MaxTick = (WHEEL_DIAMETER_MM * PI * 1000.0) / MIN_SPEED_mmPs;
//    SerialMonitor.print (" MaxTick = ");
//    SerialMonitor.print (MaxTick);
    MaxTickTime_ms = MaxTick;
//    SerialMonitor.print (" MaxTickTime = ");
//    SerialMonitor.println (MaxTickTime_ms);
    TickTime = millis();
    // OldTick will normally be less than TickTime.
    // When it is greater, TickTime - OldTick is a large positive number,
    // indicating that we have not moved.
    // TickTime would overflow after days of continuous operation, causing a glitch of
    // a display of zero speed.  It is unlikely that we have enough battery power to ever see this.
    OldTick = TickTime;
    ShowTime_ms = TickTime;
 //   InterruptCount = 0;
    InterruptState = IRQ_NONE;
    attachInterrupt (1, WheelRev, RISING);//pin 3 on C2 Mega
    SerialMonitor.print("TickTime: ");
    SerialMonitor.print(TickTime);
    SerialMonitor.print(" OldTick: ");
    SerialMonitor.println(OldTick);

    SerialMonitor.println("setup complete");
}
/*---------------------------------------------------------------------------------------*/

void show_speed()
{
   ShowTime_ms = millis();
   if (InterruptState == IRQ_NONE || InterruptState == IRQ_FIRST)  // no OR 1 interrupts
   {
       SpeedCyclometer_mmPs = 0;
       SpeedCyclometer_revPs = 0;
   }
  //check if velocity has gone to zero
   else // have at least twointerrupts
   {
    if(ShowTime_ms - TickTime > MaxTickTime_ms)
    {  // stopped
/*        SerialMonitor.print("Stop. Showtime: ");
        SerialMonitor.print(ShowTime_ms);
        SerialMonitor.print(" Tick: ");
        SerialMonitor.println(TickTime); */
        SpeedCyclometer_mmPs = 0;
        SpeedCyclometer_revPs = 0;
    }
    else
    {  // moving
//        int revolutions;
        WheelRev_ms = max(TickTime - OldTick, ShowTime_ms - TickTime);
        if (InterruptState == IRQ_RUNNING)
        {  // have new data

            float Circum_mm = (WHEEL_DIAMETER_MM * PI);
            if (WheelRev_ms > 0)
            {
                SpeedCyclometer_revPs = 1000.0 / WheelRev_ms;
                SpeedCyclometer_mmPs  = Circum_mm * SpeedCyclometer_revPs;
            }
            else
            {
                SpeedCyclometer_mmPs = 0;
                SpeedCyclometer_revPs = 0;
            }
        }
    }
    }
    // Show on monitor
/*    SerialMonitor.print("\nWheelRev (ms): ");
    SerialMonitor.print(WheelRev_ms);
    SerialMonitor.print(" SENSOR ");
    SerialMonitor.print("{Speed ");
    SerialMonitor.print(SpeedCyclometer_revPs);
    SerialMonitor.println("}\0"); */
    Odometer_m += (float)(LOOP_TIME_MS * SpeedCyclometer_mmPs) / MEG;
}

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


added temperature and humidity RPI

added temperature and humidity RPI

added adruino project that talks to the raspberry pi

#include <JeeLib.h> //Low Power functions library
#include <SPI.h>
#include "RF24.h"

// User Config for wireless module
bool radioNumber = 1;
RF24 radio(9,10);
// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
byte addresses[][6] = {"1Node","2Node"};

//
// Payload
//

const int min_payload_size = 4;
const int max_payload_size = 32;
const int payload_size_increments_by = 1;
int next_payload_size = min_payload_size;

char receive_payload[max_payload_size+1]; // +1 to allow room for a terminating NULL char

ISR(WDT_vect) { Sleepy::watchdogEvent(); } //Setup the watchdog
//Setup temperature sensor
int DHpin = 8;
byte dat [5];
byte read_data () {
  byte data;
  for (int i = 0; i < 8; i ++) {
    if (digitalRead (DHpin) == LOW) {
      while (digitalRead (DHpin) == LOW); // wait for 50us
      delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1'
      if (digitalRead (DHpin) == HIGH)
        data |= (1 << (7-i)); // high front and low in the post
      while (digitalRead (DHpin) == HIGH); // data '1 ', wait for the next one receiver
     }
  }
return data;
}

void start_test () {
  digitalWrite (DHpin, LOW); // bus down, send start signal
  delay (30); // delay greater than 18ms, so DHT11 start signal can be detected

  digitalWrite (DHpin, HIGH);
  delayMicroseconds (40); // Wait for DHT11 response

  pinMode (DHpin, INPUT);
  while (digitalRead (DHpin) == HIGH);
  delayMicroseconds (80); // DHT11 response, pulled the bus 80us
  if (digitalRead (DHpin) == LOW);
  delayMicroseconds (80); // DHT11 80us after the bus pulled to start sending data

  for (int i = 0; i < 4; i ++) // receive temperature and humidity data, the parity bit is not considered
    dat[i] = read_data ();

  pinMode (DHpin, OUTPUT);
  digitalWrite (DHpin, HIGH); // send data once after releasing the bus, wait for the host to open the next Start signal
}

int cToF (int c) {
  int f = 1.8 * c + 32;
  return f;
}

void setup () {
  Serial.begin (9600);
  pinMode (DHpin, OUTPUT);

  radio.begin();
  radio.enableDynamicPayloads();

  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  //  radio.setPALevel(RF24_PA_LOW);

//  radio.openWritingPipe(addresses[1]);
//  radio.openReadingPipe(1, addresses[0]);
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);

//  radio.startListening();
}

void loop () {
  digitalWrite(13, LOW);
  start_test ();

radio.stopListening();
  Serial.println(F("Now sending"));
  Serial.println(dat[2], DEC);
//  if(!radio.write(&dat, sizeof(byte)*5)){
//    Serial.println(F("failed"));
//  }
//  radio.write(&dat, sizeof(byte)*5);
  radio.write(dat, next_payload_size);

  radio.startListening();
  unsigned long started_waiting_at = millis();
  bool timeout = false;

  while(!radio.available() && !timeout){
    if(millis() - started_waiting_at > 1000){
      timeout = true;
      break;
    }
  }

  if(timeout){
    Serial.println(F("Failed, response time out."));
  }else{
    uint8_t len = radio.getDynamicPayloadSize();
    if(!len){
      return;
    }
    radio.read(receive_payload, len);
    receive_payload[len] = 0;
    Serial.print(F("Got response "));
    Serial.println(receive_payload);
  }

  radio.stopListening();
  delay(500);
  Sleepy::loseSomeTime(1000);
}

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


found an error, can i keep it?

found an error, can i keep it?

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/Tengo10/Clock-Weather-Oled.git/'


Checkin a modified version of the strandtest.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 7

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(300, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  // Some example procedures showing how to display to the pixels:
//  colorWipe(strip.Color(255, 255, 255), 50); // Red
//  colorWipe(strip.Color(255, 0, 0), 50); // Red
//  colorWipe(strip.Color(0, 255, 0), 50); // Green
//  colorWipe(strip.Color(0, 0, 255), 50); // Blue
////colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
//  // Send a theater pixel chase in...
//  theaterChase(strip.Color(127, 127, 127), 50); // White
//  theaterChase(strip.Color(127, 0, 0), 50); // Red
//  theaterChase(strip.Color(0, 0, 127), 50); // Blue

  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

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


Added Arduino code to listen to clock and data lines and push one byte at a time to the serial port, will be useful for testing once Android portion of the code is working.

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